Changeset View
Changeset View
Standalone View
Standalone View
applets/weather/package/contents/ui/DisplayUnits.qml
- This file was added.
1 | import QtQuick 2.0 | ||||
---|---|---|---|---|---|
2 | | ||||
3 | QtObject { | ||||
4 | // https://doc.qt.io/qt-5/qml-qtqml-locale.html#measurementSystem-prop | ||||
5 | readonly property bool localeUsesMetric: Qt.locale().measurementSystem == Locale.MetricSystem | ||||
6 | | ||||
7 | readonly property int temperatureUnitId: { | ||||
8 | if (plasmoid.configuration.temperatureUnitId === 0) { // Use locale default | ||||
9 | if (localeUsesMetric) { | ||||
10 | return 6001 // Celcius | ||||
11 | } else { | ||||
12 | return 6002 // Fahrenheit | ||||
13 | } | ||||
14 | } else { | ||||
15 | return plasmoid.configuration.temperatureUnitId | ||||
16 | } | ||||
17 | } | ||||
18 | readonly property int speedUnitId: { | ||||
19 | if (plasmoid.configuration.speedUnitId === 0) { // Use locale default | ||||
20 | if (localeUsesMetric) { | ||||
21 | return 9000 // MeterPerSecond | ||||
22 | } else { | ||||
23 | return 9002 // MilePerHour | ||||
24 | } | ||||
25 | } else { | ||||
26 | return plasmoid.configuration.speedUnitId | ||||
27 | } | ||||
28 | } | ||||
29 | readonly property int pressureUnitId: { | ||||
30 | if (plasmoid.configuration.pressureUnitId === 0) { // Use locale default | ||||
31 | if (localeUsesMetric) { | ||||
32 | return 5008 // Hectopascal | ||||
33 | } else { | ||||
34 | return 5028 // InchesOfMercury | ||||
35 | } | ||||
36 | } else { | ||||
37 | return plasmoid.configuration.pressureUnitId | ||||
38 | } | ||||
39 | } | ||||
40 | readonly property int visibilityUnitId: { | ||||
41 | if (plasmoid.configuration.visibilityUnitId === 0) { // Use locale default | ||||
42 | if (localeUsesMetric) { | ||||
43 | return 2007 // Kilometer | ||||
44 | } else { | ||||
45 | return 2024 // Mile | ||||
46 | } | ||||
47 | } else { | ||||
48 | return plasmoid.configuration.visibilityUnitId | ||||
49 | } | ||||
50 | } | ||||
51 | } |