2 Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "sieveeditorconfiguredialog.h"
22 #include "serversievelistwidget.h"
23 #include "sieveeditorconfigureserverwidget.h"
24 #include "PimCommon/ConfigureImmutableWidgetUtils"
25 #include "sieveeditorglobalconfig.h"
27 #include <KLocalizedString>
28 #include <KSharedConfig>
30 #include <QVBoxLayout>
32 #include <KConfigGroup>
33 #include <QDialogButtonBox>
34 #include <QPushButton>
37 SieveEditorConfigureDialog::SieveEditorConfigureDialog(QWidget
*parent
)
40 setWindowTitle(i18n("Configure"));
41 QDialogButtonBox
*buttonBox
= new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
);
42 QVBoxLayout
*mainLayout
= new QVBoxLayout
;
43 setLayout(mainLayout
);
44 QPushButton
*okButton
= buttonBox
->button(QDialogButtonBox::Ok
);
45 okButton
->setDefault(true);
46 okButton
->setShortcut(Qt::CTRL
| Qt::Key_Return
);
47 connect(buttonBox
, &QDialogButtonBox::accepted
, this, &SieveEditorConfigureDialog::accept
);
48 connect(buttonBox
, &QDialogButtonBox::rejected
, this, &SieveEditorConfigureDialog::reject
);
49 QGroupBox
*w
= new QGroupBox(i18n("Sieve Server"));
51 QVBoxLayout
*layout
= new QVBoxLayout
;
53 mServerWidget
= new SieveEditorConfigureServerWidget
;
54 layout
->addWidget(mServerWidget
);
56 mCloseWallet
= new QCheckBox(i18n("Close wallet when close application"));
57 layout
->addWidget(mCloseWallet
);
59 mainLayout
->addWidget(w
);
60 mainLayout
->addWidget(buttonBox
);
61 loadServerSieveConfig();
65 SieveEditorConfigureDialog::~SieveEditorConfigureDialog()
70 void SieveEditorConfigureDialog::loadServerSieveConfig()
72 mServerWidget
->readConfig();
73 PimCommon::ConfigureImmutableWidgetUtils::loadWidget(mCloseWallet
, SieveEditorGlobalConfig::self()->closeWalletItem());
76 void SieveEditorConfigureDialog::saveServerSieveConfig()
78 mServerWidget
->writeConfig();
79 PimCommon::ConfigureImmutableWidgetUtils::saveCheckBox(mCloseWallet
, SieveEditorGlobalConfig::self()->closeWalletItem());
80 SieveEditorGlobalConfig::self()->save();
83 void SieveEditorConfigureDialog::readConfig()
85 KConfigGroup
group(KSharedConfig::openConfig(), "SieveEditorConfigureDialog");
86 const QSize size
= group
.readEntry("Size", QSize(600, 400));
92 void SieveEditorConfigureDialog::writeConfig()
94 KConfigGroup
group(KSharedConfig::openConfig(), "SieveEditorConfigureDialog");
95 group
.writeEntry("Size", size());