From 3e5440a3e1d4f23180b8e6795ae1c29f9964379d Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sat, 25 Aug 2012 21:56:47 +0200 Subject: bumping to 0.4.2 --- qmapwatchlet/compass-metawatch-digital.qml | 75 ++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 8 deletions(-) (limited to 'qmapwatchlet/compass-metawatch-digital.qml') 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
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 + } + } } } } -- cgit v1.2.3