Files
z-bar-qt/Modules/Bar/Components/Resource.qml
T
zach b58b4fdc9c
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 9s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Failing after 33s
Rust / build (pull_request) Successful in 48s
Python / verify (pull_request) Failing after 1m24s
Rust / fmt (pull_request) Successful in 32s
Rust / clippy (pull_request) Successful in 57s
fix: remove more uses of cliprect and finally fix workspace's layer texture
2026-10-27 15:15:57 +01:00

84 lines
2.3 KiB
QML

import QtQuick
import QtQuick.Layouts
import Quickshell
import qs.Components
import ZShell.Config
import qs.Services
GridLayout {
id: root
property color accentColor: warning ? Colors.palette.m3error : mainColor
property real animatedPercentage: 0
readonly property real arcStartAngle: 0.75 * Math.PI
readonly property real arcSweep: 1.5 * Math.PI
required property bool horizontal
property string icon
required property color iconColor
required property color mainColor
required property double percentage
property bool shown: true
property color usageColor: warning ? Colors.palette.m3error : mainColor
property bool warning: percentage * 100 >= warningThreshold
property int warningThreshold: 80
columnSpacing: Tokens.spacing.medium
columns: horizontal ? -1 : 1
percentage: 0
Behavior on animatedPercentage {
Anim {}
}
Component.onCompleted: animatedPercentage = percentage
onPercentageChanged: {
const next = percentage;
if (Math.abs(next - animatedPercentage) >= 0.05)
animatedPercentage = next;
}
MaterialIcon {
id: icon
Layout.preferredWidth: 16
color: root.iconColor
fontStyle: Tokens.font.icon.small
text: root.icon
}
CustomRect {
id: track
Layout.preferredHeight: root.horizontal ? icon.implicitHeight - Tokens.padding.extraSmall : 4
Layout.preferredWidth: root.horizontal ? 4 : icon.implicitWidth
color: Colors.layer(Colors.palette.m3surfaceContainerHigh, 2)
radius: Tokens.rounding.full
Item {
id: clipper
anchors.bottom: root.horizontal ? parent.bottom : undefined
anchors.horizontalCenter: root.horizontal ? parent.horizontalCenter : undefined
anchors.left: root.horizontal ? undefined : parent.left
anchors.verticalCenter: root.horizontal ? undefined : parent.verticalCenter
clip: true
implicitHeight: root.horizontal ? root.percentage * track.height : track.height * 2
implicitWidth: root.horizontal ? track.width * 2 : root.percentage * track.width
CustomRect {
anchors.bottom: root.horizontal ? parent.bottom : undefined
anchors.horizontalCenter: root.horizontal ? parent.horizontalCenter : undefined
anchors.left: root.horizontal ? undefined : parent.left
anchors.verticalCenter: root.horizontal ? undefined : parent.verticalCenter
color: root.mainColor
radius: track.radius
implicitHeight: track.height
implicitWidth: track.width
}
}
}
}