aboutsummaryrefslogtreecommitdiff
path: root/quickshell/items/Spin.qml
blob: 72e61055a0fb891b11161289e8f9c969da4ed75b (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
import QtQuick
import QtQuick.Layouts

RowLayout {
  spacing: 0
  Text {
    text: " Spin:"
    color: shellRoot.white
    font {
      family: shellRoot.fontFamily
      pixelSize: shellRoot.fontSize
    }
  }
  Text {
    property var formatMode: "HH:mm:ss"

    id: clock
    text: Qt.formatDateTime(new Date(), clock.formatMode)
    color: shellRoot.purple
    font {
      family: shellRoot.fontFamily
      pixelSize: shellRoot.fontSize
      bold: true
    }

    Timer {
      interval: 1000
      running: true
      repeat: true
      onTriggered: clock.text = Qt.formatDateTime(new Date(), clock.formatMode)
    }

    MouseArea {
      anchors.fill: parent
      onClicked: {
        if (clock.formatMode === "HH:mm:ss") {
          clock.formatMode = "yyyy/MM/dd, dddd"
        } else {
          clock.formatMode = "HH:mm:ss"
        }
        clock.text = Qt.formatDateTime(new Date(), clock.formatMode)
      }
    }
  }
}