summaryrefslogtreecommitdiff
path: root/qmapwatchlet/compass-metawatch-digital.qml
diff options
context:
space:
mode:
Diffstat (limited to 'qmapwatchlet/compass-metawatch-digital.qml')
-rw-r--r--qmapwatchlet/compass-metawatch-digital.qml75
1 files changed, 67 insertions, 8 deletions
diff --git a/qmapwatchlet/compass-metawatch-digital.qml b/qmapwatchlet/compass-metawatch-digital.qml
index c465e20..37d6e11 100644
--- a/qmapwatchlet/compass-metawatch-digital.qml
+++ b/qmapwatchlet/compass-metawatch-digital.qml
@@ -4,15 +4,24 @@ import com.javispedro.sowatch.metawatch 1.0
import com.javispedro.sowatch.qmap 1.0
MWPage {
+ id: page
function formatSpeed(speed) {
var kmh = speed * 3.6;
- if (kmh < 0) {
+ if (kmh < 0 || isNaN(kmh)) {
return "";
} else if (kmh < 10) {
- return kmh.toFixed(1) + " km/h";
+ return kmh.toFixed(1);
} else {
- return kmh.toFixed(0) + " km/h";
+ return kmh.toFixed(0);
+ }
+ }
+
+ function formatAltitude(alt) {
+ if (isNaN(alt)) {
+ return "";
+ } else {
+ return alt.toFixed(0);
}
}
@@ -20,6 +29,13 @@ MWPage {
anchors.top: parent.top
width: parent.width
+ spacing: 2
+
+ MWTitle {
+ text: qsTr("Compass")
+ icon.source: "compass-icon.png"
+ }
+
CompassView {
anchors.horizontalCenter: parent.horizontalCenter
id: compass
@@ -30,12 +46,55 @@ MWPage {
}
Row {
- MWLabel {
- text: qsTr("Speed") + " "
+ Column {
+ width: page.width / 2
+ id: speedColumn
+
+ MWLabel {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: qsTr("Speed")
+ }
+ Row {
+ anchors.horizontalCenter: parent.horizontalCenter
+ spacing: 2
+ MWLabel {
+ id: speedLabel
+ anchors.top: parent.top
+ text: formatSpeed(compass.currentSpeed)
+ font.pointSize: 12
+ }
+ MWLabel {
+ anchors.top: parent.top
+ text: altitudeLabel.text ? qsTr("km<br>h") : "";
+ font.family: "MetaWatch Small caps 8pt"
+ font.pointSize: 6
+ }
+ }
}
- MWLabel {
- id: speedLabel
- text: formatSpeed(compass.currentSpeed)
+ Column {
+ width: page.width / 2
+ id: altitudeColumn
+
+ MWLabel {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: qsTr("Altitude")
+ }
+ Row {
+ anchors.horizontalCenter: parent.horizontalCenter
+ spacing: 2
+ MWLabel {
+ id: altitudeLabel
+ anchors.top: parent.top
+ text: formatAltitude(compass.currentAltitude)
+ font.pointSize: 12
+ }
+ MWLabel {
+ anchors.top: parent.top
+ text: altitudeLabel.text ? qsTr("m") : "";
+ font.family: "MetaWatch Small caps 8pt"
+ font.pointSize: 6
+ }
+ }
}
}
}