[applets/batterymonitor] PowerManagement: Factor out lid behavior as a property

Pass down laptop's lid action inhibition all the way from the top-level
file to reduce dependency on sketchy context properties and make
components more self-contained.
wilder-5.25
ivan tkachenko 4 years ago
parent 301832c894
commit 035e2233c4
No known key found for this signature in database
GPG Key ID: 4D197017E61437CF
  1. 2
      applets/batterymonitor/package/contents/ui/PopupDialog.qml
  2. 3
      applets/batterymonitor/package/contents/ui/PowerManagementItem.qml
  3. 1
      applets/batterymonitor/package/contents/ui/main.qml

@ -36,6 +36,7 @@ PlasmaComponents3.Page {
// Reason: string,
// }]
property var inhibitions: []
property bool inhibitsLidAction
property string inhibitionReason
property string degradationReason
@ -51,6 +52,7 @@ PlasmaComponents3.Page {
id: pmSwitch
inhibitions: dialog.inhibitions
inhibitsLidAction: dialog.inhibitsLidAction
pluggedIn: dialog.pluggedIn
onDisabledChanged: powerManagementChanged(disabled)

@ -27,6 +27,7 @@ ColumnLayout {
// Reason: string,
// }]
property var inhibitions: []
property bool inhibitsLidAction
// UI to manually inhibit sleep and screen locking
PlasmaComponents3.CheckBox {
@ -56,7 +57,7 @@ ColumnLayout {
InhibitionHint {
Layout.fillWidth: true
visible: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Is Lid Present"] && !pmSource.data["PowerDevil"]["Triggers Lid Action"] ? true : false
visible: root.inhibitsLidAction
iconSource: "computer-laptop"
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.")
}

@ -242,6 +242,7 @@ Item {
readonly property string actuallyActiveProfile: pmSource.data["Power Profiles"] ? (pmSource.data["Power Profiles"]["Current Profile"] || "") : ""
activeProfile: actuallyActiveProfile
inhibitions: batterymonitor.inhibitions
inhibitsLidAction: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Is Lid Present"] && !pmSource.data["PowerDevil"]["Triggers Lid Action"] ? true : false
profiles: pmSource.data["Power Profiles"] ? (pmSource.data["Power Profiles"]["Profiles"] || []) : []
inhibitionReason: pmSource.data["Power Profiles"] ? (pmSource.data["Power Profiles"]["Performance Inhibited Reason"] || "") : ""
degradationReason: pmSource.data["Power Profiles"] ? (pmSource.data["Power Profiles"]["Performance Degraded Reason"] || "") : ""

Loading…
Cancel
Save