OSDN Git Service

plasma: put back the inhibition item to the battery monitor applet
authorIvailo Monev <xakepa10@gmail.com>
Sat, 23 Apr 2022 04:36:38 +0000 (07:36 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sat, 23 Apr 2022 04:36:50 +0000 (07:36 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
plasma/applets/batterymonitor/contents/ui/PopupDialog.qml
plasma/applets/batterymonitor/contents/ui/PowerManagementItem.qml [new file with mode: 0644]
plasma/applets/batterymonitor/contents/ui/batterymonitor.qml

index d3b09b0..298929c 100644 (file)
@@ -37,6 +37,8 @@ FocusScope {
 
     property bool popupShown // somehow plasmoid.popupShowing isn't working
 
+    property int pmSwitchWidth: padding.margins.left + pmSwitch.implicitWidth + padding.margins.right
+
     signal powermanagementChanged(bool checked)
 
     PlasmaCore.FrameSvgItem {
@@ -63,6 +65,7 @@ FocusScope {
             property int activeIndex
 
             delegate: BatteryItem { }
+            KeyNavigation.tab: pmSwitch
 
             function updateSelection(old,active) {
                 itemAt(old).updateSelection();
@@ -108,6 +111,12 @@ FocusScope {
             top: plasmoid.location == BottomEdge ? undefined : parent.top
             bottom: plasmoid.location == BottomEdge ? parent.bottom : undefined
         }
+
+        PowerManagementItem {
+            id: pmSwitch
+            onEnabledChanged: powermanagementChanged(enabled)
+            KeyNavigation.tab: batteryList
+        }
     }
 
     PlasmaCore.SvgItem {
diff --git a/plasma/applets/batterymonitor/contents/ui/PowerManagementItem.qml b/plasma/applets/batterymonitor/contents/ui/PowerManagementItem.qml
new file mode 100644 (file)
index 0000000..084970a
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *   Copyright 2012-2013 Daniel Nicoletti <dantti12@gmail.com>
+ *   Copyright 2013 Kai Uwe Broulik <kde@privat.broulik.de>
+ *
+ *   This program 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 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 Library 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 1.1
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.plasma.components 0.1 as Components
+import org.kde.qtextracomponents 0.1
+
+FocusScope {
+    id: brightnessItem
+    clip: true
+    width: parent.width
+    height: Math.max(pmCheckBox.height, pmLabel.height) + padding.margins.top + padding.margins.bottom
+
+    property bool enabled: pmCheckBox.checked
+    property int implicitWidth: theme.iconSizes.dialog + pmCheckBox.implicitWidth + 6 + pmLabel.paintedWidth
+
+    Components.CheckBox {
+        id: pmCheckBox
+        anchors {
+            verticalCenter: parent.verticalCenter
+            left: parent.left
+            leftMargin: padding.margins.left + (theme.iconSizes.dialog - width)
+            topMargin: padding.margins.top
+            bottomMargin: padding.margins.bottom
+        }
+        focus: true
+        checked: true
+    }
+
+    Components.Label {
+        id: pmLabel
+        anchors {
+            verticalCenter: pmCheckBox.verticalCenter
+            left: pmCheckBox.right
+            leftMargin: 6
+        }
+        height: paintedHeight
+        text: i18n("Enable Power Management")
+    }
+
+    MouseArea {
+        anchors.fill: parent
+
+        onReleased: pmCheckBox.released();
+        onPressed: pmCheckBox.forceActiveFocus();
+    }
+}
+
index 6d86887..9282963 100644 (file)
@@ -25,7 +25,7 @@ import "../code/logic.js" as Logic
 
 Item {
     id: batterymonitor
-    property int minimumWidth: dialogItem.actualWidth
+    property int minimumWidth: Math.max(theme.iconSizes.dialog * 9, dialogItem.pmSwitchWidth)
     property int minimumHeight: dialogItem.actualHeight
     property int maximumHeight: dialogItem.actualHeight