-
Notifications
You must be signed in to change notification settings - Fork 1
/
TimeCodeText.qml
34 lines (29 loc) · 894 Bytes
/
TimeCodeText.qml
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
import QtQuick
import QtQuick.Controls
import org.tal
Label {
id: timeCodeText
property CameraDevice camera;
signal clicked();
signal doubleClicked();
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: camera.connectionReady ? formatTimecode(camera.timecode) : '--:--:--.--'
font.family: "Courier"
font.bold: true
font.pixelSize: 24
function formatTimecode(tc) {
let h=tc.getHours();
let m=tc.getMinutes();
let s=tc.getSeconds();
let f=tc.getMilliseconds();
let tcs=(h<10 ? '0'+h : h)+':'+(m<10 ? '0'+m : m)+':'+(s<10 ? '0'+s : s)+'.'+(f<10 ? '0'+f : f)
return tcs;
}
// Layout.alignment: Qt.AlignRight
MouseArea {
anchors.fill: parent
onClicked: timeCodeText.clicked()
onDoubleClicked: timeCodeText.doubleClicked()
}
}