change comments in starDict
[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 /*!
23     \file XdxfDialog.cpp
24     \author Mateusz Półrola <mateusz.polrola@gmail.com>
25 */
26
27 #ifndef STARDIALOG_H
28 #define STARDIALOG_H
29
30 #include <QDialog>
31 #include "../../include/settings.h"
32 #include <QtGui>
33 #include "StarDictPlugin.h"
34
35
36 //! Implementation of stardict plugin's dialogs.
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     //! 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     void accept();
86
87 private Q_SLOTS:
88     //! displays dialog to browse and select file
89     void selectFile();
90
91 private:
92     void initializeUI();
93
94     //! saves new settings after acceptance of dialog
95     void saveSettings();
96     bool checkFiles();
97
98     QLabel* infoLabel;
99     QPushButton* browseButton;
100     QHBoxLayout* browseLayout;
101
102     QPushButton* confirmButton;
103     QString _dictionaryFilePath;
104     QScrollArea* scrollArea;
105     QWidget* widget;
106     QHBoxLayout* layout;
107     QVBoxLayout* mainVerticalLayout;
108     bool _isCompressed;
109     QString _dictName;
110
111     Settings* _settings;
112
113     StarDictPlugin* plugin;
114     StarDialogType type;
115 };
116
117 #endif // STARDIALOG_H