[applets/battery] Clarify power management inhibition UI

The power management inhibition UI is currently somewhat confusing to
users because it's not clear that the checkbox is a local override for
the permanent settings set elsewhere in System Settings.

A good sign that the UI is sub-optimal is that we refer to it as "power
management inhibition" internally and in our developer conversations,
but the UI expresses the opposite: *allowing* power management, not
inhibiting it. This conflicts in the user's mind with the UI in System
Settings that is also expressed in terms of allowing it. It is further
confused by the fact that the message about apps suppressing power
management is phrased in terms of being an temporary override, and that
we also show an unrelated message about the battery charge limit (if set)
in the same place where we're notifying the user about power management
inhibition.

Let's clarify this UI by doing the following:

- Re-word the checkbox's label to emphasize that it's a local override
  for the settings that were set elsewhere
- Move the charge level message into the battery item itself, since
  that's what it affects
- Slightly re-word the message for when apps are inhibiting power
  management to emphasize that power management can be inhibited
  automatically by apps in additionto manually by the user

BUG: 435827
FIXED-IN: 5.22
wilder-5.22
Nate Graham 5 years ago
parent e8e17c5ef8
commit 8916b14f0e
  1. 13
      applets/batterymonitor/package/contents/ui/BatteryItem.qml
  2. 4
      applets/batterymonitor/package/contents/ui/PopupDialog.qml
  3. 47
      applets/batterymonitor/package/contents/ui/PowerManagementItem.qml
  4. 30
      applets/batterymonitor/package/contents/ui/batterymonitor.qml

@ -208,6 +208,19 @@ Item {
opacity: 0.5 opacity: 0.5
sourceComponent: batteryDetails sourceComponent: batteryDetails
} }
InhibitionHint {
anchors {
left: parent.left
leftMargin: batteryIcon.width + PlasmaCore.Units.gridUnit
right: parent.right
}
readonly property var chargeStopThreshold: pmSource.data["Battery"] ? pmSource.data["Battery"]["Charge Stop Threshold"] : undefined
readonly property bool pluggedIn: pmSource.data["AC Adapter"] !== undefined && pmSource.data["AC Adapter"]["Plugged in"]
visible: pluggedIn && typeof chargeStopThreshold === "number" && chargeStopThreshold > 0 && chargeStopThreshold < 100
iconSource: "kt-speed-limits" // FIXME good icon
text: i18n("Your battery is configured to only charge up to %1%.", chargeStopThreshold || 0)
}
} }
} }

@ -35,14 +35,14 @@ PlasmaComponents3.Page {
property bool isBrightnessAvailable property bool isBrightnessAvailable
property bool isKeyboardBrightnessAvailable property bool isKeyboardBrightnessAvailable
signal powermanagementChanged(bool checked) signal powermanagementChanged(bool disabled)
header: PlasmaExtras.PlasmoidHeading { header: PlasmaExtras.PlasmoidHeading {
PowerManagementItem { PowerManagementItem {
id: pmSwitch id: pmSwitch
width: parent.width width: parent.width
pluggedIn: dialog.pluggedIn pluggedIn: dialog.pluggedIn
onEnabledChanged: powermanagementChanged(enabled) onDisabledChanged: powermanagementChanged(disabled)
KeyNavigation.tab: batteryList KeyNavigation.tab: batteryList
KeyNavigation.backtab: keyboardBrightnessSlider KeyNavigation.backtab: keyboardBrightnessSlider
} }

@ -25,8 +25,8 @@ import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.kquickcontrolsaddons 2.0 import org.kde.kquickcontrolsaddons 2.0
ColumnLayout { ColumnLayout {
id: powerManagementHeadingColumn id: powerManagement
property alias enabled: pmCheckBox.checked property alias disabled: pmCheckBox.checked
property bool pluggedIn property bool pluggedIn
spacing: 0 spacing: 0
@ -38,8 +38,8 @@ ColumnLayout {
PlasmaComponents3.CheckBox { PlasmaComponents3.CheckBox {
id: pmCheckBox id: pmCheckBox
Layout.fillWidth: true Layout.fillWidth: true
text: i18nc("Minimize the length of this string as much as possible", "Allow automatic sleep and screen locking") text: i18nc("Minimize the length of this string as much as possible", "Inhibit automatic sleep and screen locking")
checked: true checked: false
} }
} }
@ -50,42 +50,43 @@ ColumnLayout {
InhibitionHint { InhibitionHint {
Layout.fillWidth: true Layout.fillWidth: true
readonly property var chargeStopThreshold: pmSource.data["Battery"] ? pmSource.data["Battery"]["Charge Stop Threshold"] : undefined visible: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Is Lid Present"] && !pmSource.data["PowerDevil"]["Triggers Lid Action"] ? true : false
visible: powerManagementHeadingColumn.pluggedIn && typeof chargeStopThreshold === "number" && chargeStopThreshold > 0 && chargeStopThreshold < 100 iconSource: "computer-laptop"
iconSource: "kt-speed-limits" // FIXME good icon text: i18nc("Minimize the length of this string as much as possible", "Your notebook is configured not to sleep when closing the lid while an external monitor is connected.")
text: i18n("Your battery is configured to only charge up to %1%.", chargeStopThreshold || 0)
} }
// UI to display when there is only one inhibition
InhibitionHint { InhibitionHint {
// Don't need to show the inhibitions when power management
// isn't enabled anyway
visible: inhibitions.length === 1 && !powerManagement.disabled
Layout.fillWidth: true Layout.fillWidth: true
visible: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Is Lid Present"] && !pmSource.data["PowerDevil"]["Triggers Lid Action"] ? true : false iconSource: inhibitions[0].Icon || ""
iconSource: "computer-laptop" text: inhibitions[0].Reason ?
text: i18nc("Minimize the length of this string as much as possible", "Your notebook is configured not to sleep when closing the lid while an external monitor is connected.") i18n("%1 is inhibiting sleep and screen locking (%2)", inhibitions[0].Name, inhibitions[0].Reason)
: i18n("%1 is inhibiting sleep and screen locking (unknown reason)", inhibitions[0].Name)
} }
// UI to display when there is more than one inhibition
PlasmaComponents3.Label { PlasmaComponents3.Label {
id: inhibitionExplanation id: inhibitionExplanation
Layout.fillWidth: true Layout.fillWidth: true
// Don't need to show the inhibitions when power management // Don't need to show the inhibitions when power management
// isn't enabled anyway // isn't enabled anyway
visible: inhibitions.length > 0 && pmCheckBox.checked visible: inhibitions.length > 1 && !powerManagement.disabled
font: PlasmaCore.Theme.smallestFont font: PlasmaCore.Theme.smallestFont
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 3 maximumLineCount: 3
text: { text: i18np("%1 application is inhibiting sleep and screen locking:",
if (inhibitions.length === 1) { "%1 applications are inhibiting sleep and screen locking:",
return i18n("An application is preventing sleep and screen locking:") inhibitions.length)
} else if (inhibitions.length > 1) {
return i18np("%1 application is preventing sleep and screen locking:",
"%1 applications are preventing sleep and screen locking:",
inhibitions.length)
} else {
return ""
}
}
} }
Repeater { Repeater {
visible: inhibitions.length > 1
model: inhibitionExplanation.visible ? inhibitions.length : null model: inhibitionExplanation.visible ? inhibitions.length : null
InhibitionHint { InhibitionHint {

@ -223,39 +223,39 @@ Item {
property int cookie2: -1 property int cookie2: -1
onPowermanagementChanged: { onPowermanagementChanged: {
var service = pmSource.serviceForSource("PowerDevil"); var service = pmSource.serviceForSource("PowerDevil");
if (checked) { if (disabled) {
var op1 = service.operationDescription("stopSuppressingSleep"); var reason = i18n("The battery applet has enabled system-wide inhibition");
op1.cookie = cookie1; var op1 = service.operationDescription("beginSuppressingSleep");
var op2 = service.operationDescription("stopSuppressingScreenPowerManagement"); op1.reason = reason;
op2.cookie = cookie2; var op2 = service.operationDescription("beginSuppressingScreenPowerManagement");
op2.reason = reason;
var job1 = service.startOperationCall(op1); var job1 = service.startOperationCall(op1);
job1.finished.connect(function(job) { job1.finished.connect(function(job) {
cookie1 = -1; cookie1 = job.result;
}); });
var job2 = service.startOperationCall(op2); var job2 = service.startOperationCall(op2);
job2.finished.connect(function(job) { job2.finished.connect(function(job) {
cookie2 = -1; cookie2 = job.result;
}); });
} else { } else {
var reason = i18n("The battery applet has enabled system-wide inhibition"); var op1 = service.operationDescription("stopSuppressingSleep");
var op1 = service.operationDescription("beginSuppressingSleep"); op1.cookie = cookie1;
op1.reason = reason; var op2 = service.operationDescription("stopSuppressingScreenPowerManagement");
var op2 = service.operationDescription("beginSuppressingScreenPowerManagement"); op2.cookie = cookie2;
op2.reason = reason;
var job1 = service.startOperationCall(op1); var job1 = service.startOperationCall(op1);
job1.finished.connect(function(job) { job1.finished.connect(function(job) {
cookie1 = job.result; cookie1 = -1;
}); });
var job2 = service.startOperationCall(op2); var job2 = service.startOperationCall(op2);
job2.finished.connect(function(job) { job2.finished.connect(function(job) {
cookie2 = job.result; cookie2 = -1;
}); });
} }
batterymonitor.powermanagementDisabled = !checked batterymonitor.powermanagementDisabled = disabled
} }
} }
} }

Loading…
Cancel
Save