aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/appearance/WallEngineTab.qml
blob: 3f72d83933369adcc710b39b9cf1a9203cc13170 (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
// 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 "../.."

Item {
    implicitHeight: col.implicitHeight

    Column {
        id: col
        width: parent.width
        spacing: 14

        Row {
            spacing: 8
            Text {
                anchors.verticalCenter: parent.verticalCenter
                text: "Change the wallpapers every"
                color: Theme.subtext
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
            }
            Field {
                anchors.verticalCenter: parent.verticalCenter
                width: 50
                value: String(WallEngine.draftMinutes)
                // On every keystroke, not on edited: that waits for Enter
                // or a focus change, and clicking Start takes neither, so a
                // typed interval was silently left at the old one.
                onValueChanged: WallEngine.setDraftMinutes(Number(value))
                onEdited: value = String(WallEngine.draftMinutes)
            }
            Text {
                anchors.verticalCenter: parent.verticalCenter
                text: "minutes"
                color: Theme.subtext
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
            }
            Tab {
                text: "Next"
                enabled: WallEngine.on && !Wallpapers.applying
                onClicked: if (enabled) WallEngine.next()
            }
        }

        Text {
            width: col.width
            wrapMode: Text.Wrap
            text: "Timer changes recolour the desktop and leave GRUB, the homepage and the login screen alone. "
                + "Stop puts back each screen's home wallpaper, the one last applied by hand, with a full run."
            color: Theme.overlay
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
        }

        Repeater {
            model: [{ which: "H", name: "Horizontal, DP-1" }, { which: "V", name: "Vertical, DP-3" }]

            Column {
                id: screen
                required property var modelData
                readonly property var paths: WallEngine.list(modelData.which)
                readonly property string home: modelData.which === "V" ? WallEngine.cfg.homeV : WallEngine.cfg.homeH
                // The draft's source: what Start or Apply will use.
                readonly property string folder: WallEngine.draftFolder(modelData.which)
                readonly property var group: Wallpapers.groups.find(g => g.key === folder) ?? null
                width: col.width
                spacing: 8

                Text {
                    text: screen.modelData.name + ": "
                        + (screen.folder === "" ? `${screen.paths.length} hearted`
                           : screen.group ? `${screen.group.files.length} in ${screen.group.name}`
                           : "the folder is gone, so this screen stays as it is")
                        + (WallEngine.on && screen.home !== "" ? `, home ${Wallpapers.label(screen.home)}` : "")
                    color: Theme.subtext
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
                }

                // Where the timer draws from: the hearts, or one gallery
                // folder in their place.
                Flow {
                    width: col.width
                    spacing: 6
                    Tab {
                        text: "Hearted"
                        selected: screen.folder === ""
                        onClicked: WallEngine.setDraftFolder(screen.modelData.which, "")
                    }
                    Repeater {
                        model: Wallpapers.groups
                        Tab {
                            required property var modelData
                            text: modelData.name
                            selected: screen.folder === modelData.key
                            onClicked: WallEngine.setDraftFolder(screen.modelData.which, modelData.key)
                        }
                    }
                }

                Text {
                    visible: screen.folder === "" && screen.paths.length === 0
                    text: "Heart a wallpaper on the Wallpaper page, with this screen selected, to add it."
                    color: Theme.overlay
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                }

                Flow {
                    visible: screen.folder === ""
                    width: col.width
                    spacing: 8

                    Repeater {
                        model: screen.paths

                        // Dimmed when the gallery's scan did not find it: the
                        // timer skips it.
                        Rectangle {
                            id: entry
                            required property string modelData
                            width: 192; height: 108 + 20
                            radius: 6
                            color: Qt.alpha(Theme.surface, 0.3)
                            opacity: WallEngine.present(modelData) ? 1 : 0.4
                            clip: true

                            Image {
                                id: thumb
                                anchors { top: parent.top; left: parent.left; right: parent.right; margins: 4 }
                                height: 100
                                source: "file://" + entry.modelData
                                asynchronous: true
                                cache: false
                                fillMode: Image.PreserveAspectCrop
                                sourceSize.width: 192
                            }
                            Text {
                                anchors { top: thumb.bottom; left: parent.left; right: parent.right; margins: 4 }
                                elide: Text.ElideMiddle
                                text: Wallpapers.label(entry.modelData)
                                color: Theme.subtext
                                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 6 }
                            }
                            // nf-fa-xmark: out of the list.
                            Text {
                                anchors { top: parent.top; right: parent.right; margins: 8 }
                                text: "\uf00d"
                                color: Theme.text
                                style: Text.Outline
                                styleColor: Qt.alpha(Theme.base, 0.6)
                                font { family: Theme.iconFamily; pixelSize: Theme.fontSize }
                                MouseArea {
                                    anchors { fill: parent; margins: -4 }
                                    cursorShape: Qt.PointingHandCursor
                                    onClicked: WallEngine.toggle(entry.modelData, screen.modelData.which)
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}