diff --git a/kcms/feedback/feedback.cpp b/kcms/feedback/feedback.cpp index d7fa0e651..cf789f425 100644 --- a/kcms/feedback/feedback.cpp +++ b/kcms/feedback/feedback.cpp @@ -1,74 +1,82 @@ /* * 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_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::plasmaFeedbackLevelChanged, this, [this](){ setNeedsSave(true); }); } Feedback::~Feedback() = default; bool Feedback::feedbackEnabled() const { KUserFeedback::Provider p; 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_plasmaConfig->group("Global").writeEntry("FeedbackLevel", m_plasmaFeedbackLevel); m_plasmaConfig->sync(); } void Feedback::defaults() { setPlasmaFeedbackLevel(KUserFeedback::Provider::NoTelemetry); } +void Feedback::setPlasmaFeedbackLevel(int plasmaFeedbackLevel) { + if (plasmaFeedbackLevel != m_plasmaFeedbackLevel) { + m_plasmaFeedbackLevel = plasmaFeedbackLevel; + Q_EMIT plasmaFeedbackLevelChanged(plasmaFeedbackLevel); + } + setRepresentsDefaults(plasmaFeedbackLevel == KUserFeedback::Provider::NoTelemetry); +} + #include "feedback.moc" diff --git a/kcms/feedback/feedback.h b/kcms/feedback/feedback.h index 729f34e3d..7ec5da4a7 100644 --- a/kcms/feedback/feedback.h +++ b/kcms/feedback/feedback.h @@ -1,59 +1,54 @@ /* * 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 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; int plasmaFeedbackLevel() const { return m_plasmaFeedbackLevel; } - void setPlasmaFeedbackLevel(int plasmaFeedbackLevel) { - if (plasmaFeedbackLevel != m_plasmaFeedbackLevel) { - m_plasmaFeedbackLevel = plasmaFeedbackLevel; - Q_EMIT plasmaFeedbackLevelChanged(plasmaFeedbackLevel); - } - } + void setPlasmaFeedbackLevel(int plasmaFeedbackLevel); public Q_SLOTS: void load() override; void save() override; void defaults() override; Q_SIGNALS: void plasmaFeedbackLevelChanged(bool plasmaFeedbackLevel); private: KSharedConfig::Ptr m_plasmaConfig; int m_plasmaFeedbackLevel = 0; };