diff --git a/kcms/feedback/feedback.cpp b/kcms/feedback/feedback.cpp index b0edb24b0..d7fa0e651 100644 --- a/kcms/feedback/feedback.cpp +++ b/kcms/feedback/feedback.cpp @@ -1,79 +1,74 @@ /* * Copyright (C) 2019 David Edmundson * Copyright (C) 2019 Aleix Pol Gonzalez * * 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) 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 "feedback.h" #include #include #include #include #include #include K_PLUGIN_CLASS_WITH_JSON(Feedback, "kcm_feedback.json"); Feedback::Feedback(QObject *parent, const QVariantList &args) : KQuickAddons::ConfigModule(parent) //UserFeedback.conf is used by KUserFeedback which uses QSettings and won't go through globals - , m_globalConfig(KSharedConfig::openConfig(QStringLiteral("KDE/UserFeedback.conf"), KConfig::NoGlobals)) , m_plasmaConfig(KSharedConfig::openConfig(QStringLiteral("PlasmaUserFeedback"))) { Q_UNUSED(args) setAboutData(new KAboutData(QStringLiteral("kcm_feedback"), i18n("User Feedback"), QStringLiteral("1.0"), i18n("Configure user feedback settings"), KAboutLicense::LGPL)); - connect(this, &Feedback::feedbackEnabledChanged, this, [this](){ - setNeedsSave(true); - }); connect(this, &Feedback::plasmaFeedbackLevelChanged, this, [this](){ setNeedsSave(true); }); } Feedback::~Feedback() = default; -void Feedback::load() +bool Feedback::feedbackEnabled() const { - //The global kill switch is off by default, all KDE components should default to KUserFeedback::Provider::NoTelemetry KUserFeedback::Provider p; - setFeedbackEnabled(p.isEnabled()); + return p.isEnabled(); +} +void Feedback::load() +{ + //We only operate if the kill switch is off, all KDE components should default to KUserFeedback::Provider::NoTelemetry setPlasmaFeedbackLevel(m_plasmaConfig->group("Global").readEntry("FeedbackLevel", int(KUserFeedback::Provider::NoTelemetry))); setNeedsSave(false); } void Feedback::save() { - m_globalConfig->group("UserFeedback").writeEntry("Enabled", m_feedbackEnabled); - m_globalConfig->sync(); - m_plasmaConfig->group("Global").writeEntry("FeedbackLevel", m_plasmaFeedbackLevel); m_plasmaConfig->sync(); } void Feedback::defaults() { - setFeedbackEnabled(true); setPlasmaFeedbackLevel(KUserFeedback::Provider::NoTelemetry); } #include "feedback.moc" diff --git a/kcms/feedback/feedback.h b/kcms/feedback/feedback.h index 5cb0db937..729f34e3d 100644 --- a/kcms/feedback/feedback.h +++ b/kcms/feedback/feedback.h @@ -1,69 +1,59 @@ /* * Copyright (C) 2019 David Edmundson * Copyright (C) 2019 Aleix Pol Gonzalez * * 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) 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. */ #pragma once #include #include class Feedback : public KQuickAddons::ConfigModule { Q_OBJECT - Q_PROPERTY(bool feedbackEnabled READ feedbackEnabled WRITE setFeedbackEnabled NOTIFY feedbackEnabledChanged) + Q_PROPERTY(bool feedbackEnabled READ feedbackEnabled CONSTANT) Q_PROPERTY(int plasmaFeedbackLevel READ plasmaFeedbackLevel WRITE setPlasmaFeedbackLevel NOTIFY plasmaFeedbackLevelChanged) public: explicit Feedback(QObject* parent = nullptr, const QVariantList &list = QVariantList()); ~Feedback() override; - bool feedbackEnabled() const { return m_feedbackEnabled; } + bool feedbackEnabled() const; int plasmaFeedbackLevel() const { return m_plasmaFeedbackLevel; } - void setFeedbackEnabled(bool feedbackEnabled) { - if (feedbackEnabled != m_feedbackEnabled) { - m_feedbackEnabled = feedbackEnabled; - Q_EMIT feedbackEnabledChanged(feedbackEnabled); - } - } - void setPlasmaFeedbackLevel(int plasmaFeedbackLevel) { if (plasmaFeedbackLevel != m_plasmaFeedbackLevel) { m_plasmaFeedbackLevel = plasmaFeedbackLevel; Q_EMIT plasmaFeedbackLevelChanged(plasmaFeedbackLevel); } } public Q_SLOTS: void load() override; void save() override; void defaults() override; Q_SIGNALS: - void feedbackEnabledChanged(bool feedbackEnabled) const; void plasmaFeedbackLevelChanged(bool plasmaFeedbackLevel); private: - KSharedConfig::Ptr m_globalConfig; KSharedConfig::Ptr m_plasmaConfig; - bool m_feedbackEnabled = false; int m_plasmaFeedbackLevel = 0; }; diff --git a/kcms/feedback/package/contents/ui/main.qml b/kcms/feedback/package/contents/ui/main.qml index dd3f8aa16..523923ee0 100644 --- a/kcms/feedback/package/contents/ui/main.qml +++ b/kcms/feedback/package/contents/ui/main.qml @@ -1,118 +1,125 @@ /* * Copyright (C) 2019 David Edmundson * Copyright (C) 2019 Aleix Pol Gonzalez * * 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) 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. */ import QtQuick 2.1 import QtQuick.Layouts 1.1 import QtQuick.Controls 2.3 as QQC2 import org.kde.kirigami 2.6 as Kirigami import org.kde.userfeedback 1.0 as UserFeedback import org.kde.kcm 1.2 SimpleKCM { id: root ConfigModule.buttons: ConfigModule.Defaults | ConfigModule.Apply leftPadding: width * 0.1 rightPadding: leftPadding + ColumnLayout { + Kirigami.InlineMessage { + id: infoLabel + Layout.fillWidth: true - QQC2.CheckBox { - Layout.topMargin: Kirigami.Units.gridUnit - Layout.bottomMargin: Kirigami.Units.gridUnit - Layout.alignment: Qt.AlignHCenter - checked: kcm.feedbackEnabled - onToggled: kcm.feedbackEnabled = checked - text: i18n("Allow KDE software to collect anonymous usage information") + type: Kirigami.MessageType.Information + visible: !form.enabled + text: i18n("User Feedback has been disabled centrally. Please contact your distributor.") } QQC2.Label { Kirigami.FormData.label: i18n("Plasma:") Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true wrapMode: Text.WordWrap - text: xi18nc("@info", "You can help us improve this software by sharing information about how you use it. This allows us to focus on things that matter to you.Contributing usage information is optional and entirely anonymous. It will not associate the data with any kind of unique identifier, and will never track the documents you open, the websites you visit, or any other kind of personal information.You can read more about our policy in the following link:") + text: xi18nc("@info", "You can read about our policy in the following link:") } Kirigami.UrlButton { Layout.alignment: Qt.AlignHCenter url: "https://kde.org/privacypolicy-apps.php" } Kirigami.Separator { Layout.fillWidth: true Layout.topMargin: Kirigami.Units.gridUnit Layout.bottomMargin: Kirigami.Units.gridUnit } Kirigami.FormLayout { + id: form + enabled: kcm.feedbackEnabled QQC2.Slider { id: statisticsModeSlider Kirigami.FormData.label: i18n("Plasma:") enabled: kcm.feedbackEnabled Layout.fillWidth: true readonly property var modeOptions: [UserFeedback.Provider.NoTelemetry, UserFeedback.Provider.BasicSystemInformation, UserFeedback.Provider.BasicUsageStatistics, UserFeedback.Provider.DetailedSystemInformation, UserFeedback.Provider.DetailedUsageStatistics] from: 0 to: modeOptions.length - 1 stepSize: 1 snapMode: QQC2.Slider.SnapAlways function findIndex(array, what) { for (var v in array) { if (array[v] == what) return v; } return null; } Component.onCompleted: { var idx = findIndex(modeOptions, kcm.plasmaFeedbackLevel) value = idx===null ? 2 : modeOptions[idx] } onMoved: { kcm.plasmaFeedbackLevel = modeOptions[value] } } UserFeedback.FeedbackConfigUiController { id: feedbackController applicationName: i18n("Plasma") } Kirigami.Heading { Layout.alignment: Qt.AlignHCenter Layout.maximumWidth: root.width * 0.5 wrapMode: Text.WordWrap level: 3 text: feedbackController.telemetryName(statisticsModeSlider.modeOptions[statisticsModeSlider.value]) } QQC2.Label { Layout.alignment: Qt.AlignHCenter Layout.maximumWidth: root.width * 0.5 wrapMode: Text.WordWrap - text: feedbackController.telemetryDescription(statisticsModeSlider.modeOptions[statisticsModeSlider.value]) + enabled: statisticsModeSlider.value > 0 + + text: { + feedbackController.applicationName + return feedbackController.telemetryDescription(statisticsModeSlider.modeOptions[statisticsModeSlider.value]) + } } } } }