Commit e19e8f17 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

implement userfeedback (not activate by default)

parent 48e189ac
......@@ -21,10 +21,15 @@ set(sieveeditor_importimapsettings_check_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/importwizard/checks/importimapsettingsakonadipassword.cpp
)
if (TARGET KUserFeedbackWidgets)
add_definitions(-DWITH_KUSERFEEDBACK)
endif()
set(sieveeditor_userfeedback_SRCS)
if (TARGET KUserFeedbackWidgets)
set(sieveeditor_userfeedback_SRCS ${sieveeditor_userfeedback_SRCS}
#TODO
userfeedback/userfeedbackmanager.cpp
)
endif()
......@@ -68,6 +73,12 @@ add_library(libsieveeditor ${sieveeditor_LIB_SRCS})
generate_export_header(libsieveeditor BASE_NAME libsieveeditor)
set(libsieveeditor_userfeedback_LIB)
if (TARGET KUserFeedbackWidgets)
set(libsieveeditor_userfeedback_LIB KUserFeedbackWidgets)
endif()
target_link_libraries(libsieveeditor
PRIVATE
KF5::MailTransport
......@@ -78,6 +89,7 @@ target_link_libraries(libsieveeditor
KF5::PimCommon
KF5::KSieveUi
KF5::KManageSieve
${libsieveeditor_userfeedback_LIB}
)
set_target_properties(libsieveeditor
......
......@@ -23,6 +23,13 @@
#include "PimCommon/ConfigureImmutableWidgetUtils"
#include "sieveeditorglobalconfig.h"
#ifdef WITH_KUSERFEEDBACK
#include "userfeedback/userfeedbackmanager.h"
#include <KUserFeedback/Provider>
#include <KUserFeedback/FeedbackConfigWidget>
#endif
#include <KLocalizedString>
#include <KSharedConfig>
......@@ -70,6 +77,22 @@ SieveEditorConfigureDialog::SieveEditorConfigureDialog(QWidget *parent)
editorPageWidgetPage->setIcon(QIcon::fromTheme(QStringLiteral("accessories-text-editor")));
addPage(editorPageWidgetPage);
//UserFeedBack config
#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"));
addPage(userFeedBackPageWidgetPage);
#endif
loadServerSieveConfig();
readConfig();
}
......@@ -92,6 +115,11 @@ void SieveEditorConfigureDialog::saveServerSieveConfig()
PimCommon::ConfigureImmutableWidgetUtils::saveCheckBox(mCloseWallet, SieveEditorGlobalConfig::self()->closeWalletItem());
PimCommon::ConfigureImmutableWidgetUtils::saveCheckBox(mWrapText, SieveEditorGlobalConfig::self()->wrapTextItem());
SieveEditorGlobalConfig::self()->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 SieveEditorConfigureDialog::readConfig()
......
......@@ -23,6 +23,12 @@
#include <KPageDialog>
class QCheckBox;
class SieveEditorConfigureServerWidget;
#ifdef WITH_KUSERFEEDBACK
namespace KUserFeedback {
class FeedbackConfigWidget;
}
#endif
class SieveEditorConfigureDialog : public KPageDialog
{
Q_OBJECT
......@@ -39,6 +45,9 @@ private:
SieveEditorConfigureServerWidget *mServerWidget = nullptr;
QCheckBox *mCloseWallet = nullptr;
QCheckBox *mWrapText = nullptr;
#ifdef WITH_KUSERFEEDBACK
KUserFeedback::FeedbackConfigWidget *mUserFeedbackWidget = nullptr;
#endif
};
#endif // SIEVEEDITORCONFIGUREDIALOG_H
......@@ -47,11 +47,18 @@
#include <QLabel>
#include <QCloseEvent>
#include <QNetworkConfigurationManager>
#ifdef WITH_KUSERFEEDBACK
#include "userfeedback/userfeedbackmanager.h"
#endif
SieveEditorMainWindow::SieveEditorMainWindow(QWidget *parent)
: KXmlGuiWindow(parent)
{
mMainWidget = new SieveEditorCentralWidget(this, actionCollection());
#ifdef WITH_KUSERFEEDBACK
//Initialize
(void)UserFeedBackManager::self();
#endif
connect(mMainWidget, &SieveEditorCentralWidget::configureClicked, this, &SieveEditorMainWindow::slotConfigure);
connect(mMainWidget, &SieveEditorCentralWidget::importSieveSettings, this, &SieveEditorMainWindow::slotImportImapSettings);
connect(mMainWidget->sieveEditorMainWidget(), &SieveEditorMainWidget::updateButtons, this, &SieveEditorMainWindow::slotUpdateButtons);
......
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
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.
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.
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.
*/
#include "userfeedbackmanager.h"
#include <KUserFeedback/ApplicationVersionSource>
#include <KUserFeedback/PlatformInfoSource>
#include <KUserFeedback/ScreenInfoSource>
#include <KUserFeedback/QtVersionSource>
#include <KUserFeedback/Provider>
#include <KUserFeedback/StartCountSource>
#include <KUserFeedback/UsageTimeSource>
#include <KUserFeedback/LocaleInfoSource>
UserFeedBackManager::UserFeedBackManager(QObject *parent)
: QObject(parent)
{
mUserFeedbackProvider = new KUserFeedback::Provider(this);
mUserFeedbackProvider->setProductIdentifier(QStringLiteral("org.kde.pim-sieve-editor"));
mUserFeedbackProvider->setFeedbackServer(QUrl(QStringLiteral("https://telemetry.kde.org/")));
mUserFeedbackProvider->setSubmissionInterval(7);
mUserFeedbackProvider->setApplicationStartsUntilEncouragement(5);
mUserFeedbackProvider->setEncouragementDelay(30);
mUserFeedbackProvider->addDataSource(new KUserFeedback::ApplicationVersionSource);
mUserFeedbackProvider->addDataSource(new KUserFeedback::PlatformInfoSource);
mUserFeedbackProvider->addDataSource(new KUserFeedback::ScreenInfoSource);
mUserFeedbackProvider->addDataSource(new KUserFeedback::QtVersionSource);
mUserFeedbackProvider->addDataSource(new KUserFeedback::StartCountSource);
mUserFeedbackProvider->addDataSource(new KUserFeedback::UsageTimeSource);
mUserFeedbackProvider->addDataSource(new KUserFeedback::LocaleInfoSource);
}
UserFeedBackManager *UserFeedBackManager::self()
{
static UserFeedBackManager s_self;
return &s_self;
}
KUserFeedback::Provider *UserFeedBackManager::userFeedbackProvider() const
{
return mUserFeedbackProvider;
}
/*
Copyright (C) 2020 Laurent Montel <montel@kde.org>
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.
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.
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.
*/
#ifndef USERFEEDBACKMANAGER_H
#define USERFEEDBACKMANAGER_H
#include <QObject>
namespace KUserFeedback {
class Provider;
}
class UserFeedBackManager : public QObject
{
Q_OBJECT
public:
explicit UserFeedBackManager(QObject *parent = nullptr);
static UserFeedBackManager *self();
KUserFeedback::Provider *userFeedbackProvider() const;
private:
KUserFeedback::Provider *mUserFeedbackProvider = nullptr;
};
#endif // USERFEEDBACKMANAGER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment