mirror of
https://github.com/Keyitdev/sddm-astronaut-theme.git
synced 2026-09-24 02:22:09 +00:00
Fix: Removed useless KeyNavigation and key events. Fixed typos. Cleaned up some code.
This commit is contained in:
+102
-74
@@ -9,25 +9,32 @@ import QtQuick.Controls 2.15
|
||||
|
||||
Column {
|
||||
id: inputContainer
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
property ComboBox exposeSession: sessionSelect.exposeSession
|
||||
property bool failed
|
||||
|
||||
Item {
|
||||
id: errorMessageField
|
||||
|
||||
// change also in selectSession
|
||||
height: root.font.pointSize * 2
|
||||
width: parent.width / 2
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
Label {
|
||||
id: errorMessage
|
||||
|
||||
width: parent.width
|
||||
text: failed ? config.TranslateLoginFailedWarning || textConstants.loginFailed + "!" : keyboard.capsLock ? config.TranslateCapslockWarning || textConstants.capslockWarning : null
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
||||
text: failed ? config.TranslateLoginFailedWarning || textConstants.loginFailed + "!" : keyboard.capsLock ? config.TranslateCapslockWarning || textConstants.capslockWarning : null
|
||||
font.pointSize: root.font.pointSize * 0.8
|
||||
font.italic: true
|
||||
color: config.WarningColor
|
||||
opacity: 0
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "fail"
|
||||
@@ -65,22 +72,11 @@ Column {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
ComboBox {
|
||||
|
||||
id: selectUser
|
||||
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
anchors.left: parent.left
|
||||
|
||||
property var popkey: config.RightToLeftLayout == "true" ? Qt.Key_Right : Qt.Key_Left
|
||||
Keys.onPressed: function(event) {
|
||||
if (event.key == Qt.Key_Down && !popup.opened)
|
||||
username.forceActiveFocus();
|
||||
if ((event.key == Qt.Key_Up || event.key == popkey) && !popup.opened)
|
||||
popup.open();
|
||||
}
|
||||
KeyNavigation.down: username
|
||||
KeyNavigation.right: username
|
||||
z: 2
|
||||
|
||||
model: userModel
|
||||
@@ -91,42 +87,56 @@ Column {
|
||||
username.text = currentText
|
||||
}
|
||||
|
||||
property var popkey: config.RightToLeftLayout == "true" ? Qt.Key_Right : Qt.Key_Left
|
||||
Keys.onPressed: function(event) {
|
||||
if (event.key == Qt.Key_Down && !popup.opened)
|
||||
username.forceActiveFocus();
|
||||
if ((event.key == Qt.Key_Up || event.key == popkey) && !popup.opened)
|
||||
popup.open();
|
||||
}
|
||||
KeyNavigation.down: username
|
||||
KeyNavigation.right: username
|
||||
|
||||
delegate: ItemDelegate {
|
||||
// minus padding
|
||||
width: popupHandler.width - 20
|
||||
anchors.horizontalCenter: popupHandler.horizontalCenter
|
||||
|
||||
contentItem: Text {
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
||||
text: model.name
|
||||
font.pointSize: root.font.pointSize * 0.8
|
||||
font.capitalization: Font.AllLowercase
|
||||
font.family: root.font.family
|
||||
color: config.DropdownTextColor
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
// highlighted: parent.highlightedIndex === index
|
||||
|
||||
background: Rectangle {
|
||||
color: selectUser.highlightedIndex === index ? config.DropdownSelectedBackgroundColor : "transparent"
|
||||
}
|
||||
}
|
||||
|
||||
indicator: Button {
|
||||
id: usernameIcon
|
||||
width: selectUser.height * 1
|
||||
height: parent.height
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: selectUser.height * 0
|
||||
icon.height: parent.height * 0.25
|
||||
icon.width: parent.height * 0.25
|
||||
enabled: false
|
||||
icon.color: config.UserIconColor
|
||||
icon.source: Qt.resolvedUrl("../Assets/User.svg")
|
||||
id: usernameIcon
|
||||
|
||||
background: Rectangle {
|
||||
color: "transparent"
|
||||
border.color: "transparent"
|
||||
}
|
||||
width: selectUser.height * 1
|
||||
height: parent.height
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: selectUser.height * 0
|
||||
|
||||
icon.height: parent.height * 0.25
|
||||
icon.width: parent.height * 0.25
|
||||
enabled: false
|
||||
icon.color: config.UserIconColor
|
||||
icon.source: Qt.resolvedUrl("../Assets/User.svg")
|
||||
|
||||
background: Rectangle {
|
||||
color: "transparent"
|
||||
border.color: "transparent"
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
@@ -136,16 +146,18 @@ Column {
|
||||
|
||||
popup: Popup {
|
||||
id: popupHandler
|
||||
|
||||
implicitHeight: contentItem.implicitHeight
|
||||
width: usernameField.width
|
||||
y: parent.height - username.height / 3
|
||||
x: config.RightToLeftLayout == "true" ? -loginButton.width + selectUser.width : 0
|
||||
rightMargin: config.RightToLeftLayout == "true" ? root.padding + usernameField.width / 2 : undefined
|
||||
width: usernameField.width
|
||||
implicitHeight: contentItem.implicitHeight
|
||||
padding: 10
|
||||
|
||||
contentItem: ListView {
|
||||
clip: true
|
||||
implicitHeight: contentHeight + 20
|
||||
|
||||
clip: true
|
||||
model: selectUser.popup.visible ? selectUser.delegateModel : null
|
||||
currentIndex: selectUser.highlightedIndex
|
||||
ScrollIndicator.vertical: ScrollIndicator { }
|
||||
@@ -188,7 +200,6 @@ Column {
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
PropertyAnimation {
|
||||
@@ -202,22 +213,27 @@ Column {
|
||||
|
||||
TextField {
|
||||
id: username
|
||||
|
||||
anchors.centerIn: parent
|
||||
height: root.font.pointSize * 3
|
||||
width: parent.width
|
||||
horizontalAlignment: TextInput.AlignHCenter
|
||||
z: 1
|
||||
|
||||
text: config.ForceLastUser == "true" ? selectUser.currentText : null
|
||||
color: config.LoginFieldTextColor
|
||||
font.bold: true
|
||||
font.capitalization: config.AllowUppercaseLettersInUsernames == "false" ? Font.AllLowercase : Font.MixedCase
|
||||
anchors.centerIn: parent
|
||||
height: root.font.pointSize * 3
|
||||
width: parent.width
|
||||
placeholderText: config.TranslatePlaceholderUsername || textConstants.userName
|
||||
placeholderTextColor: config.PlacholderTextColor
|
||||
placeholderTextColor: config.PlaceholderTextColor
|
||||
selectByMouse: true
|
||||
horizontalAlignment: TextInput.AlignHCenter
|
||||
renderType: Text.QtRendering
|
||||
|
||||
onFocusChanged:{
|
||||
if(focus)
|
||||
selectAll()
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: config.LoginFieldBackgroundColor
|
||||
opacity: 0.2
|
||||
@@ -225,9 +241,9 @@ Column {
|
||||
border.width: parent.activeFocus ? 2 : 1
|
||||
radius: config.RoundCorners || 0
|
||||
}
|
||||
|
||||
onAccepted: config.AllowUppercaseLettersInUsernames == "false" ? sddm.login(username.text.toLowerCase(), password.text, sessionSelect.selectedSession) : sddm.login(username.text, password.text, sessionSelect.selectedSession)
|
||||
KeyNavigation.down: showPassword
|
||||
z: 1
|
||||
KeyNavigation.down: passwordIcon
|
||||
|
||||
states: [
|
||||
State {
|
||||
@@ -254,13 +270,15 @@ Column {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
Button {
|
||||
id: showPassword
|
||||
z: 2
|
||||
width: selectUser.height * 1
|
||||
id: passwordIcon
|
||||
|
||||
height: parent.height
|
||||
width: selectUser.height * 1
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: selectUser.height * 0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
z: 2
|
||||
|
||||
icon.height: parent.height * 0.25
|
||||
icon.width: parent.height * 0.25
|
||||
icon.color: config.PasswordIconColor
|
||||
@@ -274,44 +292,44 @@ Column {
|
||||
states: [
|
||||
State {
|
||||
name: "visiblePasswordFocused"
|
||||
when: showPassword.checked && showPassword.activeFocus
|
||||
when: passwordIcon.checked && passwordIcon.activeFocus
|
||||
PropertyChanges {
|
||||
target: showPassword
|
||||
target: passwordIcon
|
||||
icon.source: Qt.resolvedUrl("../Assets/Password.svg")
|
||||
icon.color: config.HoverPasswordIconColor
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "visiblePasswordHovered"
|
||||
when: showPassword.checked && showPassword.hovered
|
||||
when: passwordIcon.checked && passwordIcon.hovered
|
||||
PropertyChanges {
|
||||
target: showPassword
|
||||
target: passwordIcon
|
||||
icon.source: Qt.resolvedUrl("../Assets/Password.svg")
|
||||
icon.color: config.HoverPasswordIconColor
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "visiblePassword"
|
||||
when: showPassword.checked
|
||||
when: passwordIcon.checked
|
||||
PropertyChanges {
|
||||
target: showPassword
|
||||
target: passwordIcon
|
||||
icon.source: Qt.resolvedUrl("../Assets/Password.svg")
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "hiddenPasswordFocused"
|
||||
when: showPassword.enabled && showPassword.activeFocus
|
||||
when: passwordIcon.enabled && passwordIcon.activeFocus
|
||||
PropertyChanges {
|
||||
target: showPassword
|
||||
target: passwordIcon
|
||||
icon.source: Qt.resolvedUrl("../Assets/Password2.svg")
|
||||
icon.color: config.HoverPasswordIconColor
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "hiddenPasswordHovered"
|
||||
when: showPassword.hovered
|
||||
when: passwordIcon.hovered
|
||||
PropertyChanges {
|
||||
target: showPassword
|
||||
target: passwordIcon
|
||||
icon.source: Qt.resolvedUrl("../Assets/Password2.svg")
|
||||
icon.color: config.HoverPasswordIconColor
|
||||
}
|
||||
@@ -327,20 +345,23 @@ Column {
|
||||
|
||||
TextField {
|
||||
id: password
|
||||
anchors.centerIn: parent
|
||||
color: config.PasswordFieldTextColor
|
||||
|
||||
height: root.font.pointSize * 3
|
||||
width: parent.width
|
||||
font.bold: true
|
||||
focus: config.PasswordFocus == "true" ? true : false
|
||||
selectByMouse: true
|
||||
echoMode: showPassword.checked ? TextInput.Normal : TextInput.Password
|
||||
placeholderText: config.TranslatePlaceholderPassword || textConstants.password
|
||||
placeholderTextColor: config.PlacholderTextColor
|
||||
anchors.centerIn: parent
|
||||
horizontalAlignment: TextInput.AlignHCenter
|
||||
|
||||
font.bold: true
|
||||
color: config.PasswordFieldTextColor
|
||||
focus: config.PasswordFocus == "true" ? true : false
|
||||
echoMode: passwordIcon.checked ? TextInput.Normal : TextInput.Password
|
||||
placeholderText: config.TranslatePlaceholderPassword || textConstants.password
|
||||
placeholderTextColor: config.PlaceholderTextColor
|
||||
passwordCharacter: "•"
|
||||
passwordMaskDelay: config.HideCompletePassword == "true" ? undefined : 1000
|
||||
renderType: Text.QtRendering
|
||||
selectByMouse: true
|
||||
|
||||
background: Rectangle {
|
||||
color: config.PasswordFieldBackgroundColor
|
||||
opacity: 0.2
|
||||
@@ -366,7 +387,6 @@ Column {
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
PropertyAnimation {
|
||||
@@ -379,35 +399,42 @@ Column {
|
||||
|
||||
Item {
|
||||
id: login
|
||||
|
||||
// important
|
||||
// try 4 or 9 ...
|
||||
height: root.font.pointSize * 9
|
||||
width: parent.width / 2
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
visible: config.HideLoginButton == "true" ? false : true
|
||||
|
||||
Button {
|
||||
id: loginButton
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: config.TranslateLogin || textConstants.login
|
||||
|
||||
height: root.font.pointSize * 3
|
||||
implicitWidth: parent.width
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
text: config.TranslateLogin || textConstants.login
|
||||
enabled: config.AllowEmptyPassword == "true" || username.text != "" && password.text != "" ? true : false
|
||||
hoverEnabled: true
|
||||
|
||||
contentItem: Text {
|
||||
font.bold: true
|
||||
text: parent.text
|
||||
color: config.LoginButtonTextColor
|
||||
font.pointSize: root.font.pointSize
|
||||
font.family: root.font.family
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
font.bold: true
|
||||
font.pointSize: root.font.pointSize
|
||||
font.family: root.font.family
|
||||
color: config.LoginButtonTextColor
|
||||
text: parent.text
|
||||
opacity: 0.5
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
id: buttonBackground
|
||||
|
||||
color: config.LoginButtonBackgroundColor
|
||||
opacity: 0.2
|
||||
radius: config.RoundCorners || 0
|
||||
@@ -466,7 +493,6 @@ Column {
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
PropertyAnimation {
|
||||
@@ -475,10 +501,12 @@ Column {
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
onClicked: config.AllowUppercaseLettersInUsernames == "false" ? sddm.login(username.text.toLowerCase(), password.text, sessionSelect.selectedSession) : sddm.login(username.text, password.text, sessionSelect.selectedSession)
|
||||
Keys.onReturnPressed: clicked()
|
||||
Keys.onEnterPressed: clicked()
|
||||
KeyNavigation.down: sessionSelect.exposeSession
|
||||
|
||||
KeyNavigation.down: config.HideSystemButtons == "true" ? virtualKeyboard : systemButtons.children[0]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user