From b82d79caa78f691c61fe656c68035c314611420b Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sat, 23 Apr 2022 07:36:38 +0300 Subject: [PATCH] plasma: put back the inhibition item to the battery monitor applet Signed-off-by: Ivailo Monev --- .../batterymonitor/contents/ui/PopupDialog.qml | 9 +++ .../contents/ui/PowerManagementItem.qml | 66 ++++++++++++++++++++++ .../batterymonitor/contents/ui/batterymonitor.qml | 2 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 plasma/applets/batterymonitor/contents/ui/PowerManagementItem.qml diff --git a/plasma/applets/batterymonitor/contents/ui/PopupDialog.qml b/plasma/applets/batterymonitor/contents/ui/PopupDialog.qml index d3b09b08..298929cc 100644 --- a/plasma/applets/batterymonitor/contents/ui/PopupDialog.qml +++ b/plasma/applets/batterymonitor/contents/ui/PopupDialog.qml @@ -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 index 00000000..084970aa --- /dev/null +++ b/plasma/applets/batterymonitor/contents/ui/PowerManagementItem.qml @@ -0,0 +1,66 @@ +/* + * Copyright 2012-2013 Daniel Nicoletti + * Copyright 2013 Kai Uwe Broulik + * + * 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(); + } +} + diff --git a/plasma/applets/batterymonitor/contents/ui/batterymonitor.qml b/plasma/applets/batterymonitor/contents/ui/batterymonitor.qml index 6d86887e..92829636 100644 --- a/plasma/applets/batterymonitor/contents/ui/batterymonitor.qml +++ b/plasma/applets/batterymonitor/contents/ui/batterymonitor.qml @@ -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 -- 2.11.0