summaryrefslogtreecommitdiff
path: root/components/SimpleResource.qml
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-15 19:19:47 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-15 19:20:14 +0800
commitf7e4b82cf17a6571e3cca8bc57cd20a28bbe3ea8 (patch)
treef81885d6fc5e9c2095e5d277097fdd21e1bd687c /components/SimpleResource.qml
parentc549a8a57aedde017dfd7c8ea53348d789c95fa7 (diff)
stats: highlight significant usages
Diffstat (limited to 'components/SimpleResource.qml')
-rw-r--r--components/SimpleResource.qml12
1 files changed, 11 insertions, 1 deletions
diff --git a/components/SimpleResource.qml b/components/SimpleResource.qml
index c1c5bd1..0775069 100644
--- a/components/SimpleResource.qml
+++ b/components/SimpleResource.qml
@@ -7,8 +7,16 @@ import qs.components
Item {
id: root
- required property string text
+ required property real value
+ required property string suffix // unit
required property string icon
+ property string text: Math.round(root.value * 100) + root.suffix
+ property real thresholdL1: 40 / 100
+ 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
implicitWidth: layout.implicitWidth
implicitHeight: layout.implicitHeight
@@ -24,10 +32,12 @@ Item {
Icon {
text: root.icon
+ color: root.value < root.thresholdL1 ? WallustColors.foreground : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1
}
IText {
animate: true
text: root.text
+ color: root.value < root.thresholdL1 ? WallustColors.foreground : root.value >= root.thresholdL3 ? root.thresholdColorL3 : root.value >= root.thresholdL2 ? root.thresholdColorL2 : root.thresholdColorL1
}
Item {