aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/appearance/UdtTab.qml
blob: b4d14b70b312e4ebde41a4a3e3fb86cb9b29121b (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
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import QtQuick
import "../.."

// The live scheme, accent and both wallpapers, then every consumer install.sh
// knows, each with a button that re-applies the theme to it alone.
Column {
    id: tab
    spacing: 10

    // A value set on another settings page links to it.
    signal go(string name)

    Component.onCompleted: Udt.refreshStatus()

    Repeater {
        model: [
            { label: "Theme", value: Udt.current, page: "theme" },
            { label: "Accent", value: String(Theme.accent), swatch: true },
            { label: "Wallpaper H", value: Wallpapers.basename(Wallpapers.currentH), page: "wallpaper" },
            { label: "Wallpaper V", value: Wallpapers.basename(Wallpapers.currentV), page: "wallpaper" },
        ]

        Row {
            required property var modelData
            spacing: 8

            Text {
                width: 100
                text: modelData.label
                color: Theme.overlay
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
            }
            Rectangle {
                anchors.verticalCenter: parent.verticalCenter
                visible: modelData.swatch ?? false
                width: 16; height: 16; radius: 4
                color: Theme.accent
                border.width: 1
                border.color: Qt.alpha(Theme.text, 0.1)
            }
            Text {
                id: value
                width: Math.min(implicitWidth, tab.width - 140)
                elide: Text.ElideMiddle
                text: modelData.value || "-"
                color: modelData.page && link.containsMouse ? Theme.accent : Theme.text
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3; bold: !!modelData.page }

                MouseArea {
                    id: link
                    anchors.fill: parent
                    enabled: !!modelData.page
                    hoverEnabled: true
                    cursorShape: Qt.PointingHandCursor
                    onClicked: tab.go(modelData.page)
                }
            }
            Text {
                anchors.verticalCenter: parent.verticalCenter
                visible: !!modelData.page
                // nf-fa-chevron_right
                text: "\uf054"
                color: link.containsMouse ? Theme.accent : Theme.overlay
                font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 6 }
            }
        }
    }

    Text {
        width: tab.width
        wrapMode: Text.Wrap
        text: "Re-applying runs install.sh for that consumer alone; Re-apply all in the header runs it for every one. A failure's output lands in the steps window."
        color: Theme.overlay
        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
    }

    // Apps and devices, in install.sh's order.
    Repeater {
        model: [{ kind: "software", label: "Software" }, { kind: "hardware", label: "Hardware" }]

        Column {
            id: section
            required property var modelData
            readonly property string kind: modelData.kind
            width: tab.width
            spacing: 6

            Text {
                topPadding: 6
                text: section.modelData.label
                color: Theme.subtext
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
            }

            Repeater {
                model: Array.from(Udt.consumers).filter(n => Udt.consumerKind[n] === section.kind)

                Rectangle {
                    required property string modelData
                    // What a search hit scrolls to (UdtModule's searchItems key).
                    objectName: modelData
                    readonly property var result: Udt.reapplied[modelData]

                    width: section.width
                    implicitHeight: 46
                    radius: 8
                    color: Qt.alpha(Theme.surface, 0.4)

                    Column {
                        anchors.verticalCenter: parent.verticalCenter
                        x: 12
                        Text {
                            text: modelData
                            color: Theme.text
                            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
                        }
                        Text {
                            text: Udt.consumerInfo[modelData] ?? ""
                            visible: text !== ""
                            color: Theme.overlay
                            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 5 }
                        }
                    }

                    Row {
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.right: parent.right
                        anchors.rightMargin: 8
                        spacing: 10

                        Text {
                            anchors.verticalCenter: parent.verticalCenter
                            visible: Udt.isReapplying(modelData) || result !== undefined
                            text: Udt.isReapplying(modelData) ? "applying…"
                                : result ? "" : ""
                            color: Udt.isReapplying(modelData) ? Theme.overlay
                                 : result ? Theme.green : Theme.red
                            font {
                                family: Udt.isReapplying(modelData) ? Theme.fontFamily : Theme.iconFamily
                                pixelSize: Theme.fontSize - 3
                            }
                        }
                        Button {
                            // nf-fa-refresh
                            icon: ""
                            text: "Re-apply"
                            enabled: Udt.reapplying === "" && !Udt.applying
                            onClicked: Udt.reapply(modelData)
                        }
                    }
                }
            }
        }
    }
}