summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-12 23:06:50 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-12 23:06:50 +0800
commit6c47b43925977fd203b82140bc1e6fd46765aecf (patch)
treedd70ec2ea96053ffa9929499a5dcae0c445f673c
parent9259c16c08d2875644f16a9fd6e9ae664d392e82 (diff)
timedate
-rw-r--r--bar/Bar.qml6
-rw-r--r--bar/TimeDate.qml27
-rw-r--r--services/TimeDate.qml15
3 files changed, 47 insertions, 1 deletions
diff --git a/bar/Bar.qml b/bar/Bar.qml
index 31d9c78..df4c081 100644
--- a/bar/Bar.qml
+++ b/bar/Bar.qml
@@ -1,7 +1,7 @@
import QtQuick
import Quickshell
import QtQuick.Layouts
-import qs.utils
+import qs.components
import qs.config
Scope {
@@ -76,6 +76,10 @@ Scope {
implicitWidth: (child.width - centerRow.width) / 2
implicitHeight: child.height
+ TimeDate {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
Network {
Layout.fillHeight: true
Layout.fillWidth: true
diff --git a/bar/TimeDate.qml b/bar/TimeDate.qml
new file mode 100644
index 0000000..93da141
--- /dev/null
+++ b/bar/TimeDate.qml
@@ -0,0 +1,27 @@
+import QtQuick
+import QtQuick.Layouts
+
+import qs.services as Services
+import qs.utils
+import qs.config as Config
+
+Item {
+ id: root
+ RowLayout {
+ Item {
+ Layout.fillWidth: true
+ }
+ anchors.fill: parent
+ spacing: Config.Bar.resourceIconTextSpacing
+
+ Icons {
+ text: Config.Icons.resource.clock
+ }
+ Text {
+ text: Services.TimeDate.time
+ }
+ Item {
+ Layout.fillWidth: true
+ }
+ }
+}
diff --git a/services/TimeDate.qml b/services/TimeDate.qml
new file mode 100644
index 0000000..ff9343b
--- /dev/null
+++ b/services/TimeDate.qml
@@ -0,0 +1,15 @@
+pragma Singleton
+
+import Quickshell
+import QtQuick
+
+Singleton {
+ id: root
+ readonly property string time: Qt.formatDateTime(clock.date, "hh:mm:ss")
+ readonly property string date: Qt.formatDateTime(clock.date, "dddd dd/MM")
+
+ SystemClock {
+ id: clock
+ precision: SystemClock.Seconds
+ }
+}