Astyle kdelibs
[kdepim.git] / kmail / configuredialog / configuremiscpage.cpp
bloba244f014f9b895b236a60a62c58776e18d99d366
1 /*
2 Copyright (c) 2013, 2014 Montel Laurent <montel@kde.org>
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #include "configuremiscpage.h"
19 #include "pimcommon/widgets/configureimmutablewidgetutils.h"
20 using namespace PimCommon::ConfigureImmutableWidgetUtils;
21 #include "configureagentswidget.h"
22 #include "settings/globalsettings.h"
24 #include <mailcommon/folder/folderrequester.h>
25 #include "messageviewer/widgets/invitationsettings.h"
26 #include "messageviewer/widgets/printingsettings.h"
27 #include "messageviewer/settings/globalsettings.h"
29 #include <KCModuleProxy>
30 #include <KCModuleInfo>
31 #include <KLocalizedString>
32 #include <QDialog>
33 #include <KConfigGroup>
35 using namespace MailCommon;
36 QString MiscPage::helpAnchor() const
38 return QString::fromLatin1("configure-misc");
41 MiscPage::MiscPage(QWidget *parent)
42 : ConfigModuleWithTabs(parent)
44 mFolderTab = new FolderTab();
45 addTab(mFolderTab, i18n("Folders"));
47 mInviteTab = new InviteTab();
48 addTab(mInviteTab, i18n("Invitations"));
50 mProxyTab = new ProxyTab();
51 addTab(mProxyTab, i18n("Proxy"));
53 mAgentSettingsTab = new MiscPageAgentSettingsTab();
54 addTab(mAgentSettingsTab, i18n("Plugins Settings"));
56 mPrintingTab = new MiscPagePrintingTab();
57 addTab(mPrintingTab, i18n("Printing"));
60 QString MiscPageFolderTab::helpAnchor() const
62 return QString::fromLatin1("configure-misc-folders");
65 MiscPageFolderTab::MiscPageFolderTab(QWidget *parent)
66 : ConfigModuleTab(parent)
68 mMMTab.setupUi(this);
69 //replace QWidget with FolderRequester. Promote to doesn't work due to the custom constructor
70 QHBoxLayout *layout = new QHBoxLayout;
71 layout->setContentsMargins(0, 0, 0, 0);
72 mMMTab.mOnStartupOpenFolder->setLayout(layout);
73 mOnStartupOpenFolder = new FolderRequester(mMMTab.mOnStartupOpenFolder);
74 layout->addWidget(mOnStartupOpenFolder);
76 //TODO PORT QT5 mMMTab.gridLayout->setSpacing( QDialog::spacingHint() );
77 //TODO PORT QT5 mMMTab.gridLayout->setMargin( QDialog::marginHint() );
78 mMMTab.mExcludeImportantFromExpiry->setWhatsThis(
79 i18n(GlobalSettings::self()->excludeImportantMailFromExpiryItem()->whatsThis().toUtf8()));
81 connect(mMMTab.mEmptyFolderConfirmCheck, &QCheckBox::stateChanged, this, &MiscPageFolderTab::slotEmitChanged);
82 connect(mMMTab.mExcludeImportantFromExpiry, &QCheckBox::stateChanged, this, &MiscPageFolderTab::slotEmitChanged);
83 connect(mMMTab.mLoopOnGotoUnread, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &MiscPageFolderTab::slotEmitChanged);
84 connect(mMMTab.mActionEnterFolder, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &MiscPageFolderTab::slotEmitChanged);
85 connect(mMMTab.mDelayedMarkTime, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MiscPageFolderTab::slotEmitChanged);
86 connect(mMMTab.mDelayedMarkAsRead, SIGNAL(toggled(bool)), mMMTab.mDelayedMarkTime, SLOT(setEnabled(bool)));
87 connect(mMMTab.mDelayedMarkAsRead, SIGNAL(toggled(bool)), this , SLOT(slotEmitChanged()));
88 connect(mMMTab.mShowPopupAfterDnD, &QCheckBox::stateChanged, this, &MiscPageFolderTab::slotEmitChanged);
89 connect(mOnStartupOpenFolder, &MailCommon::FolderRequester::folderChanged, this, &MiscPageFolderTab::slotEmitChanged);
90 connect(mMMTab.mEmptyTrashCheck, &QCheckBox::stateChanged, this, &MiscPageFolderTab::slotEmitChanged);
91 connect(mMMTab.mStartUpFolderCheck, &QCheckBox::toggled, this, &MiscPageFolderTab::slotEmitChanged);
92 connect(mMMTab.mStartUpFolderCheck, &QCheckBox::toggled, mOnStartupOpenFolder, &MailCommon::FolderRequester::setEnabled);
95 void MiscPage::FolderTab::doLoadFromGlobalSettings()
97 loadWidget(mMMTab.mExcludeImportantFromExpiry, GlobalSettings::self()->excludeImportantMailFromExpiryItem());
98 // default = "Loop in current folder"
99 loadWidget(mMMTab.mLoopOnGotoUnread, GlobalSettings::self()->loopOnGotoUnreadItem());
100 loadWidget(mMMTab.mActionEnterFolder, GlobalSettings::self()->actionEnterFolderItem());
101 loadWidget(mMMTab.mDelayedMarkAsRead, MessageViewer::GlobalSettings::self()->delayedMarkAsReadItem());
102 loadWidget(mMMTab.mDelayedMarkTime, MessageViewer::GlobalSettings::self()->delayedMarkTimeItem());
103 loadWidget(mMMTab.mShowPopupAfterDnD, GlobalSettings::self()->showPopupAfterDnDItem());
104 loadWidget(mMMTab.mStartUpFolderCheck, GlobalSettings::self()->startSpecificFolderAtStartupItem());
105 mOnStartupOpenFolder->setEnabled(GlobalSettings::self()->startSpecificFolderAtStartup());
106 doLoadOther();
109 void MiscPage::FolderTab::doLoadOther()
111 loadWidget(mMMTab.mEmptyTrashCheck, GlobalSettings::self()->emptyTrashOnExitItem());
112 mOnStartupOpenFolder->setCollection(Akonadi::Collection(GlobalSettings::self()->startupFolder()));
113 loadWidget(mMMTab.mEmptyFolderConfirmCheck, GlobalSettings::self()->confirmBeforeEmptyItem());
116 void MiscPage::FolderTab::save()
118 saveCheckBox(mMMTab.mEmptyTrashCheck, GlobalSettings::self()->emptyTrashOnExitItem());
119 saveCheckBox(mMMTab.mEmptyFolderConfirmCheck, GlobalSettings::self()->confirmBeforeEmptyItem());
120 saveComboBox(mMMTab.mActionEnterFolder, GlobalSettings::self()->actionEnterFolderItem());
121 GlobalSettings::self()->setStartupFolder(mOnStartupOpenFolder->collection().id());
123 saveCheckBox(mMMTab.mDelayedMarkAsRead, MessageViewer::GlobalSettings::self()->delayedMarkAsReadItem());
124 saveSpinBox(mMMTab.mDelayedMarkTime, MessageViewer::GlobalSettings::self()->delayedMarkTimeItem());
125 saveComboBox(mMMTab.mLoopOnGotoUnread, GlobalSettings::self()->loopOnGotoUnreadItem());
127 saveCheckBox(mMMTab.mExcludeImportantFromExpiry, GlobalSettings::self()->excludeImportantMailFromExpiryItem());
128 saveCheckBox(mMMTab.mShowPopupAfterDnD, GlobalSettings::self()->showPopupAfterDnDItem());
129 saveCheckBox(mMMTab.mStartUpFolderCheck, GlobalSettings::self()->startSpecificFolderAtStartupItem());
132 MiscPageAgentSettingsTab::MiscPageAgentSettingsTab(QWidget *parent)
133 : ConfigModuleTab(parent)
135 QHBoxLayout *l = new QHBoxLayout(this);
136 l->setContentsMargins(0 , 0, 0, 0);
137 mConfigureAgent = new ConfigureAgentsWidget;
138 l->addWidget(mConfigureAgent);
140 connect(mConfigureAgent, &ConfigureAgentsWidget::changed, this, &MiscPageAgentSettingsTab::slotEmitChanged);
143 void MiscPageAgentSettingsTab::doLoadFromGlobalSettings()
145 mConfigureAgent->doLoadFromGlobalSettings();
148 void MiscPageAgentSettingsTab::save()
150 mConfigureAgent->save();
153 void MiscPageAgentSettingsTab::doResetToDefaultsOther()
155 mConfigureAgent->doResetToDefaultsOther();
158 QString MiscPageAgentSettingsTab::helpAnchor() const
160 return mConfigureAgent->helpAnchor();
163 MiscPageInviteTab::MiscPageInviteTab(QWidget *parent)
164 : ConfigModuleTab(parent)
166 mInvitationUi = new MessageViewer::InvitationSettings(this);
167 QHBoxLayout *l = new QHBoxLayout(this);
168 l->setContentsMargins(0 , 0, 0, 0);
169 l->addWidget(mInvitationUi);
170 connect(mInvitationUi, &MessageViewer::InvitationSettings::changed, this, &MiscPageInviteTab::slotEmitChanged);
173 void MiscPage::InviteTab::doLoadFromGlobalSettings()
175 mInvitationUi->doLoadFromGlobalSettings();
178 void MiscPage::InviteTab::save()
180 mInvitationUi->save();
183 void MiscPage::InviteTab::doResetToDefaultsOther()
185 mInvitationUi->doResetToDefaultsOther();
188 MiscPageProxyTab::MiscPageProxyTab(QWidget *parent)
189 : ConfigModuleTab(parent)
191 KCModuleInfo proxyInfo(QLatin1String("proxy.desktop"));
192 mProxyModule = new KCModuleProxy(proxyInfo, parent);
193 QHBoxLayout *l = new QHBoxLayout(this);
194 l->addWidget(mProxyModule);
195 connect(mProxyModule, SIGNAL(changed(bool)), this, SLOT(slotEmitChanged()));
198 void MiscPage::ProxyTab::save()
200 mProxyModule->save();
203 MiscPagePrintingTab::MiscPagePrintingTab(QWidget *parent)
204 : ConfigModuleTab(parent)
206 mPrintingUi = new MessageViewer::PrintingSettings(this);
207 QHBoxLayout *l = new QHBoxLayout(this);
208 l->setContentsMargins(0 , 0, 0, 0);
209 l->addWidget(mPrintingUi);
210 connect(mPrintingUi, &MessageViewer::PrintingSettings::changed, this, &MiscPagePrintingTab::slotEmitChanged);
213 void MiscPagePrintingTab::doLoadFromGlobalSettings()
215 mPrintingUi->doLoadFromGlobalSettings();
218 void MiscPagePrintingTab::doResetToDefaultsOther()
220 mPrintingUi->doResetToDefaultsOther();
223 void MiscPagePrintingTab::save()
225 mPrintingUi->save();
228 //----------------------------