Modified google plugin dialog
[mdictionary] / src / plugins / xdxf / XdxfDialog.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 /*!
23     \file XdxfDialog.cpp
24     \author Mateusz Półrola <mateusz.polrola@gmail.com>
25 */
26
27 #ifndef XDXFDIALOG_H
28 #define XDXFDIALOG_H
29
30 #include <QDialog>
31 #include "../../include/settings.h"
32 #include <QtGui>
33 #include "xdxfplugin.h"
34
35
36 //! Implementation of xdxf plugin's dialogs.
37 /*!
38     This class can create dialogs for adding new dictionary or changins settings
39      of existing one, based on dialog type passed to contructor.
40     When adding new dictionary dialog contains button to browse file system and
41     select dictionary file. When changing settings dialog displays basic
42     information about dictionary i. e. name, languages and license info.
43     In both types of dialogs there are comboboxes with cache and remove accents
44      options. On maemo right next to comboboxes are tool button which allow to
45      see more information about this options, on desktop the same information is
46      displayed as tool tip.
47     All content of dialog is in scroll area.
48 */
49 class XdxfDialog : public QDialog
50 {
51     Q_OBJECT
52 public:
53     /*!
54       Describes type of dialog. New means that dialog contains widgets to browse
55         file system and select dictionary file. Change means that dialog displays
56      information about dictionary.
57       In both types dialog provides widgets to create or delete cache and remove
58      or left accents.
59     */
60     enum XdxfDialogType {New, Change};
61
62     //! Constructor
63     /*!
64         Creates new xdxf dialog
65         \param plugin if creating dialog of type Change it must be set to
66             pointer of plugin whose settings will be changed
67         \param type describes type of creating dialog
68         \param parent parent widget of creating dialog
69     */
70     explicit XdxfDialog(XdxfPlugin* plugin = 0,
71                         XdxfDialogType type = New,
72                         QWidget* parent = 0);
73
74     //! Returns settings of plugin
75     /*!
76         After acceptance of dialog this method return plugin's settings based on
77          user choises in dialog.
78     */
79     Settings* getSettings();
80
81 Q_SIGNALS:
82     //! Request to show notification
83     void notify(Notify::NotifyType, QString);
84
85 public Q_SLOTS:
86     //! Reimplemented accept method, to check if all necessery fields in
87     //! dialog are correct e. g. dictionary file path
88     //! and saves new settings
89     void accept();
90
91 private Q_SLOTS:
92     //! displays dialog to browse and select file
93     void selectFile();
94     void setGenerateCache(bool);
95     void setAccents(bool);
96
97     #ifdef Q_WS_MAEMO_5
98         //! on maemo shows information about checkboxes
99         void showCacheInfo();
100         void showAccentsInfo();
101     #endif
102
103
104 private:
105     void initializeUI();
106
107     //! saves new settings after acceptance of dialog
108     void saveSettings();
109
110     QLabel* infoLabel;
111     QPushButton* browseButton;
112     QHBoxLayout* browseLayout;
113
114
115     QCheckBox* cacheCheckBox;
116     QCheckBox* accentsCheckBox;
117     QHBoxLayout* cacheLayout;
118     QHBoxLayout* accentsLayout;
119
120     QString cacheToolTip;
121     QString accentsToolTip;
122
123     #ifdef Q_WS_MAEMO_5
124         QToolButton* cacheInfoToolButton;
125         QToolButton* accentsInfoToolButton;
126     #endif
127
128
129     QPushButton* confirmButton;
130
131     QString _dictionaryFilePath;
132
133     QScrollArea* scrollArea;
134
135     QWidget* widget;
136     QHBoxLayout* layout;
137
138     QVBoxLayout* mainVerticalLayout;
139     bool _generateCache;
140     bool _accents;
141     bool _lastAccents;
142
143     Settings* _settings;
144
145     XdxfPlugin* plugin;
146     XdxfDialogType type;
147 };
148
149 #endif // XDXFDIALOG_H