Paste P465

Masterwork From Distant Lands
ActivePublic

Authored by davidedmundson on Sep 16 2019, 3:45 PM.
commit 3e9f4451cd994fefc71ad3a90bdfb7b0ad6c3ac7
Author: David Edmundson <kde@davidedmundson.co.uk>
Date: Fri Sep 13 22:04:53 2019 +0200
feedback kcm
diff --git a/kcms/CMakeLists.txt b/kcms/CMakeLists.txt
index ca55b3c3b..0f71cc8a2 100644
--- a/kcms/CMakeLists.txt
+++ b/kcms/CMakeLists.txt
@@ -1 +1,2 @@
add_subdirectory(translations)
+add_subdirectory(feedback)
diff --git a/kcms/feedback/CMakeLists.txt b/kcms/feedback/CMakeLists.txt
new file mode 100644
index 000000000..2a7091bb2
--- /dev/null
+++ b/kcms/feedback/CMakeLists.txt
@@ -0,0 +1,25 @@
+include(ECMQMLModules)
+
+# KI18N Translation Domain for this library.
+add_definitions(-DTRANSLATION_DOMAIN=\"kcm_feedback\")
+
+########### next target ###############
+
+set(kcm_feedback_PART_SRCS feedback.cpp)
+
+add_library(kcm_feedback MODULE ${kcm_feedback_PART_SRCS})
+
+target_link_libraries(kcm_feedback
+ KF5::I18n
+ KF5::KCMUtils
+ KF5::QuickAddons
+)
+
+kcoreaddons_desktop_to_json(kcm_feedback "kcm_feedback.desktop")
+
+########### install files ###############
+
+install(TARGETS kcm_feedback DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms)
+install(FILES kcm_feedback.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
+kpackage_install_package(package kcm_feedback kcms)
+
diff --git a/kcms/feedback/Messages.sh b/kcms/feedback/Messages.sh
new file mode 100644
index 000000000..88a8770c9
--- /dev/null
+++ b/kcms/feedback/Messages.sh
@@ -0,0 +1,2 @@
+#! /usr/bin/env bash
+$XGETTEXT `find . -name \*.cpp -o -name \*.qml` -o $podir/kcm_feedback.pot
diff --git a/kcms/feedback/feedback.cpp b/kcms/feedback/feedback.cpp
new file mode 100644
index 000000000..9ede3b492
--- /dev/null
+++ b/kcms/feedback/feedback.cpp
@@ -0,0 +1,52 @@
+#include "feedback.h"
+
+#include <KSharedConfig>
+#include <KConfigGroup>
+#include <KPluginFactory>
+#include <KAboutData>
+#include <KLocalizedString>
+
+K_PLUGIN_CLASS_WITH_JSON(Feedback, "kcm_feedback.json");
+
+Feedback::Feedback(QObject *parent, const QVariantList &args):
+ KQuickAddons::ConfigModule(parent),
+ m_config(KSharedConfig::openConfig(QStringLiteral("KDE/UserFeedback"), KConfig::NoGlobals))
+{
+ Q_UNUSED(args)
+ // KUserFeedback (due to dependency reasons) doens't use KConfig and have cascades or globals
+ // This KCM allows cascading so that a sysadmin can set the flag as immutable elsewhere
+ // the KCM will respect that and not write the value enabling kuserfeedback
+
+ KAboutData *about = new KAboutData(QStringLiteral("kcm_feedback"),
+ i18n("Configure Telemetry Settings"),
+ QStringLiteral("1.0"), QString(), KAboutLicense::LGPL);
+ setAboutData(about);
+}
+
+Feedback::~Feedback()
+{
+
+}
+
+void Feedback::load()
+{
+ m_feedbackEnabled = m_config->group("UserFeedback").readEntry("Enabled", false);
+ emit feedbackEnabledChanged();
+
+ connect(this, &Feedback::feedbackEnabledChanged, this, [this](){
+ setNeedsSave(true);
+ });
+}
+
+void Feedback::save()
+{
+ m_config->group("UserFeedback").writeEntry("Enabled", m_feedbackEnabled);
+}
+
+void Feedback::defaults()
+{
+ m_feedbackEnabled = false;
+ emit feedbackEnabledChanged();
+}
+
+#include "feedback.moc"
diff --git a/kcms/feedback/feedback.h b/kcms/feedback/feedback.h
new file mode 100644
index 000000000..3f8383526
--- /dev/null
+++ b/kcms/feedback/feedback.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2019 David Edmundson <davidedmundson@kde.org>
+ *
+ * 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 <KQuickAddons/ConfigModule>
+
+#include <KSharedConfig>
+
+class Feedback : public KQuickAddons::ConfigModule
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool feedbackEnabled MEMBER m_feedbackEnabled NOTIFY feedbackEnabledChanged)
+
+ public:
+ explicit Feedback(QObject* parent = nullptr, const QVariantList &list = QVariantList());
+ ~Feedback() override;
+
+ public Q_SLOTS:
+ void load() override;
+ void save() override;
+ void defaults() override;
+
+ Q_SIGNALS:
+ void feedbackEnabledChanged() const;
+
+ private:
+ KSharedConfig::Ptr m_config;
+ bool m_feedbackEnabled = false;
+};
diff --git a/kcms/feedback/kcm_feedback.desktop b/kcms/feedback/kcm_feedback.desktop
new file mode 100644
index 000000000..3a6fc9158
--- /dev/null
+++ b/kcms/feedback/kcm_feedback.desktop
@@ -0,0 +1,17 @@
+[Desktop Entry]
+Exec=kcmshell5 feedback
+Icon=preferences-desktop-locale
+Type=Service
+X-KDE-ServiceTypes=KCModule
+X-DocPath=kcontrol/feedback/index.html
+
+X-KDE-Library=kcm_feedback
+X-KDE-ParentApp=kcontrol
+
+# X-KDE-System-Settings-Parent-Category=regionalsettings
+X-KDE-Weight=40
+
+Name=Feedback
+Comment=FIXME
+
+Categories=Qt;KDE;
diff --git a/kcms/feedback/package/contents/ui/main.qml b/kcms/feedback/package/contents/ui/main.qml
new file mode 100644
index 000000000..1aa606ee0
--- /dev/null
+++ b/kcms/feedback/package/contents/ui/main.qml
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 David Edmundson <davidedmundson@kde.org>
+ *
+ * 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 QtControls
+import org.kde.kirigami 2.5 as Kirigami
+import org.kde.kcm 1.2
+
+SimpleKCM {
+ id: root
+
+ ConfigModule.buttons: ConfigModule.Defaults | ConfigModule.Apply
+
+ Kirigami.FormLayout {
+ QtControls.Label {
+ text: i18n("I am some text")
+ Kirigami.FormData.isSection: true
+ }
+ QtControls.CheckBox {
+ checked: kcm.feedbackEnabled
+ onToggled: kcm.feedbackEnabled = checked
+ text: i18n("Blah blah")
+ }
+ QtControls.Label {
+ textFormat: Text.RichText
+ text: i18n("The privacy policy can be found at\n \
+ <a href='https://kde.org/privacypolicy-apps.php'>Privacy Policy</a>")
+ Kirigami.FormData.isSection: true
+ }
+ }
+}
+
diff --git a/kcms/feedback/package/metadata.desktop b/kcms/feedback/package/metadata.desktop
new file mode 100644
index 000000000..f3fba3bbe
--- /dev/null
+++ b/kcms/feedback/package/metadata.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Feedback
+
+Icon=preferences-desktop-locale
+Type=Service
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-Name=kcm_feedback
+X-KDE-ServiceTypes=Plasma/Generic
+X-Plasma-API=declarativeappletscript
+
+X-Plasma-MainScript=ui/main.qml
davidedmundson edited the content of this paste. (Show Details)Sep 16 2019, 3:45 PM
davidedmundson changed the title of this paste from untitled to Masterwork From Distant Lands.