add setingWidget Qml
[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 #include <QVariant>
35
36 #include "../../include/GUIInterface.h"
37 #include "../../include/settings.h"
38 #include "SpinBox.h"
39
40
41 /*!
42   Shows settings that user can change.
43   It allows to change limit of searches and limit of history.
44   It also allows to select if application has to search in dictionaries or in
45   bookmarks or in both of them. All changes are saved automatically after
46   hiding of this widget.
47   */
48 class SettingsWidget : public QDialog
49 {
50     Q_OBJECT
51 public:
52     //! Constructor
53     /*!
54       \param parent parent of this widget, which must be a subclass of
55       GUIInterface, because it will use it to get current settings and
56       set new ones.
57       */
58     explicit SettingsWidget(GUIInterface *parent = 0);
59
60 Q_SIGNALS:
61     void setMinHistory(QVariant minValue);
62     void setMaxHistory(QVariant minValue);
63     void setValueHistory(QVariant value);
64     void setMinSearchResult(QVariant minValue);
65     void setMaxSearchResult(QVariant minValue);
66     void setValueSearchResult(QVariant value);
67     void setCheckedBookmarks(QVariant boolen);
68     void setCheckedDictionaries(QVariant boolen);
69
70     void notify(Notify::NotifyType, QString);
71
72 protected:
73     void showEvent(QShowEvent *);
74     void hideEvent(QHideEvent *);
75
76 private Q_SLOTS:
77     void historySizeValueChanged(int value);
78     void searchResulValueChanged(int value);
79     void dictionariesCheckBoxChanged(bool boolean);
80     void bookmarksCheckBoxChanged(bool boolean);
81
82     void changed();
83     #ifndef Q_WS_MAEMO_5
84         void save();
85     #endif
86     #ifdef Q_WS_MAEMO_5
87         void showSearchResultSizeInfo();
88         void showHistorySizeInfo();
89     #endif
90
91 private:
92     void initalizeUI();
93
94     QVBoxLayout* mainLayout;
95     QDeclarativeView *view;
96
97     SpinBox* historySizeSpinBox;
98     SpinBox* searchResultSizeSpinBox;
99     QVBoxLayout* verticalLayout;
100     QFormLayout* spinBoxesFormLayout;
101     QHBoxLayout* historySizeLayout;
102     QHBoxLayout* searchResultLayout;
103
104     #ifdef Q_WS_MAEMO_5
105         QToolButton* historySizeInfoToolButton;
106         QToolButton* searchResultSizeInfoToolButton;
107     #endif
108
109     QLabel* checkBoxesLabel;
110     QCheckBox* searchInDictionariesCheckBox;
111     QCheckBox* searchInBookmarksCheckBox;
112
113
114     GUIInterface* guiInterface;
115     Settings* settings;
116     bool _changed;
117
118     QString searchResultSizeToolTip;
119     QString historySizeToolTip;
120
121     #ifndef Q_WS_MAEMO_5
122         QPushButton* closeButton;
123         QHBoxLayout* footerLayout;
124         bool _save;
125     #endif
126     int historyValue;
127     int searchResultValue;
128     bool dictionariesCheckBox;
129     bool bookmarksCheckBox;
130 };
131
132 #endif // SETTINGSWIDGET_H