aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/appearance/WallEngineTab.qml
blob: dff93868dfbf9c1713d955c3eed0aaf20390eff2 (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
// 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
            Toggle {
                anchors.verticalCenter: parent.verticalCenter
                checked: WallEngine.on
                label: "Change the wallpapers every"
                onToggled: WallEngine.setOn(checked)
            }
            Field {
                anchors.verticalCenter: parent.verticalCenter
                width: 50
                value: String(WallEngine.cfg.minutes)
                onEdited: {
                    WallEngine.setMinutes(Number(value));
                    value = String(WallEngine.cfg.minutes);
                }
            }
            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. "
                + "Switching off 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
                width: col.width
                spacing: 8

                Text {
                    text: `${screen.modelData.name}: ${screen.paths.length} hearted`
                        + (WallEngine.on && screen.home !== "" ? `, home ${Wallpapers.label(screen.home)}` : "")
                    color: Theme.subtext
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
                }

                Text {
                    visible: 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 {
                    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: ""
                                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)
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}