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