From 9eafbd28bd3d1c5fb5d6b5d1dae9f38c7ec278ef Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Fri, 23 Apr 2021 11:57:22 -0600 Subject: [PATCH] [applets/batterymonitor] Overhaul configuration and actions Right now the applet puts the entries to open the KCM and Energy Info page in a hamburger menu, while the Configure button opens the applet's own settings window which has only one item in it. This emphasizes the less important thing, while de-emphasizing the more important thing. We can solve this by making the applet's configure button open the KCM instead of the applet configuration window. This makes the configuration window inaccessible, so we delete it and move its one setting into the hamburger menu along with "Show Energy Information". This is okay as these two are lesser-used settings. Overall this should make the actions easier to access and use, and more relevant to the user. BUG: 407560 FIXED-IN: 5.22 --- .../package/contents/config/config.qml | 30 -------------- .../package/contents/ui/ConfigGeneral.qml | 41 ------------------- .../package/contents/ui/batterymonitor.qml | 20 +++++++-- 3 files changed, 16 insertions(+), 75 deletions(-) delete mode 100644 applets/batterymonitor/package/contents/config/config.qml delete mode 100644 applets/batterymonitor/package/contents/ui/ConfigGeneral.qml diff --git a/applets/batterymonitor/package/contents/config/config.qml b/applets/batterymonitor/package/contents/config/config.qml deleted file mode 100644 index 5b7303849..000000000 --- a/applets/batterymonitor/package/contents/config/config.qml +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************** - * Copyright 2016 Marco Martin * - * * - * 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; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -import QtQuick 2.0 - -import org.kde.plasma.configuration 2.0 - -ConfigModel { - ConfigCategory { - name: i18n("General") - icon: "battery" - source: "ConfigGeneral.qml" - } -} diff --git a/applets/batterymonitor/package/contents/ui/ConfigGeneral.qml b/applets/batterymonitor/package/contents/ui/ConfigGeneral.qml deleted file mode 100644 index cb739309a..000000000 --- a/applets/batterymonitor/package/contents/ui/ConfigGeneral.qml +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016 Marco Martin - * - * 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; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. - */ - -import QtQuick 2.0 -import QtQuick.Controls 2.5 -import org.kde.kirigami 2.4 as Kirigami - -Item { - id: root - - width: pageColumn.width - height: pageColumn.height - - property alias cfg_showPercentage: showPercentage.checked - - Kirigami.FormLayout { - id: pageColumn - anchors.left: parent.left - anchors.right: parent.right - - CheckBox { - id: showPercentage - text: i18n("Show percentage") - } - } -} diff --git a/applets/batterymonitor/package/contents/ui/batterymonitor.qml b/applets/batterymonitor/package/contents/ui/batterymonitor.qml index 71ba2d3ce..22215113f 100644 --- a/applets/batterymonitor/package/contents/ui/batterymonitor.qml +++ b/applets/batterymonitor/package/contents/ui/batterymonitor.qml @@ -149,7 +149,7 @@ Item { }); } - function action_powerdevilkcm() { + function action_configure() { KCMShell.openSystemSettings("powerdevilprofilesconfig"); } @@ -157,19 +157,31 @@ Item { KCMShell.openInfoCenter("kcm_energyinfo"); } + function action_showPercentage() { + if (!plasmoid.configuration.showPercentage) { + plasmoid.configuration.showPercentage = true; + } else { + plasmoid.configuration.showPercentage = false; + } + } + Component.onCompleted: { Logic.updateBrightness(batterymonitor, pmSource); Logic.updateInhibitions(batterymonitor, pmSource) if (batterymonitor.kcmEnergyInformationAuthorized) { - plasmoid.setAction("energyinformationkcm", i18n("&Show Energy Information..."), "battery"); + plasmoid.setAction("energyinformationkcm", i18n("&Show Energy Information..."), "documentinfo"); } + plasmoid.setAction("showPercentage", i18n("Show Battery Percentage on Icon"), "format-number-percent"); + plasmoid.action("showPercentage").checkable = true; + plasmoid.action("showPercentage").checked = Qt.binding(() => {return plasmoid.configuration.showPercentage;}); + if (batterymonitor.kcmAuthorized) { - plasmoid.setAction("powerdevilkcm", i18n("&Configure Power Saving..."), "preferences-system-power-management"); + plasmoid.removeAction("configure"); + plasmoid.setAction("configure", i18n("&Configure Energy Saving..."), "configure", "alt+d, s"); } } - property QtObject pmSource: PlasmaCore.DataSource { id: pmSource engine: "powermanagement"