From 60781d9d32e516694ef0d2246c620003d5db2d1f Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 27 Jul 2025 17:36:13 +0800 Subject: refactor: better color code style --- bar/ActiveWindow.qml | 2 +- bar/Bar.qml | 4 ++-- bar/Mpris.qml | 8 ++++---- bar/Network.qml | 10 +++++----- bar/Power.qml | 2 +- bar/Resources.qml | 2 +- bar/TimeDate.qml | 2 +- bar/Workspace.qml | 8 ++++---- components/IText.qml | 2 +- components/Icon.qml | 2 +- components/SimpleResource.qml | 4 ++-- config/Colors.qml | 19 +++++++++++++++++++ 12 files changed, 42 insertions(+), 23 deletions(-) diff --git a/bar/ActiveWindow.qml b/bar/ActiveWindow.qml index c5cd117..9949917 100644 --- a/bar/ActiveWindow.qml +++ b/bar/ActiveWindow.qml @@ -19,7 +19,7 @@ IRect { implicitHeight: rowLayout.implicitHeight + General.rectMargin * 2 anchors.centerIn: parent - color: WallustColors.color4 + color: Colors.d2 // according to docs, null could happen but doesn't seem to happen in practice so.. // hypr toplevel.activated is always true and doesn't change either so.. opacity: activated ? 1 : 0 diff --git a/bar/Bar.qml b/bar/Bar.qml index 87ab667..b7335e2 100644 --- a/bar/Bar.qml +++ b/bar/Bar.qml @@ -43,7 +43,7 @@ Scope { anchors.left: parent.left width: leftRow.width + leftRow.anchors.leftMargin - leftSpacer.width height: leftRow.height - color: Qt.rgba(WallustColors.background.r, WallustColors.background.g, WallustColors.background.b, Bar.bgTransparency) + color: Qt.rgba(Colors.background3.r, Colors.background3.g, Colors.background3.b, Bar.bgTransparency) radius: Bar.moduleRadius Behavior on color { @@ -92,7 +92,7 @@ Scope { anchors.right: parent.right width: rightRow.width + rightRow.anchors.rightMargin - rightSpacer.width height: rightRow.height - color: Qt.rgba(WallustColors.background.r, WallustColors.background.g, WallustColors.background.b, Bar.bgTransparency) + color: Qt.rgba(Colors.background3.r, Colors.background3.g, Colors.background3.b, Bar.bgTransparency) radius: Bar.moduleRadius Behavior on color { diff --git a/bar/Mpris.qml b/bar/Mpris.qml index 3f388b4..23c7c2f 100644 --- a/bar/Mpris.qml +++ b/bar/Mpris.qml @@ -52,14 +52,14 @@ Item { value: activePlayer?.position || 0 background: IRect { anchors.fill: parent - color: WallustColors.color4 + color: Colors.d2 radius: Style.rounding.smaller } contentItem: Item { IRect { width: pBar.visualPosition * parent.width height: parent.height - color: Qt.rgba(WallustColors.color12.r, WallustColors.color12.g, WallustColors.color12.b, WallustColors.color4.a * 2) + color: Qt.rgba(Colors.d1.r, Colors.d1.g, Colors.d1.b, Colors.d2.a * 2) radius: Style.rounding.smaller Behavior on width { @@ -109,7 +109,7 @@ Item { source: image opacity: activePlayer?.playbackState === MprisPlaybackState.Playing ? 1 : Bar.mediaPausedOpacity radius: 6 - color: WallustColors.background + color: Colors.background3 Behavior on opacity { NumberAnimation { @@ -143,7 +143,7 @@ Item { IText { animate: true opacity: activePlayer?.playbackState === MprisPlaybackState.Playing ? 1 : Bar.mediaPausedOpacity - color: activePlayer?.playbackState === MprisPlaybackState.Playing ? WallustColors.foreground : WallustColors.color15 + color: activePlayer?.playbackState === MprisPlaybackState.Playing ? Colors.foreground1 : Colors.foreground2 text: root.cleanedTitle Behavior on opacity { diff --git a/bar/Network.qml b/bar/Network.qml index f4178f2..6ce9f67 100644 --- a/bar/Network.qml +++ b/bar/Network.qml @@ -30,7 +30,7 @@ Item { implicitWidth: layout.implicitWidth + General.rectMargin * 2 implicitHeight: Bar.height - color: WallustColors.color4 + color: Colors.d2 radius: Style.rounding.large RowLayout { @@ -58,24 +58,24 @@ Item { spacing: Bar.resourceIconTextSpacing / 2 Icon { text: Icons.resource.network.download - color: root.downUnit == root.usageUnit && root.down > root.significantUsage ? Colors.cyan : WallustColors.color15 + color: root.downUnit == root.usageUnit && root.down > root.significantUsage ? Colors.cyan : Colors.foreground2 } IText { animate: true text: root.down + root.downUnit - color: root.downUnit == root.usageUnit && root.down > root.significantUsage ? Colors.cyan : WallustColors.color15 + color: root.downUnit == root.usageUnit && root.down > root.significantUsage ? Colors.cyan : Colors.foreground2 } } RowLayout { spacing: Bar.resourceIconTextSpacing / 2 Icon { text: Icons.resource.network.upload - color: root.upUnit == root.usageUnit && root.up > root.significantUsage ? Colors.cyan : WallustColors.color15 + color: root.upUnit == root.usageUnit && root.up > root.significantUsage ? Colors.cyan : Colors.foreground2 } IText { animate: true text: root.up + root.upUnit - color: root.upUnit == root.usageUnit && root.up > root.significantUsage ? Colors.cyan : WallustColors.color15 + color: root.upUnit == root.usageUnit && root.up > root.significantUsage ? Colors.cyan : Colors.foreground2 } } diff --git a/bar/Power.qml b/bar/Power.qml index 089fb0e..3681de1 100644 --- a/bar/Power.qml +++ b/bar/Power.qml @@ -26,7 +26,7 @@ Item { implicitWidth: layout.implicitWidth + General.rectMargin * 2 implicitHeight: Bar.height - General.rectMargin - color: WallustColors.color4 + color: Colors.d2 radius: Style.rounding.large RowLayout { diff --git a/bar/Resources.qml b/bar/Resources.qml index 548698f..e1147ab 100644 --- a/bar/Resources.qml +++ b/bar/Resources.qml @@ -14,7 +14,7 @@ Item { implicitWidth: layout.implicitWidth + Config.General.rectMargin * 2 implicitHeight: Config.Bar.height - Config.General.rectMargin - color: Config.WallustColors.color4 + color: Config.Colors.d2 radius: Config.Style.rounding.large RowLayout { diff --git a/bar/TimeDate.qml b/bar/TimeDate.qml index ede12ee..4908f6d 100644 --- a/bar/TimeDate.qml +++ b/bar/TimeDate.qml @@ -24,7 +24,7 @@ Item { implicitWidth: layout.width + General.rectMargin * 2 implicitHeight: Bar.height - color: WallustColors.color4 + color: Colors.d2 radius: Style.rounding.large RowLayout { diff --git a/bar/Workspace.qml b/bar/Workspace.qml index f709478..ee6810b 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -37,7 +37,7 @@ Item { source: activeRect radius: 8 cached: true - color: root.activeOccupied ? WallustColors.color4 : WallustColors.foreground + color: root.activeOccupied ? Colors.d2 : Colors.foreground1 opacity: root.activeOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 Behavior on color { @@ -60,7 +60,7 @@ Item { implicitWidth: Bar.wsActiveIconSize implicitHeight: Bar.wsIconSize - Bar.wsHorizontalSpacing radius: Bar.wsRounding - color: root.activeOccupied ? WallustColors.color4 : WallustColors.foreground + color: root.activeOccupied ? Colors.d2 : Colors.foreground1 opacity: root.activeOccupied ? Bar.wsActiveOpacity : Bar.wsEmptyOpacity / 3 Behavior on x { ISpringAnimation {} @@ -102,7 +102,7 @@ Item { implicitWidth: active ? Bar.wsActiveIconSize : Bar.wsIconSize implicitHeight: Bar.wsIconSize - Bar.wsHorizontalSpacing radius: Bar.wsRounding - color: st.isOccupied ? WallustColors.color4 : WallustColors.foreground + color: st.isOccupied ? Colors.d2 : Colors.foreground1 opacity: active && st.isOccupied ? Bar.wsActiveOpacity : st.isOccupied ? Bar.wsOpacity : Bar.wsEmptyOpacity Icon { @@ -110,7 +110,7 @@ Item { text: !st.isUrgent ? Icons.ws[index + 1] : Icons.ws['urgent'] font.pixelSize: !active ? Bar.wsIconSize / 2 : Bar.wsActiveIconSize / 2.5 opacity: !st.isOccupied ? 0 : 1 - color: !st.isUrgent ? !st.isActive ? WallustColors.color15 : WallustColors.foreground : Colors.red + color: !st.isUrgent ? !st.isActive ? Colors.foreground2 : Colors.foreground1 : Colors.red Behavior on font.pixelSize { ISpringAnimation {} } diff --git a/components/IText.qml b/components/IText.qml index fb9aed9..ad36d09 100644 --- a/components/IText.qml +++ b/components/IText.qml @@ -13,7 +13,7 @@ Text { // renderType: Text.NativeRendering textFormat: Text.PlainText - color: WallustColors.foreground + color: Colors.foreground1 font { family: Style.font.family.iosevka diff --git a/components/Icon.qml b/components/Icon.qml index 58660e5..e72f737 100644 --- a/components/Icon.qml +++ b/components/Icon.qml @@ -9,7 +9,7 @@ IText { property real fill: 0 property real truncatedFill: Math.round(fill * 100) / 100 // Reduce memory consumption spikes from constant font remapping renderType: Text.NativeRendering - color: WallustColors.color15 + color: Colors.foreground2 font { // hintingPreference: Font.PreferFullHinting hintingPreference: Font.PreferNoHinting // so the icons dont just offset away diff --git a/components/SimpleResource.qml b/components/SimpleResource.qml index b6b321b..eac09d5 100644 --- a/components/SimpleResource.qml +++ b/components/SimpleResource.qml @@ -40,12 +40,12 @@ Item { Icon { text: !root.isAlt ? root.icon : root.altIcon - color: root.value < root.thresholdL1 ? WallustColors.color15 : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1 + color: root.value < root.thresholdL1 ? Colors.foreground2 : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1 } IText { animate: true text: !root.isAlt ? root.text : root.altText - color: root.value < root.thresholdL1 ? WallustColors.foreground : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1 + color: root.value < root.thresholdL1 ? Colors.foreground1 : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1 } Item { diff --git a/config/Colors.qml b/config/Colors.qml index 522b5ff..8caa964 100644 --- a/config/Colors.qml +++ b/config/Colors.qml @@ -3,6 +3,25 @@ import Quickshell import QtQuick Singleton { + readonly property color background1: WallustColors.color8 + readonly property color background2: WallustColors.color0 + readonly property color background3: WallustColors.background + readonly property color a1: WallustColors.color9 + readonly property color a2: WallustColors.color1 + readonly property color b1: WallustColors.color10 + readonly property color b2: WallustColors.color2 + readonly property color c1: WallustColors.color11 + readonly property color c2: WallustColors.color3 + readonly property color d1: WallustColors.color12 + readonly property color d2: WallustColors.color4 + readonly property color e1: WallustColors.color13 + readonly property color e2: WallustColors.color5 + readonly property color f1: WallustColors.color14 + readonly property color f2: WallustColors.color6 + readonly property color foreground1: WallustColors.foreground + readonly property color foreground2: WallustColors.color15 + readonly property color foreground3: WallustColors.color7 + readonly property color black: Qt.rgba(59 / 255, 66 / 255, 82 / 255, 1) readonly property color red: Qt.rgba(191 / 255, 97 / 255, 106 / 255, 1) readonly property color green: Qt.rgba(163 / 255, 190 / 255, 140 / 255, 1) -- cgit v1.2.3