From e0b139d4afe566f57574fae15668ba297ed7334e Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 29 Jul 2025 17:54:31 +0800 Subject: chore: reorganize component rm: circularprogress as its unused --- components/CircularProgress.qml | 91 ----------------------------------------- components/SimpleResource.qml | 63 ---------------------------- 2 files changed, 154 deletions(-) delete mode 100644 components/CircularProgress.qml delete mode 100644 components/SimpleResource.qml (limited to 'components') diff --git a/components/CircularProgress.qml b/components/CircularProgress.qml deleted file mode 100644 index 240e520..0000000 --- a/components/CircularProgress.qml +++ /dev/null @@ -1,91 +0,0 @@ -// From https://github.com/rafzby/circular-progressbar with modifications -// License: LGPL-3.0 - A copy can be found in `licenses` folder of repo - -import QtQuick - -/** - * Material 3 circular progress. See https://m3.material.io/components/progress-indicators/specs - */ -Item { - id: root - - property int size: 30 - property int lineWidth: 2 - property real value: 0 - // property color primaryColor: Appearance.m3colors.m3onSecondaryContainer - // property color secondaryColor: Appearance.colors.colSecondaryContainer - property real gapAngle: Math.PI / 9 - property bool fill: false - property int fillOverflow: 2 - property int animationDuration: 1000 - property var easingType: Easing.OutCubic - - width: size - height: size - - signal animationFinished - - onValueChanged: { - canvas.degree = value * 360; - } - // onPrimaryColorChanged: { - // canvas.requestPaint(); - // } - // onSecondaryColorChanged: { - // canvas.requestPaint(); - // } - - Canvas { - id: canvas - - property real degree: 0 - - anchors.fill: parent - antialiasing: true - - onDegreeChanged: { - requestPaint(); - } - - onPaint: { - var ctx = getContext("2d"); - var x = root.width / 2; - var y = root.height / 2; - var radius = root.size / 2 - root.lineWidth; - var startAngle = (Math.PI / 180) * 270; - var fullAngle = (Math.PI / 180) * (270 + 360); - var progressAngle = (Math.PI / 180) * (270 + degree); - var epsilon = 0.01; // Small angle in radians - - ctx.reset(); - if (root.fill) { - // ctx.fillStyle = root.secondaryColor; - ctx.beginPath(); - ctx.arc(x, y, radius + fillOverflow, startAngle, fullAngle); - ctx.fill(); - } - ctx.lineCap = 'round'; - ctx.lineWidth = root.lineWidth; - - // Secondary - ctx.beginPath(); - ctx.arc(x, y, radius, progressAngle + gapAngle, fullAngle - gapAngle); - // ctx.strokeStyle = root.secondaryColor; - ctx.stroke(); - - // Primary (value indication) - var endAngle = progressAngle + (value > 0 ? 0 : epsilon); - ctx.beginPath(); - ctx.arc(x, y, radius, startAngle, endAngle); - // ctx.strokeStyle = root.primaryColor; - ctx.stroke(); - } - - Behavior on degree { - NumberAnimation { - duration: root.animationDuration - easing.type: root.easingType - } - } - } -} diff --git a/components/SimpleResource.qml b/components/SimpleResource.qml deleted file mode 100644 index 818327d..0000000 --- a/components/SimpleResource.qml +++ /dev/null @@ -1,63 +0,0 @@ -import QtQuick -import Quickshell -import QtQuick.Layouts -import qs.config -import qs.components - -Item { - id: root - - // TODO: use https://quickshell.org/docs/master/types/Quickshell/PopupWindow/ for tooltip - - required property real value - required property string suffix // unit - required property string icon - property string altValue: value - property string altSuffix: suffix - property string altIcon: icon - property string text: root.value + root.suffix - property string altText: root.altValue + root.altSuffix - property real thresholdL1: 40 - property real thresholdL2: thresholdL1 * 1.5 - property real thresholdL3: thresholdL2 * 1.5 - property color thresholdColorL1: Colors.cyan - property color thresholdColorL2: Colors.yellow - property color thresholdColorL3: Colors.red - - property bool isAlt: false - - implicitWidth: layout.implicitWidth - implicitHeight: layout.implicitHeight - - RowLayout { - id: layout - - spacing: Bar.resourceIconTextSpacing - - Item { - Layout.fillWidth: true - } - - Icon { - text: !root.isAlt ? root.icon : root.altIcon - color: root.value < root.thresholdL1 ? Colors.foreground2 : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1 - } - IText { - animate: true - renderType: Text.CurveRendering // it's not static and is rapidly updated - text: !root.isAlt ? root.text : root.altText - color: root.value < root.thresholdL1 ? Colors.foreground1 : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1 - } - - Item { - Layout.fillWidth: true - } - } - MouseArea { - anchors.fill: parent - cursorShape: altValue != value ? Qt.PointingHandCursor : Qt.ArrowCursor - onPressed: { - root.isAlt = !root.isAlt; - } - } -} -- cgit v1.2.3