diff options
| author | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
|---|---|---|
| committer | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
| commit | 70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 (patch) | |
| tree | ab1123d4067c1b086dd6faa7ee4ea643236b565a /raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/SmallDiskUsageButton.qml | |
| parent | 5d94c0a7d44a2255b81815a52a7056a94a39842d (diff) | |
| download | RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.tar.gz RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.zip | |
Replaced file structures for themes in the correct format
Diffstat (limited to 'raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/SmallDiskUsageButton.qml')
| -rw-r--r-- | raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/SmallDiskUsageButton.qml | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/SmallDiskUsageButton.qml b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/SmallDiskUsageButton.qml new file mode 100644 index 0000000..30c4e36 --- /dev/null +++ b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/SmallDiskUsageButton.qml @@ -0,0 +1,129 @@ +import QtQuick +import qs.Common +import qs.Services +import qs.Widgets + +Rectangle { + id: root + + LayoutMirroring.enabled: I18n.isRtl + LayoutMirroring.childrenInherit: true + + property string mountPath: "/" + property string instanceId: "" + + property var selectedMount: { + if (!DgopService.diskMounts || DgopService.diskMounts.length === 0) + return null; + const targetMount = DgopService.diskMounts.find(mount => mount.mount === mountPath); + return targetMount || DgopService.diskMounts.find(mount => mount.mount === "/") || DgopService.diskMounts[0]; + } + + property real usagePercent: { + if (!selectedMount?.percent) + return 0; + return parseFloat(selectedMount.percent.replace("%", "")) || 0; + } + + property bool enabled: DgopService.dgopAvailable + + signal clicked + + width: parent ? ((parent.width - parent.spacing * 3) / 4) : 48 + height: 48 + radius: Theme.cornerRadius + 4 + + function hoverTint(base) { + const factor = 1.2; + return Theme.isLightMode ? Qt.darker(base, factor) : Qt.lighter(base, factor); + } + + readonly property color _tileBg: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency) + + color: mouseArea.containsMouse ? Theme.primaryPressed : _tileBg + border.color: "transparent" + border.width: 0 + antialiasing: true + opacity: enabled ? 1.0 : 0.6 + + Rectangle { + anchors.fill: parent + radius: parent.radius + color: hoverTint(root.color) + opacity: mouseArea.pressed ? 0.3 : (mouseArea.containsMouse ? 0.2 : 0.0) + visible: opacity > 0 + antialiasing: true + Behavior on opacity { + NumberAnimation { + duration: Theme.shortDuration + } + } + } + + Row { + anchors.centerIn: parent + spacing: Theme.spacingXS + + DankIcon { + anchors.verticalCenter: parent.verticalCenter + name: "storage" + size: Theme.iconSizeSmall + color: { + if (root.usagePercent > 90) + return Theme.error; + if (root.usagePercent > 75) + return Theme.warning; + return Theme.ccTileInactiveIcon; + } + } + + Column { + anchors.verticalCenter: parent.verticalCenter + spacing: 0 + + StyledText { + text: root.selectedMount?.mount || root.mountPath + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceVariantText + elide: Text.ElideMiddle + width: Math.min(implicitWidth, root.width - Theme.iconSizeSmall - Theme.spacingM) + horizontalAlignment: Text.AlignLeft + } + + StyledText { + text: `${root.usagePercent.toFixed(0)}%` + font.pixelSize: Theme.fontSizeSmall + font.weight: Font.Bold + color: { + if (root.usagePercent > 90) + return Theme.error; + if (root.usagePercent > 75) + return Theme.warning; + return Theme.ccTileInactiveIcon; + } + } + } + } + + DankRipple { + id: ripple + cornerRadius: root.radius + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + enabled: root.enabled + onPressed: mouse => ripple.trigger(mouse.x, mouse.y) + onClicked: root.clicked() + } + + Component.onCompleted: { + DgopService.addRef(["diskmounts"]); + } + Component.onDestruction: { + DgopService.removeRef(["diskmounts"]); + } +} |