diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-07-16 14:54:53 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-07-16 14:54:53 +0800 |
| commit | 5109ebe7179ced7107f4152e585423782ccb826b (patch) | |
| tree | 59b8020e0351d0abd43c985c73128ea166283cda /bar | |
| parent | b147652efdcbc1a3408d20c6e02606163725452a (diff) | |
Resources: alt texts
Diffstat (limited to 'bar')
| -rw-r--r-- | bar/Mpris.qml | 6 | ||||
| -rw-r--r-- | bar/Resources.qml | 27 | ||||
| -rw-r--r-- | bar/TimeDate.qml | 112 |
3 files changed, 97 insertions, 48 deletions
diff --git a/bar/Mpris.qml b/bar/Mpris.qml index f09076d..31c984c 100644 --- a/bar/Mpris.qml +++ b/bar/Mpris.qml @@ -97,7 +97,7 @@ Item { width: Bar.appIconSize height: Bar.appIconSize - opacity: activePlayer.playbackState === MprisPlaybackState.Playing ? 1 : Bar.mediaPausedOpacity + opacity: activePlayer?.playbackState === MprisPlaybackState.Playing ? 1 : Bar.mediaPausedOpacity // put shadow Image { @@ -132,8 +132,8 @@ Item { } IText { animate: true - opacity: activePlayer.playbackState === MprisPlaybackState.Playing ? 1 : Bar.mediaPausedOpacity - color: activePlayer.playbackState === MprisPlaybackState.Playing ? WallustColors.foreground : WallustColors.color15 + opacity: activePlayer?.playbackState === MprisPlaybackState.Playing ? 1 : Bar.mediaPausedOpacity + color: activePlayer?.playbackState === MprisPlaybackState.Playing ? WallustColors.foreground : WallustColors.color15 text: root.cleanedTitle Behavior on opacity { diff --git a/bar/Resources.qml b/bar/Resources.qml index 3e393e4..607c704 100644 --- a/bar/Resources.qml +++ b/bar/Resources.qml @@ -21,30 +21,37 @@ Item { id: layout anchors.centerIn: parent SimpleResource { - value: Services.Resource.cpuUsage + value: Math.round(Services.Resource.cpuUsage * 100) + altValue: Math.round(Services.Resource.cpuFreq / 10) / 100 suffix: "%" + altSuffix: "GHz" icon: Config.Icons.resource.cpu } SimpleResource { icon: Config.Icons.resource.memory - value: Services.Resource.memoryUsedPercentage + value: Math.round(Services.Resource.memoryUsedPercentage * 100) + altValue: Math.round(Services.Resource.memoryUsed / 1024 / 1024) suffix: "%" + altSuffix: "GB" } SimpleResource { icon: Config.Icons.resource.gpu - value: Services.Resource.gpuUsage / 100 + value: Services.Resource.gpuUsage + altValue: Services.Resource.gpuTemp suffix: "%" - thresholdL1: 0.60 - thresholdL2: 0.70 - thresholdL3: 0.80 + altSuffix: "°C" + altIcon: Config.Icons.resource.temp + thresholdL1: 60 + thresholdL2: 70 + thresholdL3: 80 } SimpleResource { icon: Config.Icons.resource.temp - value: Services.Resource.cpuTemp + value: Math.round(Services.Resource.cpuTemp * 100) suffix: "°C" - thresholdL1: 0.60 - thresholdL2: 0.80 - thresholdL3: 0.90 + thresholdL1: 60 + thresholdL2: 80 + thresholdL3: 90 } } } 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; + } + } } |
