Debian Codegraph @

src/applet/contents/ui/main.qml

raw
1 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
2 // SPDX-FileCopyrightText: 2024 Stefan Dimitrijevic <[email protected]>
3 // SPDX-FileCopyrightText: 2022 Harald Sitter <[email protected]>
4
5 import QtQuick
6 import QtQuick.Controls as QQC2
7 import QtQuick.Layouts
8
9 import org.kde.plasma.core as PlasmaCore
10 import org.kde.plasma.extras as PlasmaExtras
11 import org.kde.plasma.plasmoid
12 import org.kde.kirigami as Kirigami
13
14 import org.kde.plasma.private.gamemode
15
16 PlasmoidItem {
17 id: main
18
19 GamesModel {
20 id: gamesModel
21 }
22
23 property int count: gamesModel.rowCount
24 property bool gamesEmpty: count <= 0
25
26 switchWidth: Kirigami.Units.gridUnit * 5
27 switchHeight: Kirigami.Units.gridUnit * 5
28
29 Plasmoid.status: gamesEmpty ? PlasmaCore.Types.PassiveStatus : PlasmaCore.Types.ActiveStatus
30 Plasmoid.icon: "input-gamepad-symbolic"
31 toolTipMainText: gamesEmpty ? i18nc("@info", "Gamemode inactive") : i18nc("@info", "Gamemode active")
32 toolTipSubText: gamesEmpty ? i18nc("@info process count in gamemode", "No active processes") : i18ncp("@info process count in gamemode", "%1 process", "%1 processes", count)
33 toolTipTextFormat: Text.PlainText
34
35 fullRepresentation: PlasmaExtras.Representation {
36 id: dialogItem
37
38 Layout.minimumHeight: Kirigami.Units.gridUnit * 10
39 Layout.minimumWidth: Kirigami.Units.gridUnit * 10
40 Layout.preferredHeight: Kirigami.Units.gridUnit * 10
41 Layout.preferredWidth: Kirigami.Units.gridUnit * 10
42
43 collapseMarginsHint: true
44
45 contentItem: ListView {
46 id: view
47
48 Layout.preferredHeight: Kirigami.Units.gridUnit * 10
49 Layout.preferredWidth: Kirigami.Units.gridUnit * 10
50 anchors.fill: parent
51 model: gamesModel
52
53 delegate: PlasmaExtras.ExpandableListItem {
54 icon: "input-gamepad"
55 title: executable
56 subtitle: i18nc("@label", "PID: %1", String(processid))
57 }
58
59 QQC2.Action {
60 id: helpAction
61 icon.name: "help-contextual"
62 text: i18nc("@action open help url", "Help!")
63 onTriggered: Qt.openUrlExternally('https://github.com/FeralInteractive/gamemode')
64 }
65
66 PlasmaExtras.PlaceholderMessage {
67 visible: gamesModel.serviceRegistered && gamesEmpty
68 anchors.centerIn: parent
69 width: parent.width - (Kirigami.Units.gridUnit * 4)
70
71 text: i18nc("@info", "No Processes in Gamemode")
72 helpfulAction: helpAction
73 }
74
75 PlasmaExtras.PlaceholderMessage {
76 visible: !gamesModel.serviceRegistered
77 anchors.centerIn: parent
78 width: parent.width - (Kirigami.Units.gridUnit * 4)
79
80 text: i18nc("@info", "Gamemode Service not Running")
81 helpfulAction: helpAction
82 }
83 }
84 }
85 }