From 6c47b43925977fd203b82140bc1e6fd46765aecf Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 12 Jul 2025 23:06:50 +0800 Subject: timedate --- bar/Bar.qml | 6 +++++- bar/TimeDate.qml | 27 +++++++++++++++++++++++++++ services/TimeDate.qml | 15 +++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 bar/TimeDate.qml create mode 100644 services/TimeDate.qml 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 + } +} -- cgit v1.2.3