Verified Commit b7f69359 authored by ivan tkachenko's avatar ivan tkachenko
Browse files

[applets/batterymonitor] PowerManagement: Unify inhibition hints

No more one/many hints discrimination. They can all live happy together,
under single Repeater, using model directly. When the model will
migrate to a real Qt AbstractModel subclass (e.g. QML ListModel),
delegate's properties code will need to be adjusted again though.
parent c6e95b7f
Pipeline #125516 passed with stage
in 4 minutes and 31 seconds
......@@ -63,7 +63,6 @@ ColumnLayout {
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.")
}
// UI to display when there is more than one inhibition
PlasmaComponents3.Label {
id: inhibitionExplanation
Layout.fillWidth: true
......@@ -80,33 +79,26 @@ ColumnLayout {
}
Repeater {
visible: root.inhibitions.length > 1 && !root.disabled
model: visible ? root.inhibitions.length : null
// Don't need to show the inhibitions when power management
// is manually disabled anyway
visible: !root.disabled
model: !root.disabled ? root.inhibitions : null
InhibitionHint {
property string icon: modelData.Icon
property string name: modelData.Name
property string reason: modelData.Reason
Layout.fillWidth: true
iconSource: root.inhibitions[index].Icon || ""
text: root.inhibitions[index].Reason
? i18nc("Application name: reason for preventing sleep and screen locking", "%1: %2", root.inhibitions[index].Name, root.inhibitions[index].Reason)
: i18nc("Application name: reason for preventing sleep and screen locking", "%1: unknown reason", root.inhibitions[index].Name)
iconSource: icon
text: (root.inhibitions.length === 1)
? (reason
? i18n("%1 is currently blocking sleep and screen locking (%2)", name, reason)
: i18n("%1 is currently blocking sleep and screen locking (unknown reason)", name))
: (reason
? i18nc("Application name: reason for preventing sleep and screen locking", "%1: %2", name, reason)
: i18nc("Application name: reason for preventing sleep and screen locking", "%1: unknown reason", name))
}
}
// UI to display when there is only one inhibition
InhibitionHint {
Layout.fillWidth: true
// Don't need to show the inhibitions when power management
// is manually disabled anyway
visible: root.inhibitions.length === 1 && !root.disabled
iconSource: (root.inhibitions.length === 1) ? root.inhibitions[0].Icon : ""
text: (root.inhibitions.length === 1) ?
root.inhibitions[0].Reason ?
i18n("%1 is currently blocking sleep and screen locking (%2)", root.inhibitions[0].Name, root.inhibitions[0].Reason)
:
i18n("%1 is currently blocking sleep and screen locking (unknown reason)", root.inhibitions[0].Name)
:
""
}
}
}
Supports Markdown
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