From 5109ebe7179ced7107f4152e585423782ccb826b Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 16 Jul 2025 14:54:53 +0800 Subject: Resources: alt texts --- bar/TimeDate.qml | 112 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 35 deletions(-) (limited to 'bar/TimeDate.qml') diff --git a/bar/TimeDate.qml b/bar/TimeDate.qml index 5844aab..dddd71c 100644 --- a/bar/TimeDate.qml +++ b/bar/TimeDate.qml @@ -6,6 +6,9 @@ import qs.components import qs.config Item { + id: root + property bool isAlt: false + implicitWidth: container.implicitWidth implicitHeight: container.implicitHeight - General.rectMargin Rectangle { @@ -16,51 +19,90 @@ Item { horizontalCenter: parent.horizontalCenter } - implicitWidth: layout.implicitWidth + General.rectMargin * 2 + implicitWidth: !isAlt ? nonAlt.implicitWidth + General.rectMargin * 2 : alt.implicitWidth + General.rectMargin * 2 implicitHeight: Bar.height color: WallustColors.color4 radius: Style.rounding.large - RowLayout { - id: layout - Item { - Layout.fillWidth: true - } + Loader { + id: nonAlt anchors.fill: parent - spacing: Bar.resourceIconTextSpacing + active: !root.isAlt + sourceComponent: Component { + RowLayout { + Item { + Layout.fillWidth: true + } + anchors.fill: parent + spacing: Bar.resourceIconTextSpacing - Icon { - text: Icons.resource.clock - font.pixelSize: Style.font.size.larger - } - RowLayout { - property int h: Services.TimeDate.hours - property int m: Services.TimeDate.minutes - property int s: Services.TimeDate.seconds - spacing: 0 - IText { - animate: true - text: (parent.h >= 10 ? "" : "0") + parent.h - } - IText { - text: ":" - } - IText { - animate: true - text: (parent.m >= 10 ? "" : "0") + parent.m - } - IText { - text: ":" - } - IText { - animate: true - text: (parent.s >= 10 ? "" : "0") + parent.s + Icon { + text: Icons.resource.clock + font.pixelSize: Style.font.size.larger + } + RowLayout { + property int h: Services.TimeDate.hours + property int m: Services.TimeDate.minutes + property int s: Services.TimeDate.seconds + spacing: 0 + IText { + animate: true + text: (parent.h >= 10 ? "" : "0") + parent.h + } + IText { + text: ":" + } + IText { + animate: true + text: (parent.m >= 10 ? "" : "0") + parent.m + } + IText { + text: ":" + } + IText { + animate: true + text: (parent.s >= 10 ? "" : "0") + parent.s + } + } + Item { + Layout.fillWidth: true + } } } - Item { - Layout.fillWidth: true + } + Loader { + id: alt + anchors.fill: parent + active: root.isAlt + sourceComponent: Component { + RowLayout { + Item { + Layout.fillWidth: true + } + anchors.fill: parent + spacing: Bar.resourceIconTextSpacing + + Icon { + text: Icons.resource.calendar + font.pixelSize: Style.font.size.larger + } + IText { + animate: true + text: Services.TimeDate.date + } + Item { + Layout.fillWidth: true + } + } } } } + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onPressed: { + root.isAlt = !root.isAlt; + } + } } -- cgit v1.2.3