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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
//
// This file is part of Sugar Light, a theme for the Simple Display Desktop Manager.
//
// Copyright 2018 Marian Arlt
//
// Sugar Light is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Sugar Light 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 General Public License
// along with Sugar Light. If not, see <https://www.gnu.org/licenses/>.
//
import QtQuick 2.11
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.4
Column {
id: inputContainer
Layout.fillWidth: true
property Control exposeLogin: loginButton
Item {
id: usernameField
height: root.font.pointSize * 3.25
width: parent.width / 2
anchors.horizontalCenter: parent.horizontalCenter
TextField {
id: username
text: config.ForceLastUser == "true" ? userModel.lastUser : ""
anchors.centerIn: parent
height: root.font.pointSize * 3
width: parent.width
placeholderText: config.TranslateUsernamePlaceholder || textConstants.userName
selectByMouse: true
horizontalAlignment: TextInput.AlignHCenter
renderType: Text.QtRendering
background: Rectangle {
color: "transparent"
border.color: root.palette.text
border.width: parent.activeFocus ? 2 : 1
radius: config.RoundCorners || 0
}
Keys.onReturnPressed: loginButton.clicked()
KeyNavigation.down: password
}
Button {
id: usernameIcon
anchors.horizontalCenter: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenterOffset: username.height * 0.6
icon.height: username.height * 0.4
icon.width: username.height * 0.4
enabled: false
icon.color: root.palette.text
icon.source: Qt.resolvedUrl("../Assets/User.svgz")
}
states: [
State {
name: "focused"
when: username.activeFocus
PropertyChanges {
target: username.background
border.color: config.AccentColor
}
PropertyChanges {
target: username
color: config.AccentColor
}
}
]
transitions: [
Transition {
PropertyAnimation {
properties: "color, border.color"
duration: 150
}
}
]
}
Item {
id: passwordField
height: root.font.pointSize * 4.5
width: parent.width / 2
anchors.horizontalCenter: parent.horizontalCenter
TextField {
id: password
anchors.centerIn: parent
height: root.font.pointSize * 3
width: parent.width
focus: config.ForcePasswordFocus == "true" ? true : false
selectByMouse: true
echoMode: revealSecret.checked ? TextInput.Normal : TextInput.Password
placeholderText: config.TranslatePasswordPlaceholder || textConstants.password
horizontalAlignment: TextInput.AlignHCenter
passwordCharacter: "•"
passwordMaskDelay: config.ForceHideCompletePassword == "true" ? undefined : 1000
renderType: Text.QtRendering
background: Rectangle {
color: "transparent"
border.color: root.palette.text
border.width: parent.activeFocus ? 2 : 1
radius: config.RoundCorners || 0
}
Keys.onReturnPressed: loginButton.clicked()
KeyNavigation.down: revealSecret
}
states: [
State {
name: "focused"
when: password.activeFocus
PropertyChanges {
target: password.background
border.color: config.AccentColor
}
PropertyChanges {
target: password
color: config.AccentColor
}
}
]
transitions: [
Transition {
PropertyAnimation {
properties: "color, border.color"
duration: 150
}
}
]
}
Item {
id: secretCheckBox
height: root.font.pointSize * 7
width: parent.width / 2
anchors.horizontalCenter: parent.horizontalCenter
CheckBox {
id: revealSecret
width: parent.width
hoverEnabled: true
indicator: Rectangle {
id: indicator
anchors.left: parent.left
implicitHeight: root.font.pointSize
implicitWidth: root.font.pointSize
color: "transparent"
border.color: root.palette.text
border.width: parent.visualFocus ? 2 : 1
Rectangle {
id: dot
anchors.centerIn: parent
implicitHeight: parent.width - 6
implicitWidth: parent.width - 6
color: root.palette.text
opacity: revealSecret.checked ? 1 : 0
}
}
contentItem: Text {
id: indicatorLabel
text: config.TranslateShowPassword || "Show Password"
anchors.verticalCenter: indicator.verticalCenter
horizontalAlignment: Text.AlignLeft
anchors.left: indicator.right
anchors.leftMargin: indicator.width / 2
font.pointSize: root.font.pointSize * 0.75
color: root.palette.text
}
Keys.onReturnPressed: toggle()
KeyNavigation.down: loginButton
}
states: [
State {
name: "pressed"
when: revealSecret.down
PropertyChanges {
target: revealSecret.contentItem
color: Qt.darker(config.AccentColor, 1.2)
}
PropertyChanges {
target: dot
color: Qt.darker(config.AccentColor, 1.2)
}
PropertyChanges {
target: indicator
border.color: Qt.darker(config.AccentColor, 1.2)
}
},
State {
name: "hovered"
when: revealSecret.hovered
PropertyChanges {
target: indicatorLabel
color: Qt.lighter(config.AccentColor, 1.3)
}
PropertyChanges {
target: indicator
border.color: Qt.lighter(config.AccentColor, 1.3)
}
PropertyChanges {
target: dot
color: Qt.lighter(config.AccentColor, 1.3)
}
},
State {
name: "focused"
when: revealSecret.visualFocus
PropertyChanges {
target: indicatorLabel
color: config.AccentColor
}
PropertyChanges {
target: indicator
border.color: config.AccentColor
}
PropertyChanges {
target: dot
color: config.AccentColor
}
}
]
transitions: [
Transition {
PropertyAnimation {
properties: "color, border.color, opacity"
duration: 150
}
}
]
}
Item {
height: root.font.pointSize * 2.3
width: parent.width / 2
anchors.horizontalCenter: parent.horizontalCenter
Label {
id: errorMessage
width: parent.width
text: config.TranslateLoginFailed || textConstants.loginFailed + "!"
horizontalAlignment: Text.AlignHCenter
font.pointSize: root.font.pointSize * 0.8
font.italic: true
color: root.palette.text
opacity: 0
OpacityAnimator on opacity {
id: fadeIn
from: 0;
to: 1;
duration: 200
running: false
}
OpacityAnimator on opacity {
id: fadeOut
from: 1;
to: 0;
duration: 400
running: false
}
}
}
Item {
id: login
height: root.font.pointSize * 3
width: parent.width / 2
anchors.horizontalCenter: parent.horizontalCenter
Button {
id: loginButton
anchors.horizontalCenter: parent.horizontalCenter
text: config.TranslateLogin || textConstants.login
height: root.font.pointSize * 3
implicitWidth: parent.width
enabled: username.text !== "" && password.text !== "" ? true : false
hoverEnabled: true
contentItem: Text {
text: parent.text
color: "white"
font.pointSize: root.font.pointSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
id: buttonBackground
color: root.palette.text
radius: config.RoundCorners || 0
}
states: [
State {
name: "disabled"
when: !loginButton.enabled
PropertyChanges {
target: buttonBackground
color: "#888888"
}
},
State {
name: "pressed"
when: loginButton.down
PropertyChanges {
target: buttonBackground
color: "#444444"
}
},
State {
name: "hovered"
when: loginButton.hovered
PropertyChanges {
target: buttonBackground
color: Qt.lighter(config.AccentColor, 1.2) || Qt.lighter("orange", 1.2)
}
},
State {
name: "focused"
when: loginButton.visualFocus
PropertyChanges {
target: buttonBackground
color: config.AccentColor
}
}
]
transitions: [
Transition {
from: "disabled"; to: ""
PropertyAnimation {
properties: "color"
duration: 500
}
},
Transition {
PropertyAnimation {
properties: "color"
duration: 100
}
}
]
Keys.onReturnPressed: clicked()
onClicked: username.text !== "" && password.text !== "" ? sddm.login(username.text, password.text, sessionSelector.selectedSession) : sddm.loginFailed()
}
}
SessionButton {
id: sessionSelector
textConstantSession: textConstants.session
}
Connections {
target: sddm
onLoginSucceeded: {}
onLoginFailed: {
fadeIn.start()
resetError.running ? resetError.stop() & resetError.start() : resetError.start()
}
}
Timer {
id: resetError
interval: 2000
onTriggered: fadeOut.start()
running: false
}
}
|