Fix Bug 362152 - Font selection is not honored
[kdepim.git] / sieveeditor / sieveeditorconfigureserverwidget.cpp
blobb02d765d67c459a2f0d7d39f37815bb07576432f
1 /*
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
17 02110-1301, USA.
21 #include "sieveeditorconfigureserverwidget.h"
22 #include "ui_sieveeditorconfigureserverwidget.h"
23 #include "serversievesettingsdialog.h"
25 #include <KLocalizedString>
26 #include <KMessageBox>
28 SieveEditorConfigureServerWidget::SieveEditorConfigureServerWidget(QWidget *parent) :
29 QWidget(parent),
30 ui(new Ui::SieveEditorConfigureServerWidget)
32 ui->setupUi(this);
33 connect(ui->modifyServer, &QPushButton::clicked, this, &SieveEditorConfigureServerWidget::slotModifyServer);
34 connect(ui->addServer, &QPushButton::clicked, this, &SieveEditorConfigureServerWidget::slotAddServer);
35 connect(ui->removeServer, &QPushButton::clicked, this, &SieveEditorConfigureServerWidget::slotDeleteServer);
36 connect(ui->serverSieveListWidget, &ServerSieveListWidget::itemSelectionChanged, this, &SieveEditorConfigureServerWidget::slotItemSelectionChanged);
37 slotItemSelectionChanged();
40 SieveEditorConfigureServerWidget::~SieveEditorConfigureServerWidget()
42 delete ui;
45 void SieveEditorConfigureServerWidget::readConfig()
47 ui->serverSieveListWidget->readConfig();
50 void SieveEditorConfigureServerWidget::writeConfig()
52 ui->serverSieveListWidget->writeConfig();
55 void SieveEditorConfigureServerWidget::slotModifyServer()
57 ui->serverSieveListWidget->modifyServerConfig();
60 void SieveEditorConfigureServerWidget::slotAddServer()
62 ui->serverSieveListWidget->addServerConfig();
65 void SieveEditorConfigureServerWidget::slotDeleteServer()
67 QListWidgetItem *item = ui->serverSieveListWidget->currentItem();
68 if (!item) {
69 return;
71 if (KMessageBox::Yes == KMessageBox::questionYesNo(this, i18n("Do you want to remove this server \'%1\'?", item->text()), i18n("Remove Server Sieve"))) {
72 delete item;
73 slotItemSelectionChanged();
77 void SieveEditorConfigureServerWidget::slotItemSelectionChanged()
79 const bool hasItemSelected = ui->serverSieveListWidget->currentItem();
80 ui->modifyServer->setEnabled(hasItemSelected);
81 ui->removeServer->setEnabled(hasItemSelected);