summaryrefslogtreecommitdiff
path: root/qmapwatchlet/compass-metawatch-digital.qml
blob: c465e209e90c7ce56481a9fc57809feeb9f40760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import QtQuick 1.0
import QtMobility.location 1.2
import com.javispedro.sowatch.metawatch 1.0
import com.javispedro.sowatch.qmap 1.0

MWPage {

	function formatSpeed(speed) {
		var kmh = speed * 3.6;
		if (kmh < 0) {
			return "";
		} else if (kmh < 10) {
			return kmh.toFixed(1) + " km/h";
		} else {
			return kmh.toFixed(0) + " km/h";
		}
	}

	Column {
		anchors.top: parent.top
		width: parent.width

		CompassView {
			anchors.horizontalCenter: parent.horizontalCenter
			id: compass
			updateEnabled: watch.active
			updateInterval: 3000
			width: 48
			height: 48
		}

		Row {
			MWLabel {
				text: qsTr("Speed") + " "
			}
			MWLabel {
				id: speedLabel
				text: formatSpeed(compass.currentSpeed)
			}
		}
	}
}