pimdataexporterconfiguredialog.cpp 3.67 KB
Newer Older
1
/*
Laurent Montel's avatar
Laurent Montel committed
2
   Copyright (C) 2015-2020 Laurent Montel <montel@kde.org>
3

Laurent Montel's avatar
Laurent Montel committed
4
5
6
7
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
8

Laurent Montel's avatar
Laurent Montel committed
9
10
11
12
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.
13

Laurent Montel's avatar
Laurent Montel committed
14
15
16
17
   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
18
19
*/

Laurent Montel's avatar
Laurent Montel committed
20
#include "pimdataexporterconfiguredialog.h"
Laurent Montel's avatar
Laurent Montel committed
21
22
#include <QVBoxLayout>
#include <KLocalizedString>
Laurent Montel's avatar
Laurent Montel committed
23
#include <QPushButton>
Laurent Montel's avatar
Laurent Montel committed
24
#include <QDialogButtonBox>
Laurent Montel's avatar
Laurent Montel committed
25
#include <kpagewidgetmodel.h>
Laurent Montel's avatar
Laurent Montel committed
26
#include "../widgets/pimdataexporterconfigurewidget.h"
Laurent Montel's avatar
Laurent Montel committed
27
28
#include <KConfigGroup>
#include <KSharedConfig>
29

Laurent Montel's avatar
Laurent Montel committed
30
31
32
33
34
35
#ifdef WITH_KUSERFEEDBACK
#include <KUserFeedback/Provider>
#include <KUserFeedback/FeedbackConfigWidget>
#include "userfeedback/userfeedbackmanager.h"
#endif

Laurent Montel's avatar
Laurent Montel committed
36
PimDataExporterConfigureDialog::PimDataExporterConfigureDialog(QWidget *parent)
Laurent Montel's avatar
Laurent Montel committed
37
    : KPageDialog(parent)
38
{
Laurent Montel's avatar
Laurent Montel committed
39
    setFaceType(KPageDialog::List);
40
    setWindowTitle(i18nc("@title:window", "Configure PimDataExporter"));
Laurent Montel's avatar
Laurent Montel committed
41
42
43
44
45


    //General page
    QWidget *generalConfigureWiget = new QWidget;
    QVBoxLayout *layout = new QVBoxLayout(generalConfigureWiget);
Laurent Montel's avatar
Laurent Montel committed
46
    mConfigureWidget = new PimDataExporterConfigureWidget(this);
Laurent Montel's avatar
Laurent Montel committed
47
    mConfigureWidget->setObjectName(QStringLiteral("configurewidget"));
Laurent Montel's avatar
Laurent Montel committed
48

Laurent Montel's avatar
Laurent Montel committed
49
50
    layout->addWidget(mConfigureWidget);

Laurent Montel's avatar
Laurent Montel committed
51
52
53
54
    KPageWidgetItem *generalPageWidgetPage = new KPageWidgetItem(mConfigureWidget, i18n("General"));
    generalPageWidgetPage->setIcon(QIcon::fromTheme(QStringLiteral("network-workgroup")));
    addPage(generalPageWidgetPage);

Laurent Montel's avatar
Laurent Montel committed
55
56
57
58
59
60
61
62
63
64
65
66
#ifdef WITH_KUSERFEEDBACK
    QWidget *userFeedBackWidget = new QWidget;
    userFeedBackWidget->setObjectName(QStringLiteral("userFeedBackWidget"));

    mUserFeedbackWidget = new KUserFeedback::FeedbackConfigWidget(this);

    QHBoxLayout *userFeedBackLayout = new QHBoxLayout(userFeedBackWidget);
    userFeedBackLayout->setContentsMargins(0, 0, 0, 0);
    userFeedBackLayout->addWidget(mUserFeedbackWidget);

    mUserFeedbackWidget->setFeedbackProvider(UserFeedBackManager::self()->userFeedbackProvider());
    KPageWidgetItem *userFeedBackPageWidgetPage = new KPageWidgetItem(userFeedBackWidget, i18n("User Feedback"));
67
    userFeedBackPageWidgetPage->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-locale")));
Laurent Montel's avatar
Laurent Montel committed
68
69
70
71
    addPage(userFeedBackPageWidgetPage);
#endif


Laurent Montel's avatar
Laurent Montel committed
72
73
74
75
76

    buttonBox()->setStandardButtons(QDialogButtonBox::Ok| QDialogButtonBox::Cancel);

    connect(buttonBox(), &QDialogButtonBox::accepted, this, &PimDataExporterConfigureDialog::accept);
    connect(buttonBox(), &QDialogButtonBox::rejected, this, &PimDataExporterConfigureDialog::reject);
Laurent Montel's avatar
Laurent Montel committed
77
    readConfig();
78
79
}

Laurent Montel's avatar
Laurent Montel committed
80
PimDataExporterConfigureDialog::~PimDataExporterConfigureDialog()
81
{
Laurent Montel's avatar
Laurent Montel committed
82
    writeConfig();
83
}
Laurent Montel's avatar
Laurent Montel committed
84

Laurent Montel's avatar
Laurent Montel committed
85
void PimDataExporterConfigureDialog::slotAccepted()
Laurent Montel's avatar
Laurent Montel committed
86
87
88
89
{
    mConfigureWidget->save();
    accept();
}
Laurent Montel's avatar
Laurent Montel committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105

void PimDataExporterConfigureDialog::readConfig()
{
    KConfigGroup group(KSharedConfig::openConfig(), "PimDataExporterConfigureDialog");
    const QSize size = group.readEntry("Size", QSize(600, 400));
    if (size.isValid()) {
        resize(size);
    }
}

void PimDataExporterConfigureDialog::writeConfig()
{
    KConfigGroup group(KSharedConfig::openConfig(), "PimDataExporterConfigureDialog");
    group.writeEntry("Size", size());
    group.sync();
}