diff --git a/src/widgets/configuredialog/configuresettingsdialog.cpp b/src/widgets/configuredialog/configuresettingsdialog.cpp index 9df980af..eab436e5 100644 --- a/src/widgets/configuredialog/configuresettingsdialog.cpp +++ b/src/widgets/configuredialog/configuresettingsdialog.cpp @@ -1,104 +1,106 @@ /* Copyright (c) 2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configuresettingsdialog.h" #include "configureaccountwidget.h" #include "configurespellcheckingwidget.h" #include #include #include #include #include #include #include #ifdef WITH_KUSERFEEDBACK #include "configureuserfeedbackwidget.h" #endif namespace { static const char myConfigGroupName[] = "ConfigureSettingsDialog"; } ConfigureSettingsDialog::ConfigureSettingsDialog(QWidget *parent) : KPageDialog(parent) { setWindowTitle(i18nc("@title:window", "Configure Ruqola")); setFaceType(KPageDialog::List); buttonBox()->setStandardButtons(QDialogButtonBox::Ok| QDialogButtonBox::Cancel); const QString accountPageName = i18nc("@title Preferences page name", "Account"); mConfigureAccountWidget = new ConfigureAccountWidget(this); mConfigureAccountWidgetPage = new KPageWidgetItem(mConfigureAccountWidget, accountPageName); mConfigureAccountWidgetPage->setIcon(QIcon::fromTheme(QStringLiteral("network-workgroup"))); addPage(mConfigureAccountWidgetPage); const QString spellCheckingPageName = i18nc("@title Preferences page name", "Spell Checking"); mConfigureSpellCheckingWidget = new ConfigureSpellCheckingWidget(this); mConfigureSpellCheckingWidgetPage = new KPageWidgetItem(mConfigureSpellCheckingWidget, spellCheckingPageName); mConfigureSpellCheckingWidgetPage->setIcon(QIcon::fromTheme(QStringLiteral("tools-check-spelling"))); addPage(mConfigureSpellCheckingWidgetPage); #ifdef WITH_KUSERFEEDBACK const QString userFeedBackPageName = i18nc("@title Preferences page name", "User Feedback"); mConfigureUserFeedBackWidget = new ConfigureUserFeedbackWidget(this); mConfigureUserFeedBackWidgetPage = new KPageWidgetItem(mConfigureUserFeedBackWidget, userFeedBackPageName); mConfigureUserFeedBackWidgetPage->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-locale"))); addPage(mConfigureUserFeedBackWidgetPage); #endif connect(buttonBox()->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &ConfigureSettingsDialog::slotAccepted); connect(buttonBox()->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &ConfigureSettingsDialog::reject); readConfig(); load(); } ConfigureSettingsDialog::~ConfigureSettingsDialog() { writeConfig(); } void ConfigureSettingsDialog::readConfig() { KConfigGroup group(KSharedConfig::openConfig(), myConfigGroupName); const QSize sizeDialog = group.readEntry("Size", QSize(800, 600)); if (sizeDialog.isValid()) { resize(sizeDialog); } } void ConfigureSettingsDialog::writeConfig() { KConfigGroup group(KSharedConfig::openConfig(), myConfigGroupName); group.writeEntry("Size", size()); } void ConfigureSettingsDialog::slotAccepted() { mConfigureAccountWidget->save(); mConfigureSpellCheckingWidget->save(); + mConfigureUserFeedBackWidget->save(); } void ConfigureSettingsDialog::load() { mConfigureAccountWidget->load(); mConfigureSpellCheckingWidget->load(); + mConfigureUserFeedBackWidget->load(); } diff --git a/src/widgets/configuredialog/configureuserfeedbackwidget.cpp b/src/widgets/configuredialog/configureuserfeedbackwidget.cpp index 213fe323..42be5d04 100644 --- a/src/widgets/configuredialog/configureuserfeedbackwidget.cpp +++ b/src/widgets/configuredialog/configureuserfeedbackwidget.cpp @@ -1,49 +1,63 @@ /* Copyright (c) 2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "configureuserfeedbackwidget.h" #include #ifdef WITH_KUSERFEEDBACK #include #include #include "userfeedback/userfeedbackmanager.h" #endif ConfigureUserFeedbackWidget::ConfigureUserFeedbackWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *userFeedBackLayout = new QVBoxLayout(this); userFeedBackLayout->setObjectName(QStringLiteral("userFeedBackLayout")); userFeedBackLayout->setContentsMargins(0, 0, 0, 0); #ifdef WITH_KUSERFEEDBACK mUserFeedbackWidget = new KUserFeedback::FeedbackConfigWidget(this); mUserFeedbackWidget->setObjectName(QStringLiteral("mUserFeedbackWidget")); userFeedBackLayout->addWidget(mUserFeedbackWidget); - - mUserFeedbackWidget->setFeedbackProvider(UserFeedBackManager::self()->userFeedbackProvider()); #endif } ConfigureUserFeedbackWidget::~ConfigureUserFeedbackWidget() { } + +void ConfigureUserFeedbackWidget::save() +{ +#ifdef WITH_KUSERFEEDBACK + // set current active mode + write back the config for future starts + UserFeedBackManager::self()->userFeedbackProvider()->setTelemetryMode(mUserFeedbackWidget->telemetryMode()); + UserFeedBackManager::self()->userFeedbackProvider()->setSurveyInterval(mUserFeedbackWidget->surveyInterval()); +#endif +} + +void ConfigureUserFeedbackWidget::load() +{ +#ifdef WITH_KUSERFEEDBACK + mUserFeedbackWidget->setFeedbackProvider(UserFeedBackManager::self()->userFeedbackProvider()); +#endif +} diff --git a/src/widgets/configuredialog/configureuserfeedbackwidget.h b/src/widgets/configuredialog/configureuserfeedbackwidget.h index efe270df..6d932951 100644 --- a/src/widgets/configuredialog/configureuserfeedbackwidget.h +++ b/src/widgets/configuredialog/configureuserfeedbackwidget.h @@ -1,45 +1,48 @@ /* Copyright (c) 2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CONFIGUREUSERFEEDBACKWIDGET_H #define CONFIGUREUSERFEEDBACKWIDGET_H #include #include "libruqolawidgets_private_export.h" #ifdef WITH_KUSERFEEDBACK namespace KUserFeedback { class FeedbackConfigWidget; } #endif class LIBRUQOLAWIDGETS_TESTS_EXPORT ConfigureUserFeedbackWidget : public QWidget { Q_OBJECT public: explicit ConfigureUserFeedbackWidget(QWidget *parent = nullptr); ~ConfigureUserFeedbackWidget(); + void save(); + void load(); + private: #ifdef WITH_KUSERFEEDBACK KUserFeedback::FeedbackConfigWidget *mUserFeedbackWidget = nullptr; #endif }; #endif // CONFIGUREUSERFEEDBACKWIDGET_H