forked from MarianArlt/sddm-chili
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.qml
executable file
·318 lines (278 loc) · 10.7 KB
/
Main.qml
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*
* Copyright 2018 Marian Arlt <[email protected]>
* Copyright 2016 David Edmundson <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 3 or
* (at your option) any later version.
*
* 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
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.2
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import SddmComponents 2.0
import "components"
Rectangle {
id: root
width: 1600
height: 900
property string notificationMessage
property string generalFontColor: "white"
property int generalFontSize: config.changeFontPointSize ? config.changeFontPointSize : root.height / 80
TextConstants { id: textConstants }
Repeater {
model: screenModel
Wallpaper {
x: geometry.x
y: geometry.y
width: geometry.width
height: geometry.height
imageSource: config.background
}
}
ColumnLayout {
id: container
anchors.fill: parent
LayoutMirroring.enabled: Qt.locale().textDirection == Qt.RightToLeft
LayoutMirroring.childrenInherit: true
RowLayout {
id: header
Layout.alignment: Qt.AlignRight
Layout.fillHeight: false
Layout.topMargin: generalFontSize
Layout.rightMargin: generalFontSize * 1.5
KeyboardLayoutButton {
Layout.topMargin: -1
implicitHeight: clockLabel.height * 1.2
implicitWidth: clockLabel.height * 1.8
}
Item {
id: clock
Layout.fillHeight: true
Layout.minimumWidth: clockLabel.width
Label {
id: clockLabel
color: generalFontColor
font.pointSize: root.generalFontSize
renderType: Text.QtRendering
function updateTime() {
text = new Date().toLocaleString(Qt.locale("en_US"), "ddd dd MMMM, hh:mm A")
}
}
Timer {
interval: 1000
repeat: true
running: true
onTriggered: {
clockLabel.updateTime()
}
}
Component.onCompleted: {
clockLabel.updateTime()
}
}
}
StackView {
id: loginFormStack
Layout.fillHeight: true
Layout.fillWidth: true
focus: true // StackView is an implicit focus scope. Therefore focus needs to be passed to its children.
initialItem: LoginForm {
id: userListComponent
userListModel: userModel
userListCurrentIndex: userModel.lastIndex >= 0 ? userModel.lastIndex : 0
lastUserName: userModel.lastUser
usernameFontSize: root.generalFontSize
usernameFontColor: root.generalFontColor
faceSize: config.changeAvatarPixelSize ? config.changeAvatarPixelSize : root.width / 15
showUserList: {
if ( !userListModel.hasOwnProperty("count") || !userListModel.hasOwnProperty("disableAvatarsThreshold") )
return (userList.y + mainStack.y) > 0
if ( userListModel.count == 0 )
return false
return userListModel.count <= userListModel.disableAvatarsThreshold && (userList.y + loginFormStack.y) > 0
}
notificationMessage: {
var text = ""
text += root.notificationMessage
return text
}
actionItems: [
ActionButton {
iconSource: "assets/suspend.svgz"
text: config.translationSuspend ? config.translationSuspend : "Suspend"
onClicked: sddm.suspend()
enabled: sddm.canSuspend
iconSize: root.generalFontSize * 3
},
ActionButton {
iconSource: "assets/reboot.svgz"
text: config.translationReboot ? config.translationReboot : textConstants.reboot
onClicked: sddm.reboot()
enabled: sddm.canReboot
iconSize: root.generalFontSize * 3
},
ActionButton {
iconSource: "assets/shutdown.svgz"
text: config.translationPowerOff ? config.translationPowerOff : textConstants.shutdown
onClicked: sddm.powerOff()
enabled: sddm.canPowerOff
iconSize: root.generalFontSize * 3
}
]
onLoginRequest: {
root.notificationMessage = ""
sddm.login(username, password, sessionMenu.currentIndex)
}
}
Behavior on opacity {
OpacityAnimator {
duration: 150
}
}
}
Loader {
id: inputPanel
state: "hidden"
property bool keyboardActive: item ? item.active : false
onKeyboardActiveChanged: {
if (keyboardActive) {
state = "visible"
} else {
state = "hidden";
}
}
source: "components/VirtualKeyboard.qml"
anchors {
left: parent.left
right: parent.right
}
function showHide() {
state = state == "hidden" ? "visible" : "hidden";
}
states: [
State {
name: "visible"
PropertyChanges {
target: mainStack
y: Math.min(0, root.height - inputPanel.height - userListComponent.visibleBoundary)
}
PropertyChanges {
target: inputPanel
y: root.height - inputPanel.height
opacity: 1
}
},
State {
name: "hidden"
PropertyChanges {
target: mainStack
y: 0
}
PropertyChanges {
target: inputPanel
y: root.height - root.height/4
opacity: 0
}
}
]
transitions: [
Transition {
from: "hidden"
to: "visible"
SequentialAnimation {
ScriptAction {
script: {
inputPanel.item.activated = true;
Qt.inputMethod.show();
}
}
ParallelAnimation {
NumberAnimation {
target: mainStack
property: "y"
duration: units.longDuration
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: inputPanel
property: "y"
duration: units.longDuration
easing.type: Easing.OutQuad
}
OpacityAnimator {
target: inputPanel
duration: units.longDuration
easing.type: Easing.OutQuad
}
}
}
},
Transition {
from: "visible"
to: "hidden"
SequentialAnimation {
ParallelAnimation {
NumberAnimation {
target: mainStack
property: "y"
duration: units.longDuration
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: inputPanel
property: "y"
duration: units.longDuration
easing.type: Easing.InQuad
}
OpacityAnimator {
target: inputPanel
duration: units.longDuration
easing.type: Easing.InQuad
}
}
ScriptAction {
script: {
Qt.inputMethod.hide();
}
}
}
}
]
}
RowLayout {
id: footer
Layout.fillHeight: false
Layout.alignment: Qt.AlignBottom
Layout.bottomMargin: generalFontSize
Layout.leftMargin: generalFontSize * 1.5
SessionMenu {
id: sessionMenu
rootFontSize: root.generalFontSize
rootFontColor: root.generalFontColor
}
}
Connections {
target: sddm
onLoginFailed: {
notificationMessage = textConstants.loginFailed
notificationResetTimer.start();
}
}
Timer {
id: notificationResetTimer
interval: 3000
onTriggered: notificationMessage = ""
}
}
}