b8d98415e4a35b6c71375ba201f971fc8265cc30
[mdictionary] / src / mdictionary / gui / SettingsWidget.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     mDictionary is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21
22 /*! \file DictManagerWidget.h
23     \brief Implements applications settings widget
24     \author Mateusz Półrola <mateusz.polrola@comarch.pl>
25 */
26
27 #ifndef SETTINGSWIDGET_H
28 #define SETTINGSWIDGET_H
29
30 #include <QWidget>
31 #include <QtGui>
32 #include <QPushButton>
33 #include <QDeclarativeView>
34
35 #include "../../include/GUIInterface.h"
36 #include "../../include/settings.h"
37 #include "SpinBox.h"
38
39
40 /*!
41   Shows settings that user can change.
42   It allows to change limit of searches and limit of history.
43   It also allows to select if application has to search in dictionaries or in
44   bookmarks or in both of them. All changes are saved automatically after
45   hiding of this widget.
46   */
47 class SettingsWidget : public QDialog
48 {
49     Q_OBJECT
50 public:
51     //! Constructor
52     /*!
53       \param parent parent of this widget, which must be a subclass of
54       GUIInterface, because it will use it to get current settings and
55       set new ones.
56       */
57     explicit SettingsWidget(GUIInterface *parent = 0);
58
59 Q_SIGNALS:
60     void notify(Notify::NotifyType, QString);
61
62 protected:
63     void showEvent(QShowEvent *);
64     void hideEvent(QHideEvent *);
65
66 private Q_SLOTS:
67     void changed();
68     #ifndef Q_WS_MAEMO_5
69         void save();
70     #endif
71     #ifdef Q_WS_MAEMO_5
72         void showSearchResultSizeInfo();
73         void showHistorySizeInfo();
74     #endif
75
76 private:
77     void initalizeUI();
78
79     QVBoxLayout* mainLayout;
80     QDeclarativeView *view;
81
82     SpinBox* historySizeSpinBox;
83     SpinBox* searchResultSizeSpinBox;
84     QVBoxLayout* verticalLayout;
85     QFormLayout* spinBoxesFormLayout;
86     QHBoxLayout* historySizeLayout;
87     QHBoxLayout* searchResultLayout;
88
89     #ifdef Q_WS_MAEMO_5
90         QToolButton* historySizeInfoToolButton;
91         QToolButton* searchResultSizeInfoToolButton;
92     #endif
93
94     QLabel* checkBoxesLabel;
95     QCheckBox* searchInDictionariesCheckBox;
96     QCheckBox* searchInBookmarksCheckBox;
97
98
99     GUIInterface* guiInterface;
100     Settings* settings;
101     bool _changed;
102
103     QString searchResultSizeToolTip;
104     QString historySizeToolTip;
105
106     #ifndef Q_WS_MAEMO_5
107         QPushButton* closeButton;
108         QHBoxLayout* footerLayout;
109         bool _save;
110     #endif
111
112
113
114 };
115
116 #endif // SETTINGSWIDGET_H