Changeset View
Changeset View
Standalone View
Standalone View
Modules/energy/package/contents/ui/main.qml
| Show All 10 Lines | |||||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
| 12 | * GNU General Public License for more details. * | 12 | * GNU General Public License for more details. * | ||
| 13 | * * | 13 | * * | ||
| 14 | * You should have received a copy of the GNU General Public License * | 14 | * You should have received a copy of the GNU General Public License * | ||
| 15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
| 16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
| 18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
| 19 | 19 | | |||
| 20 | import QtQuick 2.2 | 20 | import QtQuick 2.5 | ||
broulik: and also getting rid of QQC1 | |||||
| 21 | import QtQuick.Controls 1.3 | 21 | import QtQuick.Controls 2.5 | ||
I might be too aggressive here, what would be the best version to set here ? meven: I might be too aggressive here, what would be the best version to set here ? | |||||
ngraham: 2.5 is always a safe bet. | |||||
| 22 | import QtQuick.Controls 2.0 as QQC2 | | |||
| 23 | import QtQuick.Layouts 1.1 | 22 | import QtQuick.Layouts 1.1 | ||
| 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 | //We need units from it | | |||
| 29 | import org.kde.plasma.core 2.0 as PlasmaCore | 28 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
broulik: A goal is to get rid of these plasma imports, too | |||||
Now that you've imported Kirigami, you can use Kirigami.Units and drop the PlasmaCore import filipf: Now that you've imported Kirigami, you can use Kirigami.Units and drop the PlasmaCore import | |||||
| 30 | import org.kde.plasma.extras 2.0 as PlasmaExtras | | |||
| 31 | 29 | | |||
| 32 | import org.kde.plasma.workspace.components 2.0 as WorkspaceComponents | 30 | import org.kde.plasma.workspace.components 2.0 as WorkspaceComponents | ||
| 31 | import org.kde.kcm 1.1 as KCM | ||||
| 33 | 32 | | |||
| 34 | Item { | 33 | KCM.SimpleKCM { | ||
| 35 | id: root | 34 | id: root | ||
| 35 | | ||||
| 36 | KCM.ConfigModule.quickHelp: i18n("This module lets you see energy information and statistics.") | ||||
| 37 | | ||||
| 36 | property QtObject currentBattery: null | 38 | property QtObject currentBattery: null | ||
| 37 | property string currentUdi: "" | 39 | property string currentUdi: "" | ||
| 38 | property bool compact: (root.width / units.gridUnit) < 25 | 40 | property bool compact: (root.width / units.gridUnit) < 25 | ||
| 39 | 41 | | |||
| 40 | onCurrentBatteryChanged: { | 42 | onCurrentBatteryChanged: { | ||
| 41 | if (!currentBattery) { | 43 | if (!currentBattery) { | ||
| 42 | currentBattery = kcm.batteries.get(0) | 44 | currentBattery = kcm.batteries.get(0) | ||
| 43 | currentUdi = kcm.batteries.udi(0) | 45 | currentUdi = kcm.batteries.udi(0) | ||
| 44 | } | 46 | } | ||
| 45 | } | 47 | } | ||
| 46 | 48 | | |||
| 47 | SystemPalette { id: sysPal; colorGroup: SystemPalette.Active } | | |||
| 48 | | ||||
| 49 | property bool showWakeUps: true | 49 | property bool showWakeUps: true | ||
filipf: there is trailing space in this row | |||||
| 50 | property int historyType: HistoryModel.ChargeType | 50 | property int historyType: HistoryModel.ChargeType | ||
| 51 | 51 | | |||
| 52 | readonly property var details: [ | 52 | readonly property var details: [ | ||
| 53 | { | 53 | { | ||
| 54 | title: i18n("Battery"), | 54 | title: i18n("Battery"), | ||
| 55 | data: [ | 55 | data: [ | ||
| 56 | {label: i18n("Rechargeable"), value: "rechargeable"}, | 56 | {label: i18n("Rechargeable"), value: "rechargeable"}, | ||
| 57 | {label: i18n("Charge state"), value: "chargeState", modifier: "chargeState"} | 57 | {label: i18n("Charge state"), value: "chargeState", modifier: "chargeState"} | ||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 93 | function modifier_chargeState(value) { | |||
| 99 | } | 99 | } | ||
| 100 | } | 100 | } | ||
| 101 | 101 | | |||
| 102 | Component.onCompleted: { | 102 | Component.onCompleted: { | ||
| 103 | currentBattery = kcm.batteries.get(0) | 103 | currentBattery = kcm.batteries.get(0) | ||
| 104 | currentUdi = kcm.batteries.udi(0) | 104 | currentUdi = kcm.batteries.udi(0) | ||
| 105 | } | 105 | } | ||
| 106 | 106 | | |||
| 107 | implicitWidth: units.gridUnit * 25 | 107 | implicitWidth: units.gridUnit * 30 | ||
| 108 | implicitHeight: !!currentBattery ? units.gridUnit * 25 : units.gridUnit * 12 | 108 | implicitHeight: !!currentBattery ? units.gridUnit * 30 : units.gridUnit * 12 | ||
| 109 | 109 | | |||
| 110 | SystemPalette { | 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 | id: syspal | 111 | readonly property var timespanComboDurations: [3600, 7200, 43200, 86400, 172800, 604800] | ||
| 112 | } | | |||
| 113 | | ||||
| 114 | ScrollView { | | |||
| 115 | id: scrollView | | |||
| 116 | anchors.fill: parent | | |||
| 117 | | ||||
| 118 | horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff | | |||
| 119 | 112 | | |||
| 120 | ColumnLayout { | 113 | ColumnLayout { | ||
| 121 | id: column | 114 | id: column | ||
| 122 | | ||||
| 123 | width: scrollView.viewport.width | | |||
| 124 | spacing: units.largeSpacing | | |||
| 125 | | ||||
| 126 | ScrollView { | 115 | ScrollView { | ||
| 127 | id: tabView | 116 | id: tabView | ||
| 128 | Layout.fillWidth: true | 117 | Layout.fillWidth: true | ||
| 129 | Layout.minimumHeight: units.gridUnit * 3 | 118 | Layout.minimumHeight: units.gridUnit * 3 | ||
| 130 | Layout.maximumHeight: Layout.minimumHeight | 119 | Layout.maximumHeight: Layout.minimumHeight | ||
| 131 | | ||||
| 132 | frameVisible: true | | |||
| 133 | visible: kcm.batteries.count > 1 | 120 | visible: kcm.batteries.count > 1 | ||
| 134 | 121 | | |||
| 135 | verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff | | |||
| 136 | | ||||
| 137 | Row { | 122 | Row { | ||
| 123 | spacing: Kirigami.Units.smallSpacing | ||||
| 138 | Repeater { | 124 | Repeater { | ||
| 139 | model: kcm.batteries | 125 | model: kcm.batteries | ||
| 140 | 126 | | |||
| 141 | Button { | 127 | Button { | ||
| 142 | id: button | 128 | id: button | ||
| 143 | width: height | 129 | width: height | ||
| 144 | height: tabView.viewport.height | 130 | height: tabView.height | ||
| 145 | checked: model.battery == root.currentBattery | 131 | checked: model.battery == root.currentBattery | ||
| 146 | checkable: true | 132 | checkable: true | ||
| 147 | onClicked: { | 133 | onClicked: { | ||
| 148 | root.currentUdi = model.udi | 134 | root.currentUdi = model.udi | ||
| 149 | root.currentBattery = model.battery | 135 | root.currentBattery = model.battery | ||
| 150 | // override checked property | 136 | // override checked property | ||
| 151 | checked = Qt.binding(function() { | 137 | checked = Qt.binding(function() { | ||
| 152 | return model.battery == root.currentBattery | 138 | return model.battery == root.currentBattery | ||
| Show All 26 Lines | 155 | batteryType: { | |||
| 179 | } | 165 | } | ||
| 180 | } | 166 | } | ||
| 181 | percent: model.battery.chargePercent | 167 | percent: model.battery.chargePercent | ||
| 182 | //pluggedIn: model.battery.chargeState === 1 // Makes it hard to see | 168 | //pluggedIn: model.battery.chargeState === 1 // Makes it hard to see | ||
| 183 | } | 169 | } | ||
| 184 | 170 | | |||
| 185 | ProgressBar { // TODO make progress bar not eat mouse events | 171 | ProgressBar { // TODO make progress bar not eat mouse events | ||
| 186 | Layout.fillWidth: true | 172 | Layout.fillWidth: true | ||
| 187 | minimumValue: 0 | 173 | from: 0 | ||
| 188 | maximumValue: 100 | 174 | to: 100 | ||
| 189 | value: model.battery.chargePercent | 175 | value: model.battery.chargePercent | ||
| 190 | enabled: button.checked ? false : true | 176 | enabled: button.checked ? false : true | ||
| 191 | } | 177 | } | ||
| 192 | } | 178 | } | ||
| 193 | } | 179 | } | ||
| 194 | } | 180 | } | ||
| 195 | } | 181 | } | ||
| 196 | } | 182 | } | ||
| Show All 30 Lines | 189 | GridLayout { | |||
| 227 | 213 | | |||
| 228 | Item { | 214 | Item { | ||
| 229 | Layout.fillWidth: true | 215 | Layout.fillWidth: true | ||
| 230 | } | 216 | } | ||
| 231 | 217 | | |||
| 232 | ComboBox { | 218 | ComboBox { | ||
| 233 | id: timespanCombo | 219 | id: timespanCombo | ||
| 234 | Layout.minimumWidth: units.gridUnit * 6 | 220 | Layout.minimumWidth: units.gridUnit * 6 | ||
| 235 | model: [ | 221 | model: timespanComboChoices | ||
| 236 | {text: i18n("Last hour"), value: 3600}, | | |||
| 237 | {text: i18n("Last 2 hours"), value: 7200}, | | |||
| 238 | {text: i18n("Last 12 hours"), value: 43200}, | | |||
| 239 | {text: i18n("Last 24 hours"), value: 86400}, | | |||
| 240 | {text: i18n("Last 48 hours"), value: 172800}, | | |||
| 241 | {text: i18n("Last 7 days"), value: 604800} | | |||
| 242 | ] | | |||
| 243 | Accessible.name: i18n("Timespan") | 222 | Accessible.name: i18n("Timespan") | ||
| 244 | Accessible.description: i18n("Timespan of data to display") | 223 | Accessible.description: i18n("Timespan of data to display") | ||
| 245 | } | 224 | } | ||
| 246 | 225 | | |||
| 247 | Button { | 226 | Button { | ||
| 248 | iconName: "view-refresh" | 227 | icon.name: "view-refresh" | ||
| 249 | tooltip: i18n("Refresh") | 228 | hoverEnabled: true | ||
| 250 | Accessible.name: tooltip | 229 | ToolTip.text: i18n("Refresh") | ||
| 230 | ToolTip.visible: hovered | ||||
| 231 | ToolTip.delay: Kirigami.Units.toolTipDelay | ||||
| 232 | Accessible.name: ToolTip.text | ||||
| 251 | onClicked: history.refresh() | 233 | onClicked: history.refresh() | ||
| 252 | } | 234 | } | ||
| 253 | } | 235 | } | ||
| 254 | 236 | | |||
| 255 | HistoryModel { | 237 | HistoryModel { | ||
| 256 | id: history | 238 | id: history | ||
| 257 | duration: timespanCombo.model[timespanCombo.currentIndex].value | 239 | duration: timespanComboDurations[timespanCombo.currentIndex] | ||
| 258 | device: currentUdi | 240 | device: currentUdi | ||
| 259 | type: root.historyType | 241 | type: root.historyType | ||
| 260 | } | 242 | } | ||
| 261 | 243 | | |||
| 262 | Graph { | 244 | Graph { | ||
| 263 | id: graph | 245 | id: graph | ||
| 264 | Layout.fillWidth: true | 246 | Layout.fillWidth: true | ||
| 265 | Layout.minimumHeight: column.width / 3 | 247 | Layout.minimumHeight: column.width / 3 | ||
| 266 | Layout.maximumHeight: column.width / 3 | 248 | Layout.maximumHeight: column.width / 3 | ||
| 249 | Layout.topMargin: units.largeSpacing | ||||
| 250 | | ||||
| 267 | data: history.points | 251 | data: history.points | ||
| 268 | 252 | | |||
| 269 | xMin: history.firstDataPointTime | 253 | xMin: history.firstDataPointTime | ||
| 270 | xMax: history.lastDataPointTime | 254 | xMax: history.lastDataPointTime | ||
| 271 | 255 | | |||
| 272 | yUnits: root.historyType == HistoryModel.RateType ? i18nc("Shorthand for Watts","W") : i18nc("literal percent sign","%") | 256 | yUnits: root.historyType == HistoryModel.RateType ? i18nc("Shorthand for Watts","W") : i18nc("literal percent sign","%") | ||
| 273 | yMax: { | 257 | yMax: { | ||
| 274 | if (root.historyType == HistoryModel.RateType) { | 258 | if (root.historyType == HistoryModel.RateType) { | ||
| 275 | var max = history.largestValue | 259 | var max = history.largestValue | ||
| 276 | var modulo = max % 10 | 260 | var modulo = max % 10 | ||
| 277 | if (modulo > 0) { | 261 | if (modulo > 0) { | ||
| 278 | max = max - modulo + 10 // ceil to nearest 10s | 262 | max = max - modulo + 10 // ceil to nearest 10s | ||
| 279 | } | 263 | } | ||
| 280 | return max; | 264 | return max; | ||
| 281 | } else { | 265 | } else { | ||
| 282 | return 100; | 266 | return 100; | ||
| 283 | } | 267 | } | ||
| 284 | } | 268 | } | ||
| 285 | yStep: root.historyType == HistoryModel.RateType ? 10 : 20 | 269 | yStep: root.historyType == HistoryModel.RateType ? 10 : 20 | ||
| 286 | visible: history.count > 1 | 270 | visible: history.count > 1 | ||
| 287 | } | 271 | } | ||
| 288 | 272 | | |||
| 289 | QQC2.Label { | 273 | Kirigami.InlineMessage { | ||
| 290 | Layout.fillWidth: true | 274 | Layout.fillWidth: true | ||
| 291 | Layout.minimumHeight: column.width / 3 | 275 | Layout.topMargin: units.smallSpacing | ||
| 292 | Layout.maximumHeight: column.width / 3 | 276 | showCloseButton: true | ||
| 293 | horizontalAlignment: Text.AlignHCenter | | |||
| 294 | verticalAlignment: Text.AlignVCenter | | |||
| 295 | text: i18n("This type of history is currently not available for this device.") | 277 | text: i18n("This type of history is currently not available for this device.") | ||
| 296 | wrapMode: Text.WordWrap | | |||
| 297 | visible: !graph.visible | 278 | visible: !graph.visible | ||
| 298 | } | 279 | } | ||
| 299 | } | 280 | } | ||
| 300 | 281 | | |||
| 301 | ColumnLayout { | 282 | ColumnLayout { | ||
| 302 | Layout.fillWidth: true | 283 | Layout.fillWidth: true | ||
| 303 | spacing: units.smallSpacing | 284 | spacing: units.smallSpacing | ||
| 304 | visible: showWakeUps && kcm.wakeUps.count > 0 | 285 | visible: showWakeUps && kcm.wakeUps.count > 0 | ||
| 305 | 286 | | |||
| 306 | RowLayout { | 287 | RowLayout { | ||
| 307 | Layout.fillWidth: true | 288 | Layout.fillWidth: true | ||
| 308 | PlasmaExtras.Heading { | 289 | Kirigami.Heading { | ||
| 309 | Layout.fillWidth: true | 290 | Layout.fillWidth: true | ||
| 310 | Layout.columnSpan: 2 | 291 | Layout.columnSpan: 2 | ||
| 311 | color: sysPal.text | | |||
| 312 | level: 4 | 292 | level: 4 | ||
| 313 | text: i18n("Application Energy Consumption") | 293 | text: i18n("Application Energy Consumption") | ||
| 314 | } | 294 | } | ||
| 315 | } | 295 | } | ||
| 316 | 296 | | |||
| 317 | GridLayout { | 297 | GridLayout { | ||
| 318 | id: wakeUpsGrid | 298 | id: wakeUpsGrid | ||
| 319 | Layout.fillWidth: true | 299 | Layout.fillWidth: true | ||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 332 | RowLayout { | |||
| 361 | 341 | | |||
| 362 | ColumnLayout { | 342 | ColumnLayout { | ||
| 363 | Layout.fillWidth: true | 343 | Layout.fillWidth: true | ||
| 364 | spacing: 0 | 344 | spacing: 0 | ||
| 365 | 345 | | |||
| 366 | RowLayout { | 346 | RowLayout { | ||
| 367 | Layout.fillWidth: true | 347 | Layout.fillWidth: true | ||
| 368 | 348 | | |||
| 369 | QQC2.Label { | 349 | Label { | ||
| 370 | Layout.fillWidth: true | 350 | Layout.fillWidth: true | ||
| 371 | elide: Text.ElideRight | 351 | elide: Text.ElideRight | ||
| 372 | text: model.prettyName || model.name | 352 | text: model.prettyName || model.name | ||
| 373 | } | 353 | } | ||
| 374 | 354 | | |||
| 375 | /*Label { | 355 | /*Label { | ||
| 376 | text: i18n("System Service") | 356 | text: i18n("System Service") | ||
| 377 | visible: !model.userSpace | 357 | visible: !model.userSpace | ||
| 378 | opacity: 0.6 | 358 | opacity: 0.6 | ||
| 379 | }*/ | 359 | }*/ | ||
| 380 | } | 360 | } | ||
| 381 | 361 | | |||
| 382 | ProgressBar { | 362 | ProgressBar { | ||
| 383 | Layout.fillWidth: true | 363 | Layout.fillWidth: true | ||
| 384 | minimumValue: 0 | 364 | from: 0 | ||
| 385 | maximumValue: 100 | 365 | to: 100 | ||
| 386 | value: model.wakeUps / kcm.wakeUps.total * 100 | 366 | value: model.wakeUps / kcm.wakeUps.total * 100 | ||
| 387 | } | 367 | } | ||
| 388 | } | 368 | } | ||
| 389 | } | 369 | } | ||
| 390 | } | 370 | } | ||
| 391 | } | 371 | } | ||
| 392 | } | 372 | } | ||
| 393 | } | 373 | } | ||
| 394 | 374 | | |||
| 395 | Rectangle { | 375 | Rectangle { | ||
| 396 | Layout.fillWidth: true | 376 | Layout.fillWidth: true | ||
| 397 | height: 1 | 377 | height: 1 | ||
| 398 | color: "#ccc" // FIXME palette | 378 | color: Kirigami.Theme.textColor // FIXME palette | ||
| 399 | //Layout.topMargin: (compact ? units.gridUnit * 2 : 0) | 379 | //Layout.topMargin: (compact ? units.gridUnit * 2 : 0) | ||
| 400 | visible: wakeUpsGrid.visible | 380 | visible: wakeUpsGrid.visible | ||
| 401 | } | 381 | } | ||
| 402 | 382 | | |||
| 403 | ColumnLayout { | 383 | ColumnLayout { | ||
| 404 | id: detailsColumn | 384 | id: detailsColumn | ||
| 405 | property int legendWidth: 10 | 385 | spacing: 0 | ||
| 406 | 386 | | |||
| 407 | Layout.fillWidth: true | 387 | Layout.fillWidth: true | ||
| 408 | spacing: 0 | | |||
| 409 | visible: !!currentBattery | 388 | visible: !!currentBattery | ||
| 410 | 389 | | |||
| 411 | Repeater { | 390 | Repeater { | ||
| 391 | id: titleRepeater | ||||
| 412 | model: root.details | 392 | model: root.details | ||
| 393 | property list<Kirigami.FormLayout> layouts | ||||
| 413 | 394 | | |||
| 414 | ColumnLayout { | 395 | delegate: Kirigami.FormLayout { | ||
| 415 | spacing: 0//units.smallSpacing | 396 | id: currentLayout | ||
| 416 | 397 | | |||
| 417 | PlasmaExtras.Heading { | 398 | Component.onCompleted: { | ||
| 418 | level: 4 | 399 | // ensure that all visible FormLayout share the same set of twinFormLayouts | ||
| 419 | color: sysPal.text | 400 | titleRepeater.layouts.push(currentLayout); | ||
| 401 | for (var i = 0, length = titleRepeater.layouts.length; i < length; ++i) { | ||||
| 402 | titleRepeater.layouts[i].twinFormLayouts = titleRepeater.layouts; | ||||
| 403 | } | ||||
| 404 | } | ||||
| 405 | | ||||
| 406 | Kirigami.Heading { | ||||
| 420 | text: modelData.title | 407 | text: modelData.title | ||
| 408 | Kirigami.FormData.isSection: true | ||||
| 409 | level: 2 | ||||
| 421 | // HACK hide section header if all labels are invisible | 410 | // HACK hide section header if all labels are invisible | ||
| 422 | visible: { | 411 | visible: { | ||
| 423 | for (var i = 0, length = detailsRepeater.count; i < length; ++i) { | 412 | for (var i = 0, length = detailsRepeater.count; i < length; ++i) { | ||
| 424 | var item = detailsRepeater.itemAt(i) | 413 | var item = detailsRepeater.itemAt(i) | ||
| 425 | if (item && item.visible) { | 414 | if (item && item.visible) { | ||
| 426 | return true | 415 | return true | ||
| 427 | } | 416 | } | ||
| 428 | } | 417 | } | ||
| 429 | 418 | | |||
| 430 | return false | 419 | return false | ||
| 431 | } | 420 | } | ||
| 432 | } | 421 | } | ||
| 433 | 422 | | |||
| 434 | Repeater { | 423 | Repeater { | ||
| 435 | id: detailsRepeater | 424 | id: detailsRepeater | ||
| 436 | model: modelData.data || [] | 425 | model: modelData.data || [] | ||
| 437 | 426 | | |||
| 438 | RowLayout { | 427 | Label { | ||
| 439 | Layout.fillWidth: true | | |||
| 440 | spacing: units.smallSpacing * 2 | | |||
| 441 | visible: valueLabel.text !== "" | | |||
| 442 | | ||||
| 443 | QQC2.Label { | | |||
| 444 | Layout.minimumWidth: detailsColumn.legendWidth + units.gridUnit | | |||
| 445 | horizontalAlignment: Text.AlignRight | | |||
| 446 | text: i18n("%1:", modelData.label) | | |||
| 447 | wrapMode: Text.NoWrap | | |||
| 448 | opacity: 0.8 | | |||
| 449 | onPaintedWidthChanged: { | | |||
| 450 | if (paintedWidth > detailsColumn.legendWidth) { | | |||
| 451 | detailsColumn.legendWidth = paintedWidth | | |||
| 452 | } | | |||
| 453 | } | | |||
| 454 | } | | |||
| 455 | | ||||
| 456 | QQC2.Label { | | |||
| 457 | id: valueLabel | 428 | id: valueLabel | ||
| 458 | Layout.fillWidth: true | 429 | Kirigami.FormData.label: i18n("%1:", modelData.label) | ||
| 459 | text: { | 430 | text: { | ||
| 460 | var value = currentBattery[modelData.value] | 431 | var value = currentBattery[modelData.value] | ||
| 461 | 432 | | |||
| 462 | if (typeof value === "boolean") { | 433 | if (typeof value === "boolean") { | ||
| 463 | if (value) { | 434 | if (value) { | ||
| 464 | return i18n("Yes") | 435 | return i18n("Yes") | ||
| 465 | } else { | 436 | } else { | ||
| 466 | return i18n("No") | 437 | return i18n("No") | ||
| 467 | } | 438 | } | ||
| 468 | } | 439 | } | ||
| 469 | 440 | | |||
| 470 | if (!value) { | 441 | if (!value) { | ||
filipf: trailing space her as well, as well as in the preceding row | |||||
| 471 | return "" | 442 | return "" | ||
| 472 | } | 443 | } | ||
broulik: Shouldn't be neccessary as it's `QQC2.Label` | |||||
For breeze dark this makes the label, dark gray on a dark background. See before screenshot. Could it be a breeze dark bug ? meven: For breeze dark this makes the label, dark gray on a dark background. See before screenshot. | |||||
| 473 | 444 | | |||
| 474 | var precision = modelData.precision | 445 | var precision = modelData.precision | ||
| 475 | if (typeof precision === "number") { // round to decimals | 446 | if (typeof precision === "number") { // round to decimals | ||
| 476 | value = Number(value).toLocaleString(Qt.locale(), "f", precision) | 447 | value = Number(value).toLocaleString(Qt.locale(), "f", precision) | ||
| 477 | } | 448 | } | ||
| 478 | 449 | | |||
| 479 | if (modelData.modifier && root["modifier_" + modelData.modifier]) { | 450 | if (modelData.modifier && root["modifier_" + modelData.modifier]) { | ||
| 480 | value = root["modifier_" + modelData.modifier](value) | 451 | value = root["modifier_" + modelData.modifier](value) | ||
| 481 | } | 452 | } | ||
| 482 | 453 | | |||
| 483 | if (modelData.unit) { | 454 | if (modelData.unit) { | ||
| 484 | value = i18nc("%1 is value, %2 is unit", "%1 %2", value, modelData.unit) | 455 | value = i18nc("%1 is value, %2 is unit", "%1 %2", value, modelData.unit) | ||
| 485 | } | 456 | } | ||
| 486 | 457 | | |||
| 487 | return value | 458 | return value | ||
| 488 | } | 459 | } | ||
| 489 | } | 460 | visible: valueLabel.text !== "" | ||
| 490 | } | | |||
| 491 | } | 461 | } | ||
| 492 | } | 462 | } | ||
| 493 | } | 463 | } | ||
| 494 | } | 464 | } | ||
| 495 | } | 465 | } | ||
| 496 | } | 466 | } | ||
| 497 | } | 467 | } | ||
and also getting rid of QQC1