summaryrefslogtreecommitdiff
path: root/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml
blob: b5ad787d9159673d37839fc8f167d38b24dc2c56 (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
43
44
45
46
47
48
49
50
51
52
import Qt 4.7
import com.javispedro.sowatch 1.0

Rectangle {
	width: 96
	height: time.height + (title.visible ? 16 : 0)

	property alias text: title.text
	property alias font: title.font
	property alias icon: image

	clip: true

	Image {
		id: image
		anchors.top: time.bottom
		anchors.left: parent.left
	}

	MWLabel {
		id: title
		anchors.top: time.bottom
		anchors.left: image.right
		anchors.leftMargin: 2
		font.pixelSize: 16
		visible: text != ""
	}

	MWLabel {
		id: time
		anchors.right: parent.right
		anchors.rightMargin: 1
		anchors.top: parent.top
		height: 8
		font.family: "MetaWatch Large caps 8pt"
		font.pixelSize: 8
		text: "  :  "
	}

	function updateStatusBar() {
		var now = new Date
		time.text = Qt.formatDate(now, "ddd") + " " + Qt.formatTime(now)
	}

	Timer {
		triggeredOnStart: true
		interval: 100000
		repeat: true
		running: watch.active
		onTriggered: updateStatusBar()
	}
}