mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-21 18:54:01 -04:00
deprecation notice to plugin compatibility shims - When qml-common became a thing, we left qs.Widgets shims in place for plugin compatibility - It's annoying to need to maintain them when qml-common has any change, add a warning so we can safely deprecate them in the future - One shot rename the common stuff to D to make it shorter and nicer to write
86 lines
2.8 KiB
QML
86 lines
2.8 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import qs.Common
|
|
import qs.Modules.ControlCenter
|
|
import qs.Modules.ControlCenter.Widgets
|
|
import qs.Services
|
|
import qs.DCommon.Widgets
|
|
|
|
Item {
|
|
id: root
|
|
|
|
implicitHeight: column.height
|
|
|
|
LayoutMirroring.enabled: I18n.isRtl
|
|
LayoutMirroring.childrenInherit: true
|
|
|
|
property string currentMountPath: "/"
|
|
|
|
readonly property string title: I18n.tr("Disk usage")
|
|
readonly property var mounts: DgopService.diskMounts || []
|
|
|
|
signal mountPathChanged(string newMountPath)
|
|
|
|
Ref {
|
|
service: DgopService
|
|
modules: ["diskmounts"]
|
|
active: root.visible && (root.Window.window?.visible ?? false)
|
|
}
|
|
|
|
function usageOf(mount) {
|
|
return parseFloat((mount.percent || "0").replace("%", "")) || 0;
|
|
}
|
|
|
|
DFlickable {
|
|
anchors.fill: parent
|
|
contentHeight: column.height
|
|
clip: true
|
|
|
|
Column {
|
|
id: column
|
|
width: parent.width
|
|
spacing: CcMetrics.detailContentGap
|
|
|
|
CcEmptyState {
|
|
visible: !DgopService.dgopAvailable || root.mounts.length === 0
|
|
iconName: DgopService.dgopAvailable ? "storage" : "error"
|
|
iconColor: DgopService.dgopAvailable ? Theme.primary : Theme.error
|
|
title: DgopService.dgopAvailable ? I18n.tr("No disk data available") : I18n.tr("dgop not available")
|
|
}
|
|
|
|
CcGroup {
|
|
visible: root.mounts.length > 0
|
|
|
|
Repeater {
|
|
model: root.mounts
|
|
|
|
CcListRow {
|
|
required property var modelData
|
|
|
|
readonly property real usage: root.usageOf(modelData)
|
|
|
|
iconName: "storage"
|
|
iconColor: {
|
|
if (usage > CcMetrics.diskCriticalPercent)
|
|
return Theme.error;
|
|
if (usage > CcMetrics.diskWarnPercent)
|
|
return Theme.warning;
|
|
return contentColor;
|
|
}
|
|
active: modelData.mount === root.currentMountPath
|
|
title: modelData.mount === "/" ? I18n.tr("Root Filesystem") : modelData.mount
|
|
subtitle: `${modelData.used || "?"} / ${modelData.size || "?"}` + (modelData.mount === "/" ? "" : " • " + modelData.mount)
|
|
trailingBadge: usage.toFixed(0) + "%"
|
|
clickable: true
|
|
onClicked: {
|
|
root.currentMountPath = modelData.mount;
|
|
root.mountPathChanged(modelData.mount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|