From c02ed5122986c99e1b25693b7134240dcc0ea0e1 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 2 Aug 2025 16:38:07 +0800 Subject: chore: reorganize Resource (utils->components) --- bar/Power.qml | 2 +- components/Resource.qml | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ utils/Resource.qml | 59 ------------------------------------------------- 3 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 components/Resource.qml delete mode 100644 utils/Resource.qml diff --git a/bar/Power.qml b/bar/Power.qml index cab2db1..a29bc4a 100644 --- a/bar/Power.qml +++ b/bar/Power.qml @@ -2,7 +2,7 @@ import QtQuick import QtQuick.Layouts import qs.services as Services -import qs.utils +import qs.components import qs.config import qs.components diff --git a/components/Resource.qml b/components/Resource.qml new file mode 100644 index 0000000..2048e98 --- /dev/null +++ b/components/Resource.qml @@ -0,0 +1,59 @@ +import QtQuick +import QtQuick.Layouts +import Quickshell +import Quickshell.Io + +import qs.config + +Item { + id: root + + required property string iconName + required property double percentage + property bool shown: true + clip: true + visible: width > 0 && height > 0 + implicitWidth: resourceRowLayout.x < 0 ? 0 : childrenRect.width + implicitHeight: childrenRect.height + + RowLayout { + id: resourceRowLayout + spacing: 4 + x: root.shown ? 0 : -resourceRowLayout.width + + CircularProgress { + Layout.alignment: Qt.AlignVCenter + lineWidth: 2 + value: root.percentage + size: 26 + // secondaryColor: Appearance.colors.colSecondaryContainer + // primaryColor: Appearance.m3colors.m3onSecondaryContainer + + MaterialSymbol { + anchors.centerIn: parent + fill: 1 + text: iconName + // iconSize: Appearance.font.pixelSize.normal + // color: Appearance.m3colors.m3onSecondaryContainer + } + } + + Text { + Layout.alignment: Qt.AlignVCenter + // color: Appearance.colors.colOnLayer1 + text: `${Math.round(percentage * 100)}` + } + + Behavior on x { + animation: Appearance.animation.elementMove.numberAnimation.createObject(this) + } + } + + Behavior on implicitWidth { + NumberAnimation { + duration: Appearance.animation.elementMove.duration + easing.type: Appearance.animation.elementMove.type + easing.bezierCurve: Appearance.animation.elementMove.bezierCurve + } + } +} diff --git a/utils/Resource.qml b/utils/Resource.qml deleted file mode 100644 index 2048e98..0000000 --- a/utils/Resource.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick -import QtQuick.Layouts -import Quickshell -import Quickshell.Io - -import qs.config - -Item { - id: root - - required property string iconName - required property double percentage - property bool shown: true - clip: true - visible: width > 0 && height > 0 - implicitWidth: resourceRowLayout.x < 0 ? 0 : childrenRect.width - implicitHeight: childrenRect.height - - RowLayout { - id: resourceRowLayout - spacing: 4 - x: root.shown ? 0 : -resourceRowLayout.width - - CircularProgress { - Layout.alignment: Qt.AlignVCenter - lineWidth: 2 - value: root.percentage - size: 26 - // secondaryColor: Appearance.colors.colSecondaryContainer - // primaryColor: Appearance.m3colors.m3onSecondaryContainer - - MaterialSymbol { - anchors.centerIn: parent - fill: 1 - text: iconName - // iconSize: Appearance.font.pixelSize.normal - // color: Appearance.m3colors.m3onSecondaryContainer - } - } - - Text { - Layout.alignment: Qt.AlignVCenter - // color: Appearance.colors.colOnLayer1 - text: `${Math.round(percentage * 100)}` - } - - Behavior on x { - animation: Appearance.animation.elementMove.numberAnimation.createObject(this) - } - } - - Behavior on implicitWidth { - NumberAnimation { - duration: Appearance.animation.elementMove.duration - easing.type: Appearance.animation.elementMove.type - easing.bezierCurve: Appearance.animation.elementMove.bezierCurve - } - } -} -- cgit v1.2.3