Changeset View
Changeset View
Standalone View
Standalone View
Modules/energy/package/contents/ui/main.qml
Show All 21 Lines | |||||
22 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
23 | import org.kde.kirigami 2.5 as Kirigami | 23 | import org.kde.kirigami 2.5 as Kirigami | ||
24 | 24 | | |||
25 | import org.kde.kquickcontrolsaddons 2.0 | 25 | import org.kde.kquickcontrolsaddons 2.0 | ||
26 | import org.kde.kinfocenter.energy.private 1.0 | 26 | import org.kde.kinfocenter.energy.private 1.0 | ||
27 | 27 | | |||
28 | import org.kde.plasma.core 2.0 as PlasmaCore | 28 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
29 | 29 | | |||
30 | import org.kde.plasma.workspace.components 2.0 as WorkspaceComponents | | |||
31 | import org.kde.kcm 1.1 as KCM | 30 | import org.kde.kcm 1.1 as KCM | ||
32 | 31 | | |||
33 | KCM.SimpleKCM { | 32 | KCM.SimpleKCM { | ||
34 | id: root | 33 | id: root | ||
35 | 34 | | |||
36 | KCM.ConfigModule.quickHelp: i18n("This module lets you see energy information and statistics.") | 35 | KCM.ConfigModule.quickHelp: i18n("This module lets you see energy information and statistics.") | ||
37 | 36 | | |||
38 | property QtObject currentBattery: null | 37 | property QtObject currentBattery: null | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 126 | QQC2.Button { | |||
143 | 142 | | |||
144 | ColumnLayout { | 143 | ColumnLayout { | ||
145 | anchors { | 144 | anchors { | ||
146 | fill: parent | 145 | fill: parent | ||
147 | margins: units.smallSpacing | 146 | margins: units.smallSpacing | ||
148 | } | 147 | } | ||
149 | spacing: 0 | 148 | spacing: 0 | ||
150 | 149 | | |||
151 | WorkspaceComponents.BatteryIcon { | 150 | Kirigami.icon { | ||
152 | Layout.fillWidth: true | 151 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter | ||
153 | Layout.fillHeight: true | 152 | width: Kirigami.Units.iconSizes.small | ||
153 | height: Kirigami.Units.iconSizes.small | ||||
154 | hasBattery: true | 154 | hasBattery: true | ||
155 | batteryType: { | 155 | source: { | ||
156 | switch(model.battery.type) { | 156 | switch(model.battery.type) { | ||
157 | case 3: return "Battery" | 157 | case 3: return "battery-full" | ||
158 | case 2: return "Ups" | 158 | case 2: return "battery-ups" | ||
159 | case 9: return "Monitor" | 159 | case 9: return "monitor" | ||
160 | case 4: return "Mouse" | 160 | case 4: return "input-mouse" | ||
161 | case 5: return "Keyboard" | 161 | case 5: return "input-keyboard" | ||
162 | case 1: return "Pda" | 162 | case 1: return "phone" | ||
163 | case 7: return "Phone" | 163 | case 7: return "smartphone" | ||
164 | default: return "Unknown" | 164 | default: return "paint-unknown" | ||
broulik: Now you lost the battery level and charging state in the icon. | |||||
Can use the following var iconNameParts = ["battery"]; // Round percentage to the nearest 10% and pad it with leading zeroes to match the icon names iconNameParts.push(String(Math.round(model.battery.chargePercent / 10) * 10).padStart(3, "0")); if (model.battery.chargeState === 1) { // charging iconNameParts.push("charging"); } return iconNameParts.join("-"); broulik: Can use the following
```
var iconNameParts = ["battery"];
// Round percentage to the nearest… | |||||
My thought was that the battery level indicator inside the icon wasn't necessary because this UI has a current charge level indicator below the icon. Might be nice to show the plugged-in status though. ngraham: My thought was that the battery level indicator inside the icon wasn't necessary because this… | |||||
165 | } | 165 | } | ||
166 | } | 166 | } | ||
167 | percent: model.battery.chargePercent | | |||
168 | //pluggedIn: model.battery.chargeState === 1 // Makes it hard to see | | |||
169 | } | 167 | } | ||
170 | 168 | | |||
171 | QQC2.ProgressBar { // TODO make progress bar not eat mouse events | 169 | QQC2.ProgressBar { // TODO make progress bar not eat mouse events | ||
172 | Layout.fillWidth: true | 170 | Layout.fillWidth: true | ||
173 | from: 0 | 171 | from: 0 | ||
174 | to: 100 | 172 | to: 100 | ||
175 | value: model.battery.chargePercent | 173 | value: model.battery.chargePercent | ||
176 | enabled: button.checked ? false : true | 174 | enabled: button.checked ? false : true | ||
▲ Show 20 Lines • Show All 297 Lines • Show Last 20 Lines |
Now you lost the battery level and charging state in the icon.