Clean and order documentation in source files. Source ready to beta 2 release
[mdictionary] / src / plugins / google / GoogleDialog.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 GoogleDialog.h
23     \brief Implementation of google plugin's dialogs.
24
25     \author Mateusz Półrola <mateusz.polrola@gmail.com>
26     \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
27 */
28
29 #ifndef GOOGLEDIALOG_H
30 #define GOOGLEDIALOG_H
31
32 #include <QDialog>
33 #include "../../include/settings.h"
34 #include <QtGui>
35 #include "GooglePlugin.h"
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 constructor.
40      These types differ only in confirm button label.
41      Both provide comboboxes with available languages to choose.
42 */
43 class GoogleDialog : public QDialog
44 {
45     Q_OBJECT
46 public:
47     /*!
48       Describes type of dialog. New means that dialog confirm button has
49         "Add" label, Change means that dialog confirm button has "Save settings" label.
50     */
51     enum GoogleDialogType {New, Change};
52
53     //! Constructor
54     /*!
55         Creates new google dialog
56         \param plugin if created dialog is of type Change it must be set to
57             point to plugin whose settings will be changed
58         \param type describes type of created dialog
59         \param parent parent widget of created dialog
60     */
61     explicit GoogleDialog(GooglePlugin* plugin = 0,
62                           GoogleDialogType type = New,
63                           QWidget* parent = 0);
64
65     //! \returns settings of plugin
66     /*!
67         After acceptance of dialog this method returns plugin's settings based on
68          user's choices in dialog.
69     */
70     Settings* getSettings();
71
72 Q_SIGNALS:
73     //! requests to show notification
74     void notify(Notify::NotifyType, QString);
75
76 public Q_SLOTS:
77     //! reimplemented accept method, to save new settings
78     void accept();
79
80 private Q_SLOTS:
81     //! assigns the language chosen from a list(langFromComboBox) to _langFrom
82     void langFromChanged(int);
83
84     //! assigns the language chosen from a list(langToComboBox) to _langTo
85     void langToChanged(int);
86
87     //! handles the "swap languages" button
88     void changeLangButtonClicked();
89
90 private:
91     void initializeUI();
92
93     //! saves new settings after acceptance of dialog
94     void saveSettings();
95
96     QLabel* infoLabel;
97     QLabel* langFromLabel;
98     QLabel* langToLabel;
99     QLabel* connectInfoLabel;
100     QPushButton* confirmButton;
101     QPushButton* changeLangButton;
102     QComboBox *langFromComboBox;
103     QComboBox *langToComboBox;
104     QVBoxLayout* verticalLayout;
105     QVBoxLayout* langLayout;
106     QFormLayout* langsFormLayout;
107     QHBoxLayout* changeLangLayout;
108     QString _langFrom;
109     QString _langTo;
110
111     Settings* _settings;
112     GooglePlugin* plugin;
113     GoogleDialogType type;
114 };
115
116 #endif // GOOGLEDIALOG_H