forked from BlackKingBarOrg/displaywright-shell-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrangeView.qml
More file actions
226 lines (204 loc) · 6.9 KB
/
Copy pathArrangeView.qml
File metadata and controls
226 lines (204 loc) · 6.9 KB
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
// The whole arrangement interface, in plain QtQuick.
//
// Nothing here imports Quickshell, which is the point: qmltestrunner can build
// it offscreen against a fake controller and check the behaviour without a
// compositor, a shell, or the restart that testing inside the shell costs.
//
// The controller supplies: states, revision, selectedName, geo, snap, pal,
// dirty, problems, busy, notice, countdown, and the actions touch(), apply(),
// keep(), revert(), hide(), autoArrange().
import QtQuick
import QtQuick.Layouts
Item {
id: view
property var controller: null
property var pal: null
readonly property var geo: controller ? controller.geo : null
//: The overlay stands down while a dialog that cannot be drawn above it is
//: on screen. Mirrored here so it can be checked without a compositor.
readonly property bool suspended: !!controller && controller.suspended === true
readonly property var states: controller ? controller.states : []
readonly property bool ready: !!geo
visible: !view.suspended
Rectangle {
anchors.fill: parent
color: view.pal ? view.pal.scrim : "#cc0c0c11"
MouseArea { anchors.fill: parent; onClicked: if (view.controller) view.controller.hide() }
}
Rectangle {
id: panel
anchors.centerIn: parent
width: Math.min(parent.width - 80, 1180)
height: Math.min(parent.height - 80, 760)
radius: 14
color: view.pal ? view.pal.background : "#16161d"
border.color: view.pal ? view.pal.border : "#33333f"
border.width: 1
// Swallow clicks so they do not dismiss through the scrim behind.
MouseArea { anchors.fill: parent }
ColumnLayout {
anchors.fill: parent
anchors.margins: 18
spacing: 12
RowLayout {
Layout.fillWidth: true
Text {
text: "Displays"
color: view.pal ? view.pal.text : "#e6e6ea"
font.pixelSize: 20
font.bold: true
}
Item { Layout.fillWidth: true }
Text {
Layout.maximumWidth: 520
elide: Text.ElideRight
font.pixelSize: 13
text: {
if (!view.controller) return ""
if (view.controller.busy) return view.controller.busy
if (view.controller.problems.length) return view.controller.problems[0]
return view.controller.notice
}
color: view.controller && view.controller.problems.length
? (view.pal ? view.pal.textError : "#f08a8a")
: (view.pal ? view.pal.muted : "#9a9aa6")
}
}
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 14
ArrangeCanvas {
id: canvas
Layout.fillWidth: true
Layout.fillHeight: true
controller: view.controller
pal: view.pal
}
ArrangeSidebar {
Layout.preferredWidth: 320
Layout.fillHeight: true
controller: view.controller
pal: view.pal
popupLayer: popupLayer
}
}
ArrangeWallpapers {
Layout.fillWidth: true
controller: view.controller
pal: view.pal
}
RowLayout {
Layout.fillWidth: true
spacing: 10
Text {
objectName: "summary"
font.pixelSize: 13
color: view.pal ? view.pal.muted : "#9a9aa6"
text: {
if (!view.ready || !view.controller) return ""
view.controller.revision
var on = view.states.filter(function (s) { return s.enabled })
if (!on.length) return "nothing enabled"
var box = view.geo.boundingBox(on.map(view.geo.rectOf))
return on.length + " display" + (on.length === 1 ? "" : "s")
+ " · " + Math.round(box.w) + "×" + Math.round(box.h)
+ (view.controller.dirty ? " · unapplied changes" : "")
}
}
Item { Layout.fillWidth: true }
ArrangeButton {
objectName: "autoArrange"
pal: view.pal
label: "Auto arrange"
onTriggered: if (view.controller) view.controller.autoArrange()
}
ArrangeButton {
pal: view.pal
label: "Close"
onTriggered: if (view.controller) view.controller.hide()
}
ArrangeButton {
objectName: "apply"
pal: view.pal
label: "Apply"
primary: true
enabled: !!view.controller && view.controller.dirty && view.controller.busy === ""
onTriggered: if (view.controller) view.controller.apply()
}
}
}
// Keep-or-revert, defaulting to revert: a display that went black cannot
// lock anybody out while this is on screen.
Rectangle {
objectName: "countdownDialog"
anchors.fill: parent
radius: parent.radius
color: view.pal ? view.pal.scrim : "#cc0c0c11"
visible: !!view.controller && view.controller.countdown > 0
MouseArea { anchors.fill: parent }
Rectangle {
anchors.centerIn: parent
width: 460
height: 156
radius: 12
color: view.pal ? view.pal.background : "#16161d"
border.color: view.pal ? view.pal.countdown : "#e8b04b"
border.width: 2
ColumnLayout {
anchors.fill: parent
anchors.margins: 18
spacing: 10
Text {
text: "Keep this arrangement?"
color: view.pal ? view.pal.text : "#e6e6ea"
font.pixelSize: 17
font.bold: true
}
Text {
Layout.fillWidth: true
wrapMode: Text.WordWrap
color: view.pal ? view.pal.muted : "#9a9aa6"
font.pixelSize: 13
text: view.controller
? "Reverting in " + view.controller.countdown + "s if you do not confirm, "
+ "and saving to monitors.lua if you do."
: ""
}
RowLayout {
Layout.fillWidth: true
Item { Layout.fillWidth: true }
ArrangeButton {
objectName: "revert"
pal: view.pal
label: "Revert"
onTriggered: if (view.controller) view.controller.revert()
}
ArrangeButton {
objectName: "keep"
pal: view.pal
label: "Keep"
primary: true
onTriggered: if (view.controller) view.controller.keep()
}
}
}
}
}
// Anything that has to escape the layouts is drawn here. `z` only orders
// siblings, so a list inside a sidebar row is covered by the rows beneath
// it however high its z -- it has to be reparented out to be on top.
Item {
id: popupLayer
objectName: "popupLayer"
anchors.fill: parent
z: 1000
}
focus: true
Keys.onEscapePressed: {
if (!view.controller) return
if (view.controller.countdown > 0) view.controller.revert()
else view.controller.hide()
}
}
}