1 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
2 Copyright (C) 2012 Mohammed Nafees <nafees.technocool@gmail.com>
4 This file is part of the Trojita Qt IMAP e-mail client,
5 http://trojita.flaska.net/
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of
10 the License or (at your option) version 3 or any later version
11 accepted by the membership of KDE e.V. (or its successor approved
12 by the membership of KDE e.V.), which shall act as a proxy
13 defined in Section 14 of version 3 of the license.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef SETTINGSDIALOG_H
24 #define SETTINGSDIALOG_H
29 #include "Plugins/PasswordPlugin.h"
30 #include "ui_SettingsGeneralPage.h"
31 #include "ui_EditIdentity.h"
32 #include "ui_SettingsImapPage.h"
33 #include "ui_SettingsCachePage.h"
34 #include "ui_SettingsOutgoingPage.h"
38 class QDataWidgetMapper
;
46 class SenderIdentitiesModel
;
55 class PasswordWatcher
;
71 /** @short Common interface for any page of the settings dialogue */
72 class ConfigurationWidgetInterface
{
74 virtual void save(QSettings
&s
) = 0;
75 virtual QWidget
*asWidget() = 0;
76 virtual bool checkValidity() const = 0;
77 virtual bool passwordFailures(QString
&message
) const = 0;
81 class GeneralPage
: public QScrollArea
, Ui_GeneralPage
, public ConfigurationWidgetInterface
85 GeneralPage(SettingsDialog
*parent
, QSettings
&s
, Composer::SenderIdentitiesModel
*identitiesModel
);
86 virtual void save(QSettings
&s
);
87 virtual QWidget
*asWidget();
88 virtual bool checkValidity() const;
89 virtual bool passwordFailures(QString
&message
) const;
93 void moveIdentityUp();
94 void moveIdentityDown();
95 void addButtonClicked();
96 void editButtonClicked();
97 void deleteButtonClicked();
98 void passwordPluginChanged();
101 Composer::SenderIdentitiesModel
*m_identitiesModel
;
102 SettingsDialog
*m_parent
;
104 GeneralPage(const GeneralPage
&); // don't implement
105 GeneralPage
&operator=(const GeneralPage
&); // don't implement
109 void reloadPasswords();
110 void widgetsUpdated();
113 class EditIdentity
: public QDialog
, Ui_EditIdentity
117 EditIdentity(QWidget
*parent
, Composer::SenderIdentitiesModel
*identitiesModel
, const QModelIndex
¤tIndex
);
118 void setDeleteOnReject(const bool reject
= true);
125 Composer::SenderIdentitiesModel
*m_identitiesModel
;
126 QDataWidgetMapper
*m_mapper
;
127 bool m_deleteOnReject
;
129 EditIdentity(const EditIdentity
&); // don't implement
130 EditIdentity
&operator=(const EditIdentity
&); // don't implement
134 void widgetsUpdated();
138 class OutgoingPage
: public QScrollArea
, Ui_OutgoingPage
, public ConfigurationWidgetInterface
142 OutgoingPage(SettingsDialog
*parent
, QSettings
&s
);
143 virtual void save(QSettings
&s
);
144 virtual QWidget
*asWidget();
145 virtual bool checkValidity() const;
146 virtual bool passwordFailures(QString
&message
) const;
149 void slotSetSubmissionMethod();
150 void updateWidgets();
151 void slotSetPassword();
152 void showPortWarning(const QString
&warning
);
153 void setPortByText(const QString
&text
);
157 enum { NETWORK
, SENDMAIL
, IMAP_SENDMAIL
};
158 enum Encryption
{ SMTP
, SMTP_STARTTLS
, SSMTP
};
160 SettingsDialog
*m_parent
;
161 UiUtils::PasswordWatcher
*m_pwWatcher
;
163 MSA::Account
*m_smtpAccountSettings
;
165 OutgoingPage(const OutgoingPage
&); // don't implement
166 OutgoingPage
&operator=(const OutgoingPage
&); // don't implement
170 void widgetsUpdated();
173 class ImapPage
: public QScrollArea
, Ui_ImapPage
, public ConfigurationWidgetInterface
177 ImapPage(SettingsDialog
*parent
, QSettings
&s
);
178 virtual void save(QSettings
&s
);
179 virtual QWidget
*asWidget();
180 virtual bool checkValidity() const;
181 virtual bool passwordFailures(QString
&message
) const;
182 #ifdef XTUPLE_CONNECT
183 bool hasPassword() const;
187 enum { NETWORK
, PROCESS
};
188 enum Encryption
{ NONE
, STARTTLS
, SSL
};
189 SettingsDialog
*m_parent
;
192 UiUtils::PasswordWatcher
*m_pwWatcher
;
195 void updateWidgets();
196 void maybeShowPortWarning();
198 void slotSetPassword();
201 ImapPage(const ImapPage
&); // don't implement
202 ImapPage
&operator=(const ImapPage
&); // don't implement
206 void widgetsUpdated();
209 class CachePage
: public QScrollArea
, Ui_CachePage
, public ConfigurationWidgetInterface
213 CachePage(QWidget
*parent
, QSettings
&s
);
214 virtual void save(QSettings
&s
);
215 virtual QWidget
*asWidget();
216 virtual bool checkValidity() const;
217 virtual bool passwordFailures(QString
&message
) const;
220 QCheckBox
*startOffline
;
223 void updateWidgets();
226 CachePage(const CachePage
&); // don't implement
227 CachePage
&operator=(const CachePage
&); // don't implement
231 void widgetsUpdated();
234 #ifdef XTUPLE_CONNECT
235 class SettingsDialog
;
236 class XtConnectPage
: public QWidget
240 XtConnectPage(QWidget
*parent
, QSettings
&s
, ImapPage
*imapPage
);
241 void save(QSettings
&s
);
242 virtual void showEvent(QShowEvent
*event
);
248 QPointer
<ImapPage
> imap
;
254 QLabel
*imapPasswordWarning
;
257 XtConnectPage(const XtConnectPage
&); // don't implement
258 XtConnectPage
&operator=(const XtConnectPage
&); // don't implement
261 void widgetsUpdated();
266 class SettingsDialog
: public QDialog
270 SettingsDialog(MainWindow
*parent
, Composer::SenderIdentitiesModel
*identitiesModel
, QSettings
*settings
);
272 Plugins::PluginManager
*pluginManager();
273 Imap::ImapAccess
* imapAccess();
275 void setOriginalPasswordPlugin(const QString
&plugin
);
277 static QString warningStyleSheet
;
280 void reloadPasswordsRequested();
286 void adjustSizeToScrollAreas();
289 MainWindow
*mainWindow
;
290 QDialogButtonBox
*buttons
;
292 QVector
<ConfigurationWidgetInterface
*> pages
;
293 #ifdef XTUPLE_CONNECT
294 XtConnectPage
*xtConnect
;
296 Composer::SenderIdentitiesModel
*m_senderIdentities
;
297 QSettings
*m_settings
;
298 int m_saveSignalCount
;
299 QString m_originalPasswordPlugin
;
301 SettingsDialog(const SettingsDialog
&); // don't implement
302 SettingsDialog
&operator=(const SettingsDialog
&); // don't implement
304 void addPage(ConfigurationWidgetInterface
*page
, const QString
&title
);
309 #endif // SETTINGSDIALOG_H