blob: 827df4ec50432aabb33345abfeaf9f8cadf3228c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
import QtQuick
import qs.Common
import qs.Services
import qs.Modules.ControlCenter.Widgets
CompoundPill {
id: root
property string mountPath: "/"
property string instanceId: ""
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");
}
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();
}
}
|