diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-07-16 14:54:53 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-07-16 14:54:53 +0800 |
| commit | 5109ebe7179ced7107f4152e585423782ccb826b (patch) | |
| tree | 59b8020e0351d0abd43c985c73128ea166283cda /components/SimpleResource.qml | |
| parent | b147652efdcbc1a3408d20c6e02606163725452a (diff) | |
Resources: alt texts
Diffstat (limited to 'components/SimpleResource.qml')
| -rw-r--r-- | components/SimpleResource.qml | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/components/SimpleResource.qml b/components/SimpleResource.qml index 08d29b4..069dc0c 100644 --- a/components/SimpleResource.qml +++ b/components/SimpleResource.qml @@ -10,14 +10,20 @@ Item { 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 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 @@ -31,12 +37,12 @@ Item { } Icon { - text: root.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 } IText { animate: true - text: root.text + 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 } @@ -44,4 +50,11 @@ Item { Layout.fillWidth: true } } + MouseArea { + anchors.fill: parent + cursorShape: altValue != value ? Qt.PointingHandCursor : Qt.ArrowCursor + onPressed: { + root.isAlt = !root.isAlt; + } + } } |
