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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
import QtQuick
import QtQuick.Layouts
import qs.Common
import qs.Services
import qs.Widgets
Item {
id: root
function formatSpeed(bytesPerSec) {
if (bytesPerSec < 1024)
return bytesPerSec.toFixed(0) + " B/s";
if (bytesPerSec < 1024 * 1024)
return (bytesPerSec / 1024).toFixed(1) + " KB/s";
if (bytesPerSec < 1024 * 1024 * 1024)
return (bytesPerSec / (1024 * 1024)).toFixed(1) + " MB/s";
return (bytesPerSec / (1024 * 1024 * 1024)).toFixed(2) + " GB/s";
}
Component.onCompleted: {
DgopService.addRef(["disk", "diskmounts"]);
}
Component.onDestruction: {
DgopService.removeRef(["disk", "diskmounts"]);
}
ColumnLayout {
anchors.fill: parent
spacing: Theme.spacingM
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 80
radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
RowLayout {
anchors.fill: parent
anchors.margins: Theme.spacingM
spacing: Theme.spacingXL
Column {
Layout.fillWidth: true
spacing: Theme.spacingXS
Row {
spacing: Theme.spacingS
DankIcon {
name: "storage"
size: Theme.iconSize
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: I18n.tr("Disk I/O", "disk io header in system monitor")
font.pixelSize: Theme.fontSizeLarge
font.weight: Font.Bold
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
}
}
Row {
spacing: Theme.spacingL
Row {
spacing: Theme.spacingXS
StyledText {
text: I18n.tr("Read:", "disk read label")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
}
StyledText {
text: root.formatSpeed(DgopService.diskReadRate)
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
font.weight: Font.Bold
color: Theme.primary
}
}
Row {
spacing: Theme.spacingXS
StyledText {
text: I18n.tr("Write:", "disk write label")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
}
StyledText {
text: root.formatSpeed(DgopService.diskWriteRate)
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
font.weight: Font.Bold
color: Theme.warning
}
}
}
}
}
}
Rectangle {
Layout.fillWidth: true
Layout.fillHeight: true
radius: Theme.cornerRadius
color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
ColumnLayout {
anchors.fill: parent
anchors.margins: Theme.spacingM
spacing: Theme.spacingS
Row {
spacing: Theme.spacingS
DankIcon {
name: "folder"
size: Theme.iconSize - 2
color: Theme.secondary
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: I18n.tr("Mount Points", "mount points header in system monitor")
font.pixelSize: Theme.fontSizeMedium
font.weight: Font.Bold
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
color: Theme.outlineLight
}
DankListView {
id: mountListView
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
spacing: 4
model: DgopService.diskMounts
delegate: Rectangle {
required property var modelData
required property int index
width: mountListView.width
height: 60
radius: Theme.cornerRadius
color: mountMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.06) : "transparent"
readonly property real usedPct: {
const pctStr = modelData?.percent ?? "0%";
return parseFloat(pctStr.replace("%", "")) / 100;
}
MouseArea {
id: mountMouseArea
anchors.fill: parent
hoverEnabled: true
}
RowLayout {
anchors.fill: parent
anchors.margins: Theme.spacingS
spacing: Theme.spacingM
Column {
Layout.fillWidth: true
spacing: Theme.spacingXS
Row {
spacing: Theme.spacingS
DankIcon {
name: {
const mp = modelData?.mount ?? "";
if (mp === "/")
return "home";
if (mp === "/home")
return "person";
if (mp.includes("boot"))
return "memory";
if (mp.includes("media") || mp.includes("mnt"))
return "usb";
return "folder";
}
size: Theme.iconSize - 4
color: Theme.surfaceText
opacity: 0.8
}
StyledText {
text: modelData?.mount ?? ""
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
font.weight: Font.Medium
color: Theme.surfaceText
}
}
Row {
spacing: Theme.spacingS
StyledText {
text: modelData?.device ?? ""
font.pixelSize: Theme.fontSizeSmall - 2
font.family: SettingsData.monoFontFamily
color: Theme.surfaceVariantText
}
StyledText {
text: "•"
font.pixelSize: Theme.fontSizeSmall - 2
color: Theme.surfaceVariantText
}
StyledText {
text: modelData?.fstype ?? ""
font.pixelSize: Theme.fontSizeSmall - 2
font.family: SettingsData.monoFontFamily
color: Theme.surfaceVariantText
}
}
}
Column {
Layout.preferredWidth: 200
spacing: Theme.spacingXS
Rectangle {
width: parent.width
height: 8
radius: 4
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
Rectangle {
width: parent.width * Math.min(1, parent.parent.parent.parent.usedPct)
height: parent.height
radius: 4
color: {
const pct = parent.parent.parent.parent.usedPct;
if (pct > 0.95)
return Theme.error;
if (pct > 0.85)
return Theme.warning;
return Theme.primary;
}
Behavior on width {
NumberAnimation {
duration: Theme.shortDuration
}
}
}
}
Row {
anchors.right: parent.right
spacing: Theme.spacingS
StyledText {
text: modelData?.used ?? ""
font.pixelSize: Theme.fontSizeSmall - 2
font.family: SettingsData.monoFontFamily
color: Theme.surfaceText
}
StyledText {
text: "/"
font.pixelSize: Theme.fontSizeSmall - 2
color: Theme.surfaceVariantText
}
StyledText {
text: modelData?.size ?? ""
font.pixelSize: Theme.fontSizeSmall - 2
font.family: SettingsData.monoFontFamily
color: Theme.surfaceVariantText
}
}
}
StyledText {
Layout.preferredWidth: 50
text: modelData?.percent ?? ""
font.pixelSize: Theme.fontSizeSmall
font.family: SettingsData.monoFontFamily
font.weight: Font.Bold
color: {
const pct = parent.parent.usedPct;
if (pct > 0.95)
return Theme.error;
if (pct > 0.85)
return Theme.warning;
return Theme.surfaceText;
}
horizontalAlignment: Text.AlignRight
}
}
}
Rectangle {
anchors.centerIn: parent
width: 300
height: 80
radius: Theme.cornerRadius
color: "transparent"
visible: DgopService.diskMounts.length === 0
Column {
anchors.centerIn: parent
spacing: Theme.spacingM
DankIcon {
name: "storage"
size: 32
color: Theme.surfaceVariantText
anchors.horizontalCenter: parent.horizontalCenter
}
StyledText {
text: I18n.tr("No mount points found", "empty state in disk mounts list")
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceVariantText
anchors.horizontalCenter: parent.horizontalCenter
}
}
}
}
}
}
}
}
|