aef9986d8fddf0ef89d4ce59e545bf225bfb0e69
[mdictionary] / src / plugins / stardict / StarDialog.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 StarDialog.h
23     \author Mateusz Półrola <mateusz.polrola@gmail.com>
24 */
25
26 #ifndef STARDIALOG_H
27 #define STARDIALOG_H
28
29 #include <QDialog>
30 #include "../../include/settings.h"
31 #include <QtGui>
32 #include "StarDictPlugin.h"
33
34
35 //! Implementation of stardict plugin's dialogs.
36 /*!
37     This class can create dialogs for adding a new dictionary or changing settings
38     of an existing one, based on dialog type passed to contructor.
39     When adding a new dictionary dialog contains a button to browse file system and
40     select a dictionary file. When changing settings dialog displays basic
41     information about dictionary i. e. name, languages and license info.
42     All contents of a dialog are in a scroll area.
43 */
44 class StarDialog : public QDialog
45 {
46     Q_OBJECT
47 public:
48     /*!
49         Describes type of dialog. New means that dialog contains widgets to browse
50         file system and select dictionary file. Change means that dialog displays
51         information about dictionary.
52         In both types dialog provides widgets to create or delete cache and remove
53         or keep accents.
54     */
55     enum StarDialogType {New, Change};
56
57     //! Constructor
58     /*!
59         Creates new StarDict dialog
60         \param plugin if created dialog is of type Change it must be set to
61             point to plugin whose settings will be changed
62         \param type describes type of created dialog
63         \param parent parent widget of created dialog
64     */
65     explicit StarDialog(StarDictPlugin* plugin = 0,
66                         StarDialogType type = New,
67                         QWidget* parent = 0);
68
69     /*!
70         After acceptance of dialog this method returns plugin's settings based on
71         user's choices in dialog.
72         \returns settings of plugin
73     */
74     Settings* getSettings();
75
76 Q_SIGNALS:
77     //! Requests to show notification
78     void notify(Notify::NotifyType, QString);
79
80 public Q_SLOTS:
81     /*!
82         Reimplemented accept method, to check if all necessary fields in
83         dialog are correct e. g. dictionary file path
84         and saves new settings
85     */
86     void accept();
87
88 private Q_SLOTS:
89     //! displays dialog to browse and select file
90     void selectFile();
91
92 private:
93     //! create a user interface
94     void initializeUI();
95
96     //! saves new settings after acceptance of dialog
97     void saveSettings();
98
99     //! check that files is compressed
100     bool checkFiles();
101
102     QLabel* infoLabel;
103     QPushButton* browseButton;
104     QHBoxLayout* browseLayout;
105
106     QPushButton* confirmButton;
107     QString _dictionaryFilePath;
108     QScrollArea* scrollArea;
109     QWidget* widget;
110     QHBoxLayout* layout;
111     QVBoxLayout* mainVerticalLayout;
112     bool _isCompressed;
113     QString _dictName;
114
115     Settings* _settings;
116
117     StarDictPlugin* plugin;
118     StarDialogType type;
119 };
120
121 #endif // STARDIALOG_H