mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
power-kcm: Port to FormCard
This commit is contained in:
parent
a12a106439
commit
c864d9f5e1
1 changed files with 101 additions and 114 deletions
|
|
@ -14,150 +14,137 @@ import QtQuick.Layouts 1.11
|
||||||
import org.kde.kirigami 2.10 as Kirigami
|
import org.kde.kirigami 2.10 as Kirigami
|
||||||
import org.kde.plasma.components 3.0 as PlasmaComponents
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
import org.kde.kcmutils
|
import org.kde.kcmutils
|
||||||
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
|
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||||
import org.kde.kcm.power.mobile.private 1.0
|
import org.kde.kcm.power.mobile.private 1.0
|
||||||
|
|
||||||
SimpleKCM {
|
SimpleKCM {
|
||||||
id: powermanagementModule
|
id: powermanagementModule
|
||||||
|
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
topPadding: Kirigami.Units.gridUnit
|
topPadding: 0
|
||||||
bottomPadding: Kirigami.Units.gridUnit
|
bottomPadding: Kirigami.Units.gridUnit
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
MobileForm.FormCard {
|
FormCard.FormHeader {
|
||||||
Layout.fillWidth: true
|
title: i18n("Devices")
|
||||||
|
}
|
||||||
contentItem: ColumnLayout {
|
|
||||||
spacing: 0
|
FormCard.FormCard {
|
||||||
|
Repeater {
|
||||||
MobileForm.FormCardHeader {
|
model: kcm.batteries
|
||||||
title: i18n("Devices")
|
|
||||||
}
|
delegate: FormCard.AbstractFormDelegate {
|
||||||
|
Layout.fillWidth: true
|
||||||
Repeater {
|
|
||||||
model: kcm.batteries
|
onClicked: kcm.push("BatteryPage.qml", { "battery": model.battery, "vendor": model.vendor, "product": model.product, "currentUdi": model.udi })
|
||||||
|
|
||||||
delegate: MobileForm.AbstractFormDelegate {
|
contentItem: RowLayout {
|
||||||
Layout.fillWidth: true
|
spacing: Kirigami.Units.gridUnit
|
||||||
|
|
||||||
onClicked: kcm.push("BatteryPage.qml", { "battery": model.battery, "vendor": model.vendor, "product": model.product, "currentUdi": model.udi })
|
Kirigami.Icon {
|
||||||
|
implicitWidth: Kirigami.Units.iconSizes.smallMedium
|
||||||
contentItem: RowLayout {
|
implicitHeight: Kirigami.Units.iconSizes.smallMedium
|
||||||
spacing: Kirigami.Units.gridUnit
|
Layout.rightMargin: Kirigami.Units.gridUnit
|
||||||
|
source: {
|
||||||
Kirigami.Icon {
|
switch (model.battery.type) {
|
||||||
implicitWidth: Kirigami.Units.iconSizes.smallMedium
|
case 3: return model.battery.chargeState === 1 ? "battery-full-charging" : "battery-full"
|
||||||
implicitHeight: Kirigami.Units.iconSizes.smallMedium
|
case 2: return "battery-ups"
|
||||||
Layout.rightMargin: Kirigami.Units.gridUnit
|
case 9: return "monitor"
|
||||||
source: {
|
case 4: return "input-mouse"
|
||||||
switch (model.battery.type) {
|
case 5: return "input-keyboard"
|
||||||
case 3: return model.battery.chargeState === 1 ? "battery-full-charging" : "battery-full"
|
case 1: return "phone"
|
||||||
case 2: return "battery-ups"
|
case 7: return "smartphone"
|
||||||
case 9: return "monitor"
|
default: return "paint-unknown"
|
||||||
case 4: return "input-mouse"
|
|
||||||
case 5: return "input-keyboard"
|
|
||||||
case 1: return "phone"
|
|
||||||
case 7: return "smartphone"
|
|
||||||
default: return "paint-unknown"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ColumnLayout {
|
|
||||||
|
ColumnLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
|
QQC2.Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
spacing: Kirigami.Units.smallSpacing
|
elide: Text.ElideRight
|
||||||
|
wrapMode: Text.Wrap
|
||||||
QQC2.Label {
|
maximumLineCount: 2
|
||||||
Layout.fillWidth: true
|
color: Kirigami.Theme.textColor
|
||||||
elide: Text.ElideRight
|
text: {
|
||||||
wrapMode: Text.Wrap
|
let batteryType;
|
||||||
maximumLineCount: 2
|
switch (model.battery.type) {
|
||||||
color: Kirigami.Theme.textColor
|
case 3: batteryType = i18n("Internal battery"); break;
|
||||||
text: {
|
case 2: batteryType = i18n("UPS battery"); break;
|
||||||
let batteryType;
|
case 9: batteryType = i18n("Monitor battery"); break;
|
||||||
switch (model.battery.type) {
|
case 4: batteryType = i18n("Mouse battery"); break;
|
||||||
case 3: batteryType = i18n("Internal battery"); break;
|
case 5: batteryType = i18n("Keyboard battery"); break;
|
||||||
case 2: batteryType = i18n("UPS battery"); break;
|
case 1: batteryType = i18n("PDA battery"); break;
|
||||||
case 9: batteryType = i18n("Monitor battery"); break;
|
case 7: batteryType = i18n("Phone battery"); break;
|
||||||
case 4: batteryType = i18n("Mouse battery"); break;
|
default: batteryType = i18n("Unknown battery"); break;
|
||||||
case 5: batteryType = i18n("Keyboard battery"); break;
|
|
||||||
case 1: batteryType = i18n("PDA battery"); break;
|
|
||||||
case 7: batteryType = i18n("Phone battery"); break;
|
|
||||||
default: batteryType = i18n("Unknown battery"); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const chargePercent = i18nc("%1 is value, %2 is unit", "%1%2", Number(battery.chargePercent).toLocaleString(Qt.locale(), "f", 0), i18n("%"));
|
|
||||||
|
|
||||||
return (model.battery.chargeState === Battery.Charging) ? i18nc("%1 is battery type, %2 is charge percent", "%1 %2 (Charging)", batteryType, chargePercent) : i18nc("%1 is battery type, %2 is charge percent", "%1 %2", batteryType, chargePercent);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
const chargePercent = i18nc("%1 is value, %2 is unit", "%1%2", Number(battery.chargePercent).toLocaleString(Qt.locale(), "f", 0), i18n("%"));
|
||||||
QQC2.ProgressBar {
|
|
||||||
Layout.fillWidth: true
|
return (model.battery.chargeState === Battery.Charging) ? i18nc("%1 is battery type, %2 is charge percent", "%1 %2 (Charging)", batteryType, chargePercent) : i18nc("%1 is battery type, %2 is charge percent", "%1 %2", batteryType, chargePercent);
|
||||||
from: 0
|
|
||||||
to: 100
|
|
||||||
value: model.battery.chargePercent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Kirigami.Icon {
|
QQC2.ProgressBar {
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
Layout.fillWidth: true
|
||||||
source: "arrow-right"
|
from: 0
|
||||||
implicitWidth: Math.round(Kirigami.Units.iconSizes.small * 0.75)
|
to: 100
|
||||||
implicitHeight: Math.round(Kirigami.Units.iconSizes.small * 0.75)
|
value: model.battery.chargePercent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kirigami.Icon {
|
||||||
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||||
|
source: "arrow-right"
|
||||||
|
implicitWidth: Math.round(Kirigami.Units.iconSizes.small * 0.75)
|
||||||
|
implicitHeight: Math.round(Kirigami.Units.iconSizes.small * 0.75)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MobileForm.FormCard {
|
FormCard.FormHeader {
|
||||||
Layout.fillWidth: true
|
title: i18n("Screen")
|
||||||
Layout.topMargin: Kirigami.Units.gridUnit
|
}
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
FormCard.FormCard {
|
||||||
spacing: 0
|
FormCard.FormComboBoxDelegate {
|
||||||
|
id: dimScreenCombo
|
||||||
|
text: i18nc("Part of a sentence like 'Dim screen after 5 minutes'", "Dim screen after")
|
||||||
|
model: kcm.timeOptions()
|
||||||
|
currentIndex: kcm.dimScreenIdx
|
||||||
|
Component.onCompleted: dialog.parent = powermanagementModule
|
||||||
|
onCurrentIndexChanged: kcm.dimScreenIdx = currentIndex
|
||||||
|
}
|
||||||
|
|
||||||
MobileForm.FormCardHeader {
|
FormCard.FormDelegateSeparator { above: dimScreenCombo; below: screenOffCombo }
|
||||||
title: i18n("Screen")
|
|
||||||
}
|
|
||||||
|
|
||||||
MobileForm.FormComboBoxDelegate {
|
FormCard.FormComboBoxDelegate {
|
||||||
id: dimScreenCombo
|
id: screenOffCombo
|
||||||
text: i18nc("Part of a sentence like 'Dim screen after 5 minutes'", "Dim screen after")
|
text: i18nc("Part of a sentence like 'Turn off screen after 5 minutes'", "Turn off screen after")
|
||||||
model: kcm.timeOptions()
|
model: kcm.timeOptions()
|
||||||
currentIndex: kcm.dimScreenIdx
|
currentIndex: kcm.screenOffIdx
|
||||||
Component.onCompleted: dialog.parent = powermanagementModule
|
Component.onCompleted: dialog.parent = powermanagementModule
|
||||||
onCurrentIndexChanged: kcm.dimScreenIdx = currentIndex
|
onCurrentIndexChanged: kcm.screenOffIdx = currentIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
MobileForm.FormDelegateSeparator { above: dimScreenCombo; below: screenOffCombo }
|
FormCard.FormDelegateSeparator { above: screenOffCombo; below: suspendCombo }
|
||||||
|
|
||||||
MobileForm.FormComboBoxDelegate {
|
FormCard.FormComboBoxDelegate {
|
||||||
id: screenOffCombo
|
id: suspendCombo
|
||||||
text: i18nc("Part of a sentence like 'Turn off screen after 5 minutes'", "Turn off screen after")
|
text: i18nc("Part of a sentence like 'Suspend device after 5 minutes'", "Suspend device after")
|
||||||
model: kcm.timeOptions()
|
model: kcm.timeOptions()
|
||||||
currentIndex: kcm.screenOffIdx
|
currentIndex: kcm.suspendSessionIdx
|
||||||
Component.onCompleted: dialog.parent = powermanagementModule
|
Component.onCompleted: dialog.parent = powermanagementModule
|
||||||
onCurrentIndexChanged: kcm.screenOffIdx = currentIndex
|
onCurrentIndexChanged: kcm.suspendSessionIdx = currentIndex
|
||||||
}
|
|
||||||
|
|
||||||
MobileForm.FormDelegateSeparator { above: screenOffCombo; below: suspendCombo }
|
|
||||||
|
|
||||||
MobileForm.FormComboBoxDelegate {
|
|
||||||
id: suspendCombo
|
|
||||||
text: i18nc("Part of a sentence like 'Suspend device after 5 minutes'", "Suspend device after")
|
|
||||||
model: kcm.timeOptions()
|
|
||||||
currentIndex: kcm.suspendSessionIdx
|
|
||||||
Component.onCompleted: dialog.parent = powermanagementModule
|
|
||||||
onCurrentIndexChanged: kcm.suspendSessionIdx = currentIndex
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue