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