From 03a93a60a6c425f5e881bed01feddf7f755624a7 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 13 Jul 2025 22:44:02 +0800 Subject: refactor: icons -> icon components --- bar/Network.qml | 24 ++++++++++++------------ bar/Power.qml | 42 +++++++++++++++++++++--------------------- bar/TimeDate.qml | 20 ++++++++++---------- bar/Workspace.qml | 26 +++++++++++++------------- components/Icon.qml | 35 +++++++++++++++++++++++++++++++++++ components/Icons.qml | 35 ----------------------------------- components/SimpleResource.qml | 14 +++++++------- 7 files changed, 98 insertions(+), 98 deletions(-) create mode 100644 components/Icon.qml delete mode 100644 components/Icons.qml diff --git a/bar/Network.qml b/bar/Network.qml index ae1eace..8c7a745 100644 --- a/bar/Network.qml +++ b/bar/Network.qml @@ -3,12 +3,12 @@ import QtQuick.Layouts import qs.services as Services import qs.components -import qs.config as Config +import qs.config Item { implicitWidth: container.implicitWidth - implicitHeight: container.implicitHeight - Config.General.rectMargin + implicitHeight: container.implicitHeight - General.rectMargin Rectangle { id: container @@ -18,10 +18,10 @@ Item { horizontalCenter: parent.horizontalCenter } - implicitWidth: layout.implicitWidth + Config.General.rectMargin * 2 - implicitHeight: Config.Bar.height - color: Config.Colors.alt - radius: Config.Style.rounding.large + implicitWidth: layout.implicitWidth + General.rectMargin * 2 + implicitHeight: Bar.height + color: Colors.alt + radius: Style.rounding.large RowLayout { id: layout @@ -29,29 +29,29 @@ Item { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter } - spacing: Config.Bar.resourceIconTextSpacing + spacing: Bar.resourceIconTextSpacing Item { Layout.fillWidth: true } - Icons { + Icon { text: Services.Network.state } RowLayout { - spacing: Config.Bar.resourceIconTextSpacing / 2 + spacing: Bar.resourceIconTextSpacing / 2 IText { - text: Config.Icons.resource.network.download + text: Icons.resource.network.download } IText { text: Services.NetworkUsage.down + Services.NetworkUsage.downUnit } } RowLayout { - spacing: Config.Bar.resourceIconTextSpacing / 2 + spacing: Bar.resourceIconTextSpacing / 2 IText { - text: Config.Icons.resource.network.upload + text: Icons.resource.network.upload } IText { text: Services.NetworkUsage.up + Services.NetworkUsage.upUnit diff --git a/bar/Power.qml b/bar/Power.qml index 1eea3e1..a1d50f5 100644 --- a/bar/Power.qml +++ b/bar/Power.qml @@ -3,7 +3,7 @@ import QtQuick.Layouts import qs.services as Services import qs.utils -import qs.config as Config +import qs.config import qs.components Item { @@ -18,11 +18,11 @@ Item { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter } - implicitWidth: layout.implicitWidth + Config.General.rectMargin * 2 - implicitHeight: Config.Bar.height - Config.General.rectMargin + implicitWidth: layout.implicitWidth + General.rectMargin * 2 + implicitHeight: Bar.height - General.rectMargin - color: Config.Colors.alt - radius: Config.Style.rounding.large + color: Colors.alt + radius: Style.rounding.large RowLayout { id: layout @@ -30,32 +30,32 @@ Item { Layout.fillWidth: true } anchors.fill: parent - spacing: Config.Bar.resourceIconTextSpacing + spacing: Bar.resourceIconTextSpacing - Icons { - text: Config.Icons.power.shutdown - font.pixelSize: Config.Style.font.size.large + Icon { + text: Icons.power.shutdown + font.pixelSize: Style.font.size.large color: Qt.rgba(191, 97, 106, 1) } - // Icons { - // text: Config.Icons.power.dpms - // font.pixelSize: Config.Style.fontSize.large + // Icon { + // text: Icons.power.dpms + // font.pixelSize: Style.fontSize.large // } // - // Icons { - // text: Config.Icons.power.lock - // font.pixelSize: Config.Style.fontSize.large + // Icon { + // text: Icons.power.lock + // font.pixelSize: Style.fontSize.large // } // - // Icons { - // text: Config.Icons.power.suspend - // font.pixelSize: Config.Style.fontSize.large + // Icon { + // text: Icons.power.suspend + // font.pixelSize: Style.fontSize.large // } // - // Icons { - // text: Config.Icons.power.reboot - // font.pixelSize: Config.Style.fontSize.large + // Icon { + // text: Icons.power.reboot + // font.pixelSize: Style.fontSize.large // } Item { diff --git a/bar/TimeDate.qml b/bar/TimeDate.qml index 6b7ec59..1a952c7 100644 --- a/bar/TimeDate.qml +++ b/bar/TimeDate.qml @@ -3,11 +3,11 @@ import QtQuick.Layouts import qs.services as Services import qs.components -import qs.config as Config +import qs.config Item { implicitWidth: container.implicitWidth - implicitHeight: container.implicitHeight - Config.General.rectMargin + implicitHeight: container.implicitHeight - General.rectMargin Rectangle { id: container anchors { @@ -16,11 +16,11 @@ Item { horizontalCenter: parent.horizontalCenter } - implicitWidth: layout.implicitWidth + Config.General.rectMargin * 2 - implicitHeight: Config.Bar.height + implicitWidth: layout.implicitWidth + General.rectMargin * 2 + implicitHeight: Bar.height - color: Config.Colors.alt - radius: Config.Style.rounding.large + color: Colors.alt + radius: Style.rounding.large RowLayout { id: layout @@ -28,11 +28,11 @@ Item { Layout.fillWidth: true } anchors.fill: parent - spacing: Config.Bar.resourceIconTextSpacing + spacing: Bar.resourceIconTextSpacing - Icons { - text: Config.Icons.resource.clock - font.pixelSize: Config.Style.font.size.larger + Icon { + text: Icons.resource.clock + font.pixelSize: Style.font.size.larger } IText { text: Services.TimeDate.time diff --git a/bar/Workspace.qml b/bar/Workspace.qml index cf8e482..50b9296 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -3,7 +3,7 @@ import QtQuick import Quickshell import Quickshell.Hyprland import Quickshell.Wayland -import qs.config as Config +import qs.config import qs.components Item { @@ -31,29 +31,29 @@ Item { implicitWidth: childrenRect.width anchors.verticalCenter: parent.verticalCenter - spacing: Config.Bar.workspaceSpacing + spacing: Bar.workspaceSpacing Repeater { - model: Config.Bar.workspaces + model: Bar.workspaces Rectangle { id: workspaceRect property var st: getWorkspaceStats(index) - implicitWidth: !st.isActive ? Config.Bar.workspaceIconSize : Config.Bar.workspaceActiveIconSize - implicitHeight: Config.Bar.workspaceIconSize - Config.Bar.workspaceHorizontalSpacing - radius: Config.Bar.workspaceRounding - Icons { + implicitWidth: !st.isActive ? Bar.workspaceIconSize : Bar.workspaceActiveIconSize + implicitHeight: Bar.workspaceIconSize - Bar.workspaceHorizontalSpacing + radius: Bar.workspaceRounding + Icon { anchors.centerIn: parent - text: !st.isUrgent ? Config.Icons.ws[index + 1] : Config.Icons.ws['urgent'] // TODO: urgent = red - font.pixelSize: Config.Bar.workspaceIconSize / 2 - color: Config.Colors.foreground // TODO make IText w/ ts default color + text: !st.isUrgent ? Icons.ws[index + 1] : Icons.ws['urgent'] // TODO: urgent = red + font.pixelSize: Bar.workspaceIconSize / 2 + color: Colors.foreground // TODO make IText w/ ts default color opacity: !st.isOccupied ? 0 : 1 // less contrast - // opacity: isActive(index) ? Config.Bar.workspaceActiveOpacity : isOccupied(index) ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity + // opacity: isActive(index) ? Bar.workspaceActiveOpacity : isOccupied(index) ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity } - color: st.isOccupied ? Config.Colors.alt : Config.Colors.foreground - opacity: st.isActive && st.isOccupied ? Config.Bar.workspaceActiveOpacity : st.isOccupied ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity + color: st.isOccupied ? Colors.alt : Colors.foreground + opacity: st.isActive && st.isOccupied ? Bar.workspaceActiveOpacity : st.isOccupied ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity } } } diff --git a/components/Icon.qml b/components/Icon.qml new file mode 100644 index 0000000..a5d2348 --- /dev/null +++ b/components/Icon.qml @@ -0,0 +1,35 @@ +import QtQuick +import QtQuick.Layouts + +import qs.config + +IText { + id: root + property real iconSize: General.iconSize + property real fill: 0 + property real truncatedFill: Math.round(fill * 100) / 100 // Reduce memory consumption spikes from constant font remapping + renderType: Text.NativeRendering + font { + // hintingPreference: Font.PreferFullHinting + hintingPreference: Font.PreferNoHinting // so the icons dont just offset away + family: Style.font.family.symbols ?? "Symbols Nerd Font" + pixelSize: iconSize + weight: Font.Normal + (Font.DemiBold - Font.Normal) * fill + variableAxes: { + "FILL": truncatedFill, + // "wght": font.weight, + // "GRAD": 0, + "opsz": iconSize + } + } + verticalAlignment: Text.AlignVCenter + // color: Style.m3colors.m3onBackground + + // Behavior on fill { + // NumberAnimation { + // duration: Appearance?.animation.elementMoveFast.duration ?? 200 + // easing.type: Appearance?.animation.elementMoveFast.type ?? Easing.BezierSpline + // easing.bezierCurve: Appearance?.animation.elementMoveFast.bezierCurve ?? [0.34, 0.80, 0.34, 1.00, 1, 1] + // } + // } +} diff --git a/components/Icons.qml b/components/Icons.qml deleted file mode 100644 index a5d2348..0000000 --- a/components/Icons.qml +++ /dev/null @@ -1,35 +0,0 @@ -import QtQuick -import QtQuick.Layouts - -import qs.config - -IText { - id: root - property real iconSize: General.iconSize - property real fill: 0 - property real truncatedFill: Math.round(fill * 100) / 100 // Reduce memory consumption spikes from constant font remapping - renderType: Text.NativeRendering - font { - // hintingPreference: Font.PreferFullHinting - hintingPreference: Font.PreferNoHinting // so the icons dont just offset away - family: Style.font.family.symbols ?? "Symbols Nerd Font" - pixelSize: iconSize - weight: Font.Normal + (Font.DemiBold - Font.Normal) * fill - variableAxes: { - "FILL": truncatedFill, - // "wght": font.weight, - // "GRAD": 0, - "opsz": iconSize - } - } - verticalAlignment: Text.AlignVCenter - // color: Style.m3colors.m3onBackground - - // Behavior on fill { - // NumberAnimation { - // duration: Appearance?.animation.elementMoveFast.duration ?? 200 - // easing.type: Appearance?.animation.elementMoveFast.type ?? Easing.BezierSpline - // easing.bezierCurve: Appearance?.animation.elementMoveFast.bezierCurve ?? [0.34, 0.80, 0.34, 1.00, 1, 1] - // } - // } -} diff --git a/components/SimpleResource.qml b/components/SimpleResource.qml index 0069f53..4df395d 100644 --- a/components/SimpleResource.qml +++ b/components/SimpleResource.qml @@ -1,7 +1,7 @@ import QtQuick import Quickshell import QtQuick.Layouts -import qs.config as Config +import qs.config import qs.components Item { @@ -15,23 +15,23 @@ Item { Rectangle { id: container - implicitWidth: layout.implicitWidth + Config.General.rectMargin * 2 - implicitHeight: Config.Bar.height - Config.General.rectMargin + implicitWidth: layout.implicitWidth + General.rectMargin * 2 + implicitHeight: Bar.height - General.rectMargin - color: Config.Colors.alt - radius: Config.Style.rounding.large + color: Colors.alt + radius: Style.rounding.large RowLayout { id: layout anchors.centerIn: parent - spacing: Config.Bar.resourceIconTextSpacing + spacing: Bar.resourceIconTextSpacing Item { Layout.fillWidth: true } - Icons { + Icon { text: root.icon } IText { -- cgit v1.2.3