summaryrefslogtreecommitdiff
path: root/qmafwwatchlet/metawatch-digital.qml
blob: 02a5460e1a157b8de21f44379f318c74500ee413 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import QtQuick 1.0
import com.javispedro.sowatch.metawatch 1.0

Rectangle {
	width: 96
	height: 96

	color: "white"

	MWTitle {
		anchors.top: parent.top
		anchors.left: parent.left
		anchors.right: parent.right
		visible: mediaart.status != Image.Ready
		text: qsTr("Now playing")
		icon.source: "icon.png"
	}

	Image {
		id: mediaart
		anchors.fill: parent
		fillMode: Image.PreserveAspectFit
		smooth: true
		source: player.mediaArt
	}

	Rectangle {
		x: 0
		width: parent.width
		height: 14
		anchors.bottom: parent.bottom
		color: "white"

		MWLabel {
			anchors.fill: parent
			text: player.title.length > 0 ? player.title : qsTr("No media");
			color: "black"
		}
	}

	Rectangle {
		id: volumeBar
		width: 18

		anchors.top: parent.top
		anchors.bottom: parent.bottom
		anchors.right: parent.right

		color: "white"

		visible: false

		Image {
			id: volumeIcon
			anchors.top: parent.top
			anchors.left: parent.left
			anchors.leftMargin: 2

			source: "volume.png"
		}

		Rectangle {
			id: volumeBarBox

			anchors.top: volumeIcon.bottom
			anchors.left: parent.left
			anchors.right: parent.right
			anchors.bottom: parent.bottom
			anchors.leftMargin: 2

			color: "black"

			Rectangle {
				id: volumeBarThing

				anchors.left: parent.left
				anchors.right: parent.right
				anchors.bottom: parent.bottom
				anchors.margins: 4

				visible: volumeBar.visible
				height: (volumeControl.volume * (parent.height - anchors.margins*2)) / (volumeControl.max - volumeControl.min)

				color: "white"
			}
		}

		Timer {
			id: autoHideTimer
			interval: 3000
			repeat: false
			onTriggered: {
				volumeBar.visible = false;
			}
		}

		function show() {
			volumeBar.visible = true;
			autoHideTimer.restart();
		}
	}

	Connections {
		target: watch
		onButtonPressed : {
			switch(button) {
			case 1: {
				volumeControl.up();
				volumeBar.show();
				break;
			}
			case 2: {
				volumeControl.down();
				volumeBar.show();
				break;
			}
			case 4:
				player.playPause();
				break;
			case 5:
				player.next();
				break;
			}
		}
	}
}