summaryrefslogtreecommitdiff
path: root/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/ProcessList/SystemView.qml
blob: 244129d804cca804a8ad8c9b477f2fc76f5328e5 (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
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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
import QtQuick
import QtQuick.Layouts
import qs.Common
import qs.Services
import qs.Widgets

Item {
    id: root

    Component.onCompleted: {
        DgopService.addRef(["system", "cpu"]);
    }

    Component.onDestruction: {
        DgopService.removeRef(["system", "cpu"]);
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: Theme.spacingM

        Rectangle {
            Layout.fillWidth: true
            Layout.preferredHeight: systemInfoColumn.implicitHeight + Theme.spacingM * 2
            radius: Theme.cornerRadius
            color: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)

            ColumnLayout {
                id: systemInfoColumn
                anchors.fill: parent
                anchors.margins: Theme.spacingM
                spacing: Theme.spacingM

                Row {
                    spacing: Theme.spacingS

                    DankIcon {
                        name: "computer"
                        size: Theme.iconSize
                        color: Theme.primary
                        anchors.verticalCenter: parent.verticalCenter
                    }

                    StyledText {
                        text: I18n.tr("System Information", "system info header in system monitor")
                        font.pixelSize: Theme.fontSizeLarge
                        font.weight: Font.Bold
                        color: Theme.surfaceText
                        anchors.verticalCenter: parent.verticalCenter
                    }
                }

                GridLayout {
                    Layout.fillWidth: true
                    columns: 2
                    rowSpacing: Theme.spacingS
                    columnSpacing: Theme.spacingXL

                    InfoRow {
                        label: I18n.tr("Hostname", "system info label")
                        value: DgopService.hostname || "--"
                    }
                    InfoRow {
                        label: I18n.tr("Distribution", "system info label")
                        value: DgopService.distribution || "--"
                    }
                    InfoRow {
                        label: I18n.tr("Kernel", "system info label")
                        value: DgopService.kernelVersion || "--"
                    }
                    InfoRow {
                        label: I18n.tr("Architecture", "system info label")
                        value: DgopService.architecture || "--"
                    }
                    InfoRow {
                        label: I18n.tr("CPU")
                        value: DgopService.cpuModel || ("" + DgopService.cpuCores + " cores")
                    }
                    InfoRow {
                        label: I18n.tr("Uptime")
                        value: DgopService.uptime || "--"
                    }
                    InfoRow {
                        label: I18n.tr("Load Average", "system info label")
                        value: DgopService.loadAverage || "--"
                    }
                    InfoRow {
                        label: I18n.tr("Processes")
                        value: DgopService.processCount > 0 ? DgopService.processCount.toString() : "--"
                    }
                }
            }
        }

        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.spacingM

                Row {
                    spacing: Theme.spacingS

                    DankIcon {
                        name: "developer_board"
                        size: Theme.iconSize
                        color: Theme.secondary
                        anchors.verticalCenter: parent.verticalCenter
                    }

                    StyledText {
                        text: I18n.tr("GPU Monitoring", "gpu section header in system monitor")
                        font.pixelSize: Theme.fontSizeLarge
                        font.weight: Font.Bold
                        color: Theme.surfaceText
                        anchors.verticalCenter: parent.verticalCenter
                    }
                }

                Rectangle {
                    Layout.fillWidth: true
                    Layout.preferredHeight: 1
                    color: Theme.outlineLight
                }

                DankListView {
                    id: gpuListView

                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    clip: true
                    spacing: 8

                    model: DgopService.availableGpus

                    delegate: Rectangle {
                        required property var modelData
                        required property int index

                        width: gpuListView.width
                        height: 80
                        radius: Theme.cornerRadius
                        color: {
                            const vendor = (modelData?.vendor ?? "").toLowerCase();
                            if (vendor.includes("nvidia"))
                                return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.08);
                            if (vendor.includes("amd"))
                                return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.08);
                            if (vendor.includes("intel"))
                                return Qt.rgba(Theme.info.r, Theme.info.g, Theme.info.b, 0.08);
                            return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08);
                        }
                        border.color: {
                            const vendor = (modelData?.vendor ?? "").toLowerCase();
                            if (vendor.includes("nvidia"))
                                return Qt.rgba(Theme.success.r, Theme.success.g, Theme.success.b, 0.2);
                            if (vendor.includes("amd"))
                                return Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.2);
                            if (vendor.includes("intel"))
                                return Qt.rgba(Theme.info.r, Theme.info.g, Theme.info.b, 0.2);
                            return Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.2);
                        }
                        border.width: 1

                        readonly property bool tempEnabled: {
                            const pciId = modelData?.pciId ?? "";
                            if (!pciId)
                                return false;
                            return SessionData.enabledGpuPciIds ? SessionData.enabledGpuPciIds.indexOf(pciId) !== -1 : false;
                        }

                        RowLayout {
                            anchors.fill: parent
                            anchors.margins: Theme.spacingM
                            spacing: Theme.spacingM

                            DankIcon {
                                name: "developer_board"
                                size: Theme.iconSize + 4
                                color: {
                                    const vendor = (modelData?.vendor ?? "").toLowerCase();
                                    if (vendor.includes("nvidia"))
                                        return Theme.success;
                                    if (vendor.includes("amd"))
                                        return Theme.error;
                                    if (vendor.includes("intel"))
                                        return Theme.info;
                                    return Theme.surfaceVariantText;
                                }
                            }

                            Column {
                                Layout.fillWidth: true
                                spacing: Theme.spacingXS

                                StyledText {
                                    text: modelData?.displayName ?? I18n.tr("Unknown GPU", "fallback gpu name")
                                    font.pixelSize: Theme.fontSizeMedium
                                    font.weight: Font.Bold
                                    color: Theme.surfaceText
                                }

                                Row {
                                    spacing: Theme.spacingS

                                    StyledText {
                                        text: modelData?.vendor ?? ""
                                        font.pixelSize: Theme.fontSizeSmall
                                        color: Theme.surfaceVariantText
                                    }

                                    StyledText {
                                        text: "•"
                                        font.pixelSize: Theme.fontSizeSmall
                                        color: Theme.surfaceVariantText
                                        visible: (modelData?.driver ?? "").length > 0
                                    }

                                    StyledText {
                                        text: modelData?.driver ?? ""
                                        font.pixelSize: Theme.fontSizeSmall
                                        color: Theme.surfaceVariantText
                                        visible: (modelData?.driver ?? "").length > 0
                                    }
                                }

                                StyledText {
                                    text: modelData?.pciId ?? ""
                                    font.pixelSize: Theme.fontSizeSmall - 2
                                    font.family: SettingsData.monoFontFamily
                                    color: Theme.surfaceVariantText
                                    opacity: 0.7
                                }
                            }

                            Rectangle {
                                width: 70
                                height: 32
                                radius: Theme.cornerRadius
                                color: parent.parent.tempEnabled ? Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.15)
                                border.color: tempMouseArea.containsMouse ? Theme.outline : "transparent"
                                border.width: 1

                                Row {
                                    id: tempRow
                                    anchors.centerIn: parent
                                    spacing: Theme.spacingXS

                                    DankIcon {
                                        name: "thermostat"
                                        size: 16
                                        color: {
                                            if (!parent.parent.parent.parent.tempEnabled)
                                                return Theme.surfaceVariantText;
                                            const temp = modelData?.temperature ?? 0;
                                            if (temp > 85)
                                                return Theme.error;
                                            if (temp > 70)
                                                return Theme.warning;
                                            return Theme.surfaceText;
                                        }
                                        opacity: parent.parent.parent.parent.tempEnabled ? 1 : 0.5
                                        anchors.verticalCenter: parent.verticalCenter
                                    }

                                    StyledText {
                                        text: {
                                            if (!parent.parent.parent.parent.tempEnabled)
                                                return I18n.tr("Off");
                                            const temp = modelData?.temperature ?? 0;
                                            return temp > 0 ? (temp.toFixed(0) + "°C") : "--";
                                        }
                                        font.pixelSize: Theme.fontSizeSmall
                                        font.family: parent.parent.parent.parent.tempEnabled ? SettingsData.monoFontFamily : ""
                                        font.weight: parent.parent.parent.parent.tempEnabled ? Font.Bold : Font.Normal
                                        color: {
                                            if (!parent.parent.parent.parent.tempEnabled)
                                                return Theme.surfaceVariantText;
                                            const temp = modelData?.temperature ?? 0;
                                            if (temp > 85)
                                                return Theme.error;
                                            if (temp > 70)
                                                return Theme.warning;
                                            return Theme.surfaceText;
                                        }
                                        anchors.verticalCenter: parent.verticalCenter
                                    }
                                }

                                MouseArea {
                                    id: tempMouseArea
                                    anchors.fill: parent
                                    hoverEnabled: true
                                    cursorShape: Qt.PointingHandCursor
                                    onClicked: {
                                        const pciId = modelData?.pciId;
                                        if (!pciId)
                                            return;

                                        const enabledIds = SessionData.enabledGpuPciIds ? SessionData.enabledGpuPciIds.slice() : [];
                                        const idx = enabledIds.indexOf(pciId);
                                        const wasEnabled = idx !== -1;

                                        if (!wasEnabled) {
                                            enabledIds.push(pciId);
                                            DgopService.addGpuPciId(pciId);
                                        } else {
                                            enabledIds.splice(idx, 1);
                                            DgopService.removeGpuPciId(pciId);
                                        }

                                        SessionData.setEnabledGpuPciIds(enabledIds);
                                    }
                                }

                                Behavior on color {
                                    ColorAnimation {
                                        duration: Theme.shortDuration
                                    }
                                }
                            }
                        }
                    }

                    Rectangle {
                        anchors.centerIn: parent
                        width: 300
                        height: 100
                        radius: Theme.cornerRadius
                        color: "transparent"
                        visible: DgopService.availableGpus.length === 0

                        Column {
                            anchors.centerIn: parent
                            spacing: Theme.spacingM

                            DankIcon {
                                name: "developer_board_off"
                                size: 32
                                color: Theme.surfaceVariantText
                                anchors.horizontalCenter: parent.horizontalCenter
                            }

                            StyledText {
                                text: I18n.tr("No GPUs detected", "empty state in gpu list")
                                font.pixelSize: Theme.fontSizeMedium
                                color: Theme.surfaceVariantText
                                anchors.horizontalCenter: parent.horizontalCenter
                            }
                        }
                    }
                }
            }
        }
    }

    component InfoRow: RowLayout {
        property string label: ""
        property string value: ""

        Layout.fillWidth: true
        spacing: Theme.spacingS

        StyledText {
            text: label + ":"
            font.pixelSize: Theme.fontSizeSmall
            font.weight: Font.Medium
            color: Theme.surfaceVariantText
            Layout.preferredWidth: 100
        }

        StyledText {
            text: value
            font.pixelSize: Theme.fontSizeSmall
            font.family: SettingsData.monoFontFamily
            color: Theme.surfaceText
            Layout.fillWidth: true
            elide: Text.ElideRight
        }
    }
}