Changeset View
Changeset View
Standalone View
Standalone View
Modules/energy/package/contents/ui/main.qml
Show All 31 Lines | |||||
32 | 32 | | |||
33 | KCM.SimpleKCM { | 33 | KCM.SimpleKCM { | ||
34 | id: root | 34 | id: root | ||
35 | 35 | | |||
36 | KCM.ConfigModule.quickHelp: i18n("This module lets you see energy information and statistics.") | 36 | KCM.ConfigModule.quickHelp: i18n("This module lets you see energy information and statistics.") | ||
37 | 37 | | |||
38 | property QtObject currentBattery: null | 38 | property QtObject currentBattery: null | ||
39 | property string currentUdi: "" | 39 | property string currentUdi: "" | ||
40 | property string currentVendor: "" | ||||
41 | property string currentProduct: "" | ||||
40 | property bool compact: (root.width / units.gridUnit) < 25 | 42 | property bool compact: (root.width / units.gridUnit) < 25 | ||
41 | 43 | | |||
42 | onCurrentBatteryChanged: { | 44 | onCurrentBatteryChanged: { | ||
43 | if (!currentBattery) { | 45 | if (!currentBattery) { | ||
44 | currentBattery = kcm.batteries.get(0) | 46 | currentBattery = kcm.batteries.battery(0) | ||
47 | currentVendor = kcm.batteries.vendor(0) | ||||
48 | currentProduct = kcm.batteries.product(0) | ||||
45 | currentUdi = kcm.batteries.udi(0) | 49 | currentUdi = kcm.batteries.udi(0) | ||
46 | } | 50 | } | ||
47 | } | 51 | } | ||
48 | 52 | | |||
49 | property bool showWakeUps: true | 53 | property bool showWakeUps: true | ||
50 | property int historyType: HistoryModel.ChargeType | 54 | property int historyType: HistoryModel.ChargeType | ||
51 | 55 | | |||
52 | readonly property var details: [ | 56 | readonly property var details: [ | ||
Show All 11 Lines | 66 | data: [ | |||
64 | {label: i18n("Voltage"), value: "voltage", unit: i18nc("Volt", "V"), precision: 2}, | 68 | {label: i18n("Voltage"), value: "voltage", unit: i18nc("Volt", "V"), precision: 2}, | ||
65 | {label: i18n("Capacity"), value: "capacity", unit: i18n("%"), precision: 0}, | 69 | {label: i18n("Capacity"), value: "capacity", unit: i18n("%"), precision: 0}, | ||
66 | {label: i18n("Remaining energy"), value: "energy", unit: i18nc("Watt-hours", "Wh"), precision: 2}, | 70 | {label: i18n("Remaining energy"), value: "energy", unit: i18nc("Watt-hours", "Wh"), precision: 2}, | ||
67 | {label: i18n("Last full"), value: "energyFull", unit: i18nc("Watt-hours", "Wh"), precision: 2}, | 71 | {label: i18n("Last full"), value: "energyFull", unit: i18nc("Watt-hours", "Wh"), precision: 2}, | ||
68 | {label: i18n("Full design"), value: "energyFullDesign", unit: i18nc("Watt-hours", "Wh"), precision: 2} | 72 | {label: i18n("Full design"), value: "energyFullDesign", unit: i18nc("Watt-hours", "Wh"), precision: 2} | ||
69 | ] | 73 | ] | ||
70 | }, | 74 | }, | ||
71 | { | 75 | { | ||
72 | title: i18n("System"), | | |||
73 | data: [ | | |||
74 | {label: i18n("Has power supply"), value: "powerSupply"} | | |||
75 | ] | | |||
76 | }, | | |||
77 | { | | |||
78 | title: i18n("Environment"), | 76 | title: i18n("Environment"), | ||
79 | data: [ | 77 | data: [ | ||
80 | {label: i18n("Temperature"), value: "temperature", unit: i18nc("Degree Celsius", "°C"), precision: 2} | 78 | {label: i18n("Temperature"), value: "temperature", unit: i18nc("Degree Celsius", "°C"), precision: 2} | ||
81 | ] | 79 | ] | ||
82 | }, | 80 | }, | ||
83 | { | 81 | { | ||
84 | title: i18n("Manufacturer"), | 82 | title: i18n("Manufacturer"), | ||
85 | data: [ | 83 | data: [ | ||
86 | {label: i18n("Vendor"), value: "vendor"}, | 84 | {label: i18n("Vendor"), value: "vendor", source:"vendor"}, | ||
87 | {label: i18n("Model"), value: "model"}, | 85 | {label: i18n("Model"), value: "model", source:"product"}, | ||
88 | {label: i18n("Serial Number"), value: "serial"} | 86 | {label: i18n("Serial Number"), value: "serial"} | ||
89 | ] | 87 | ] | ||
90 | } | 88 | } | ||
91 | ] | 89 | ] | ||
92 | 90 | | |||
93 | function modifier_chargeState(value) { | 91 | function modifier_chargeState(value) { | ||
94 | switch(value) { | 92 | switch(value) { | ||
95 | case 0: return i18n("Not charging") | 93 | case 0: return i18n("Not charging") | ||
96 | case 1: return i18n("Charging") | 94 | case 1: return i18n("Charging") | ||
97 | case 2: return i18n("Discharging") | 95 | case 2: return i18n("Discharging") | ||
98 | case 3: return i18n("Fully charged") | 96 | case 3: return i18n("Fully charged") | ||
99 | } | 97 | } | ||
100 | } | 98 | } | ||
101 | 99 | | |||
102 | Component.onCompleted: { | 100 | Component.onCompleted: { | ||
103 | currentBattery = kcm.batteries.get(0) | 101 | currentBattery = kcm.batteries.get(0) | ||
102 | currentVendor = kcm.batteries.vendor(0) | ||||
103 | currentProduct = kcm.batteries.product(0) | ||||
104 | currentUdi = kcm.batteries.udi(0) | 104 | currentUdi = kcm.batteries.udi(0) | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | implicitWidth: units.gridUnit * 30 | 107 | implicitWidth: units.gridUnit * 30 | ||
108 | implicitHeight: !!currentBattery ? units.gridUnit * 30 : units.gridUnit * 12 | 108 | implicitHeight: !!currentBattery ? units.gridUnit * 30 : units.gridUnit * 12 | ||
109 | 109 | | |||
110 | readonly property var timespanComboChoices: [i18n("Last hour"),i18n("Last 2 hours"),i18n("Last 12 hours"),i18n("Last 24 hours"),i18n("Last 48 hours"), i18n("Last 7 days")] | 110 | readonly property var timespanComboChoices: [i18n("Last hour"),i18n("Last 2 hours"),i18n("Last 12 hours"),i18n("Last 24 hours"),i18n("Last 48 hours"), i18n("Last 7 days")] | ||
111 | readonly property var timespanComboDurations: [3600, 7200, 43200, 86400, 172800, 604800] | 111 | readonly property var timespanComboDurations: [3600, 7200, 43200, 86400, 172800, 604800] | ||
Show All 15 Lines | 124 | Repeater { | |||
127 | QQC2.Button { | 127 | QQC2.Button { | ||
128 | id: button | 128 | id: button | ||
129 | width: height | 129 | width: height | ||
130 | height: tabView.height | 130 | height: tabView.height | ||
131 | checked: model.battery == root.currentBattery | 131 | checked: model.battery == root.currentBattery | ||
132 | checkable: true | 132 | checkable: true | ||
133 | onClicked: { | 133 | onClicked: { | ||
134 | root.currentUdi = model.udi | 134 | root.currentUdi = model.udi | ||
135 | root.currentVendor = model.vendor | ||||
136 | root.currentProduct = model.product | ||||
135 | root.currentBattery = model.battery | 137 | root.currentBattery = model.battery | ||
138 | | ||||
136 | // override checked property | 139 | // override checked property | ||
137 | checked = Qt.binding(function() { | 140 | checked = Qt.binding(function() { | ||
138 | return model.battery == root.currentBattery | 141 | return model.battery == root.currentBattery | ||
139 | }) | 142 | }) | ||
140 | 143 | | |||
141 | showWakeUps = (index === 0) | 144 | showWakeUps = (index === 0) | ||
142 | } | 145 | } | ||
143 | 146 | | |||
▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Line(s) | 398 | delegate: Kirigami.FormLayout { | |||
423 | Repeater { | 426 | Repeater { | ||
424 | id: detailsRepeater | 427 | id: detailsRepeater | ||
425 | model: modelData.data || [] | 428 | model: modelData.data || [] | ||
426 | 429 | | |||
427 | QQC2.Label { | 430 | QQC2.Label { | ||
428 | id: valueLabel | 431 | id: valueLabel | ||
429 | Kirigami.FormData.label: i18n("%1:", modelData.label) | 432 | Kirigami.FormData.label: i18n("%1:", modelData.label) | ||
430 | text: { | 433 | text: { | ||
431 | var value = currentBattery[modelData.value] | 434 | var value; | ||
435 | if (modelData.source) { | ||||
436 | if (modelData.source == "vendor") { | ||||
437 | value = currentVendor; | ||||
438 | } else { | ||||
439 | value = currentProduct; | ||||
440 | } | ||||
441 | } else { | ||||
442 | value = currentBattery[modelData.value] | ||||
443 | } | ||||
432 | 444 | | |||
433 | if (typeof value === "boolean") { | 445 | if (typeof value === "boolean") { | ||
434 | if (value) { | 446 | if (value) { | ||
435 | return i18n("Yes") | 447 | return i18n("Yes") | ||
436 | } else { | 448 | } else { | ||
437 | return i18n("No") | 449 | return i18n("No") | ||
438 | } | 450 | } | ||
439 | } | 451 | } | ||
Show All 28 Lines |