Commit 544f917e authored by Nate Graham's avatar Nate Graham 🔩
Browse files

[applets/batterymonitor] Improve UI for power management inhibition

This patch improves the UI for inhibiting power management and seeing
which apps are automatically doing it. Here are the changes, explained:

1. Use less jargonistic terminology for the feature itself, and remove
   the explanatory tooltip which is no longer necessary
2. Show the full list of apps which are inhibiting power management,
   because we have the space now that app icons are smaller
3. Correctly show and hide the list of inhibitions based on count and
   Whether or not the user has independently suppressed PM
4. Leave a bit more room for long reasons and alert translators to
   minimize string length as much as possible

BUG: 401108
FIXED-IN: 5.20.0
parent 3437a1e0
......@@ -42,6 +42,6 @@ RowLayout {
font: theme.smallestFont
wrapMode: Text.WordWrap
elide: Text.ElideRight
maximumLineCount: 3
maximumLineCount: 4
}
}
......@@ -36,18 +36,8 @@ ColumnLayout {
Components.CheckBox {
id: pmCheckBox
Layout.fillWidth: true
text: i18n("Enable Power Management")
text: i18nc("Minimize the length of this string as much as possible", "Allow automatic sleep and screen locking")
checked: true
// we don't want to mess with the checked state but still reflect that changing it might not yield the desired result
opacity: inhibitions.length > 0 ? 0.5 : 1
Behavior on opacity {
NumberAnimation { duration: units.longDuration }
}
PlasmaCore.ToolTipArea {
anchors.fill: parent
subText: i18n("Disabling power management will prevent your screen and computer from turning off automatically.\n\nMost applications will automatically suppress power management when they don't want to have you interrupted.")
}
}
Components.ToolButton {
......@@ -67,32 +57,42 @@ ColumnLayout {
Layout.fillWidth: true
visible: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Is Lid Present"] && !pmSource.data["PowerDevil"]["Triggers Lid Action"] ? true : false
iconSource: "computer-laptop"
text: i18n("Your notebook is configured not to suspend when closing the lid while an external monitor is connected.")
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.")
}
InhibitionHint {
Components.Label {
id: inhibitionExplanation
Layout.fillWidth: true
visible: inhibitions.length > 0
iconSource: inhibitions.length > 0 ? inhibitions[0].Icon || "" : ""
// Don't need to show the inhibitions when power management
// isn't enabled anyway
visible: inhibitions.length > 0 && pmCheckBox.checked
font: theme.smallestFont
wrapMode: Text.WordWrap
elide: Text.ElideRight
maximumLineCount: 3
text: {
if (inhibitions.length > 1) {
return i18ncp("Some Application and n others are currently suppressing PM",
"%2 and %1 other application are currently suppressing power management.",
"%2 and %1 other applications are currently suppressing power management.",
inhibitions.length - 1, inhibitions[0].Name) // plural only works on %1
} else if (inhibitions.length === 1) {
if (!inhibitions[0].Reason) {
return i18nc("Some Application is suppressing PM",
"%1 is currently suppressing power management.", inhibitions[0].Name)
} else {
return i18nc("Some Application is suppressing PM: Reason provided by the app",
"%1 is currently suppressing power management: %2", inhibitions[0].Name, inhibitions[0].Reason)
}
if (inhibitions.length === 1) {
return i18n("An application is preventing sleep and screen locking:")
} 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 {
model: inhibitionExplanation.visible ? inhibitions.length : null
InhibitionHint {
Layout.fillWidth: true
iconSource: inhibitions[index].Icon || ""
text: inhibitions[index].Reason ?
i18nc("Application name: reason for preventing sleep and screen locking", "%1: %2", inhibitions[index].Name, inhibitions[index].Reason)
: i18nc("Application name: reason for preventing sleep and screen locking", "%1: unknown reason", inhibitions[index].Name)
}
}
}
}
......@@ -85,7 +85,7 @@ Item {
} // otherwise, don't add anything
if (powermanagementDisabled) {
parts.push(i18n("Power management is disabled"));
parts.push(i18n("Automatic sleep and screen locking are disabled"));
}
return parts.join("\n");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment