summaryrefslogtreecommitdiffstats
path: root/src/Clock.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/Clock.qml')
-rw-r--r--src/Clock.qml32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Clock.qml b/src/Clock.qml
new file mode 100644
index 0000000..73417e8
--- /dev/null
+++ b/src/Clock.qml
@@ -0,0 +1,32 @@
+import QtQuick 2.0
+
+Text {
+ id: clock
+
+ property real fontSize: parent.height * 0.05
+ property real fontScale: 0.5
+ property color textColor: parent.textColor != undefined ? parent.textColor : "black"
+ property string fontFamily: parent.fontFamily != undefined ? parent.fontFamily : "Helvetica"
+
+ text: currentTime();
+
+ function currentTime() {
+ var d = new Date();
+ return d.getHours() + ":" + d.getMinutes();
+ }
+
+ color: textColor;
+ font.family: fontFamily;
+ font.pixelSize: fontSize * fontScale;
+
+ anchors.bottom: parent.bottom;
+ anchors.left: parent.left;
+ anchors.margins: font.pixelSize;
+
+ Timer {
+ interval: 60000;
+ repeat: true;
+ running: true
+ onTriggered: clock.text = clock.currentTime();
+ }
+}