2 Copyright (c) 2013-2016 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 "serversievesettingsdialog.h"
22 #include "serversievesettings.h"
24 #include <KLocalizedString>
25 #include <QVBoxLayout>
26 #include <QDialogButtonBox>
27 #include <QPushButton>
29 ServerSieveSettingsDialog::ServerSieveSettingsDialog(QWidget
*parent
)
32 setWindowTitle(i18nc("@title:window", "Add Sieve Server"));
34 QWidget
*w
= new QWidget
;
35 QVBoxLayout
*lay
= new QVBoxLayout
;
36 mServerSieveSettings
= new ServerSieveSettings
;
37 connect(mServerSieveSettings
, &ServerSieveSettings::enableOkButton
, this, &ServerSieveSettingsDialog::slotEnableButtonOk
);
38 lay
->addWidget(mServerSieveSettings
);
41 QVBoxLayout
*mainLayout
= new QVBoxLayout
;
42 setLayout(mainLayout
);
43 mainLayout
->addWidget(w
);
45 QDialogButtonBox
*buttonBox
= new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
);
46 mOkButton
= buttonBox
->button(QDialogButtonBox::Ok
);
47 mOkButton
->setDefault(true);
48 mOkButton
->setShortcut(Qt::CTRL
| Qt::Key_Return
);
49 connect(buttonBox
, &QDialogButtonBox::accepted
, this, &ServerSieveSettingsDialog::accept
);
50 connect(buttonBox
, &QDialogButtonBox::rejected
, this, &ServerSieveSettingsDialog::reject
);
51 mainLayout
->addWidget(buttonBox
);
54 mOkButton
->setEnabled(false);
57 ServerSieveSettingsDialog::~ServerSieveSettingsDialog()
62 void ServerSieveSettingsDialog::readConfig()
64 KConfigGroup
group(KSharedConfig::openConfig(), "ServerSieveSettingsDialog");
65 const QSize size
= group
.readEntry("Size", QSize(450, 350));
71 void ServerSieveSettingsDialog::writeConfig()
73 KConfigGroup
group(KSharedConfig::openConfig(), "ServerSieveSettingsDialog");
74 group
.writeEntry("Size", size());
78 void ServerSieveSettingsDialog::slotEnableButtonOk(bool b
)
80 mOkButton
->setEnabled(b
);
83 QString
ServerSieveSettingsDialog::serverName() const
85 return mServerSieveSettings
->serverName();
88 void ServerSieveSettingsDialog::setServerName(const QString
&name
)
90 mServerSieveSettings
->setServerName(name
);
93 int ServerSieveSettingsDialog::port() const
95 return mServerSieveSettings
->port();
98 void ServerSieveSettingsDialog::setPort(int value
)
100 mServerSieveSettings
->setPort(value
);
103 QString
ServerSieveSettingsDialog::userName() const
105 return mServerSieveSettings
->userName();
108 void ServerSieveSettingsDialog::setUserName(const QString
&name
)
110 mServerSieveSettings
->setUserName(name
);
113 QString
ServerSieveSettingsDialog::password() const
115 return mServerSieveSettings
->password();
118 void ServerSieveSettingsDialog::setPassword(const QString
&pass
)
120 mServerSieveSettings
->setPassword(pass
);
123 void ServerSieveSettingsDialog::setServerSieveConfig(const SieveEditorUtil::SieveServerConfig
&conf
)
125 mServerSieveSettings
->setServerSieveConfig(conf
);
128 SieveEditorUtil::SieveServerConfig
ServerSieveSettingsDialog::serverSieveConfig() const
130 return mServerSieveSettings
->serverSieveConfig();