1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-08 12:13:31 -04:00
Files
DankMaterialShell/quickshell/Modules/ControlCenter/Widgets/DiskUsagePill.qml
T
Guilherme Pagano 3e4d2b4d46 feat(control-center): add DiskUsage widget config overlay with showMountPath toggle and standardized tile sizing (#2507)
* feat(control-center): add widget config overlay with showMountPath toggle for DiskUsage

Introduces WidgetConfigOverlay and DiskUsageWidgetConfigMenu components, allowing
users to toggle mount path visibility per DiskUsage widget in edit mode

* refactor(control-center): use Theme.iconSizeLarge and Theme.fontSizeLarge for small tiles

Standardize SmallDiskUsageButton and SmallBatteryButton sizing with Theme.iconSizeLarge
and Theme.fontSizeLarge, and unify font weight to Font.Bold on both tile widgets.

* fix(control-center): adjust SmallDiskUsageButton font size based on showMountPath

* refactor(control-center): simplify DiskUsage config menu i18n strings

Remove the redundant "Disk Usage Widget" title and the toggle description
to reduce translatable strings
2026-06-01 11:35:14 -04:00

81 lines
2.1 KiB
QML

import QtQuick
import qs.Common
import qs.Services
import qs.Modules.ControlCenter.Widgets
CompoundPill {
id: root
property string mountPath: "/"
property string instanceId: ""
property bool showMountPath: true
iconName: "storage"
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 || !selectedMount.percent) {
return 0;
}
const percentStr = selectedMount.percent.replace("%", "");
return parseFloat(percentStr) || 0;
}
isActive: DgopService.dgopAvailable && selectedMount !== null
primaryText: {
if (!DgopService.dgopAvailable) {
return I18n.tr("Disk Usage");
}
if (!selectedMount) {
return I18n.tr("No disk data");
}
if (!showMountPath) {
return I18n.tr("Disk Usage");
}
return selectedMount.mount;
}
secondaryText: {
if (!DgopService.dgopAvailable) {
return I18n.tr("dgop not available");
}
if (!selectedMount) {
return I18n.tr("No disk data available");
}
return `${selectedMount.used} / ${selectedMount.size} (${usagePercent.toFixed(0)}%)`;
}
iconColor: {
if (!DgopService.dgopAvailable || !selectedMount) {
return Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.5);
}
if (usagePercent > 90) {
return Theme.error;
}
if (usagePercent > 75) {
return Theme.warning;
}
return Theme.surfaceText;
}
Component.onCompleted: {
DgopService.addRef(["diskmounts"]);
}
Component.onDestruction: {
DgopService.removeRef(["diskmounts"]);
}
onToggled: {
expandClicked();
}
}