Update: moved SessionButton to LoginForm.qml, fixed some issues with popups, replaced anchors with layout (session button).

This commit is contained in:
Keyitdev
2024-12-21 01:44:28 +01:00
parent 95d664e483
commit 2e016cc360
4 changed files with 49 additions and 51 deletions
+6 -4
View File
@@ -73,7 +73,7 @@ Column {
anchors.left: parent.left anchors.left: parent.left
property var popkey: config.RightToLeftLayout == "true" ? Qt.Key_Right : Qt.Key_Left property var popkey: config.RightToLeftLayout == "true" ? Qt.Key_Right : Qt.Key_Left
Keys.onPressed: { Keys.onPressed: function(event) {
if (event.key == Qt.Key_Down && !popup.opened) if (event.key == Qt.Key_Down && !popup.opened)
username.forceActiveFocus(); username.forceActiveFocus();
if ((event.key == Qt.Key_Up || event.key == popkey) && !popup.opened) if ((event.key == Qt.Key_Up || event.key == popkey) && !popup.opened)
@@ -92,8 +92,9 @@ Column {
} }
delegate: ItemDelegate { delegate: ItemDelegate {
width: parent.width // minus padding
anchors.horizontalCenter: parent.horizontalCenter width: popupHandler.width - 20
anchors.horizontalCenter: popupHandler.horizontalCenter
contentItem: Text { contentItem: Text {
text: model.name text: model.name
font.pointSize: root.font.pointSize * 0.8 font.pointSize: root.font.pointSize * 0.8
@@ -103,7 +104,7 @@ Column {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
highlighted: parent.highlightedIndex === index // highlighted: parent.highlightedIndex === index
background: Rectangle { background: Rectangle {
color: selectUser.highlightedIndex === index ? config.DropdownSelectedBackgroundColor : "transparent" color: selectUser.highlightedIndex === index ? config.DropdownSelectedBackgroundColor : "transparent"
} }
@@ -134,6 +135,7 @@ Column {
} }
popup: Popup { popup: Popup {
id: popupHandler
y: parent.height - username.height / 3 y: parent.height - username.height / 3
x: config.RightToLeftLayout == "true" ? -loginButton.width + selectUser.width : 0 x: config.RightToLeftLayout == "true" ? -loginButton.width + selectUser.width : 0
rightMargin: config.RightToLeftLayout == "true" ? root.padding + usernameField.width / 2 : undefined rightMargin: config.RightToLeftLayout == "true" ? root.padding + usernameField.width / 2 : undefined
+13 -2
View File
@@ -33,10 +33,21 @@ ColumnLayout {
SystemButtons { SystemButtons {
id: systemButtons id: systemButtons
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Layout.preferredHeight: root.height / 4 Layout.preferredHeight: root.height / 5
Layout.maximumHeight: root.height / 4 Layout.maximumHeight: root.height / 5
Layout.leftMargin: p != "0" ? a == "left" ? -p : a == "right" ? p : 0 : 0 Layout.leftMargin: p != "0" ? a == "left" ? -p : a == "right" ? p : 0 : 0
exposedSession: input.exposeSession exposedSession: input.exposeSession
} }
SessionButton {
id: sessionSelect
// anchors.bottom: parent.bottom
// anchors.bottomMargin: parent.height/16
// Layout.bottomMargin: parent.height/16
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Layout.preferredHeight: root.height / 14
Layout.maximumHeight: root.height / 14
Layout.leftMargin: p != "0" ? a == "left" ? -p : a == "right" ? p : 0 : 0
}
} }
+24 -34
View File
@@ -10,7 +10,7 @@ Item {
id: sessionButton id: sessionButton
height: root.font.pointSize height: root.font.pointSize
width: parent.width / 2 width: parent.width / 2
anchors.horizontalCenter: parent.horizontalCenter // anchors.horizontalCenter: parent.horizontalCenter
property var selectedSession: selectSession.currentIndex property var selectedSession: selectSession.currentIndex
property string textConstantSession property string textConstantSession
property int loginButtonWidth property int loginButtonWidth
@@ -23,30 +23,35 @@ Item {
height: root.font.pointSize * 2 height: root.font.pointSize * 2
hoverEnabled: true hoverEnabled: true
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Keys.onPressed: { Keys.onPressed: function(event) {
if (event.key == Qt.Key_Up && loginButton.state != "enabled" && !popup.opened) if (event.key == Qt.Key_Up && loginButton.state != "enabled" && !popup.opened) {
revealSecret.focus = true, revealSecret.focus = true;
revealSecret.state = "focused", revealSecret.state = "focused";
currentIndex = currentIndex + 1; currentIndex = currentIndex + 1;
if (event.key == Qt.Key_Up && loginButton.state == "enabled" && !popup.opened) }
loginButton.focus = true, if (event.key == Qt.Key_Up && loginButton.state == "enabled" && !popup.opened) {
loginButton.state = "focused", loginButton.focus = true;
loginButton.state = "focused";
currentIndex = currentIndex + 1; currentIndex = currentIndex + 1;
if (event.key == Qt.Key_Down && !popup.opened) }
systemButtons.children[0].focus = true, if (event.key == Qt.Key_Down && !popup.opened) {
systemButtons.children[0].state = "focused", systemButtons.children[0].focus = true;
systemButtons.children[0].state = "focused";
currentIndex = currentIndex - 1; currentIndex = currentIndex - 1;
if ((event.key == Qt.Key_Left || event.key == Qt.Key_Right) && !popup.opened) }
if ((event.key == Qt.Key_Left || event.key == Qt.Key_Right) && !popup.opened) {
popup.open(); popup.open();
} }
}
model: sessionModel model: sessionModel
currentIndex: model.lastIndex currentIndex: model.lastIndex
textRole: "name" textRole: "name"
delegate: ItemDelegate { delegate: ItemDelegate {
width: parent.width // minus padding
anchors.horizontalCenter: parent.horizontalCenter width: popupHandler.width - 20
anchors.horizontalCenter: popupHandler.horizontalCenter
contentItem: Text { contentItem: Text {
text: model.name text: model.name
font.pointSize: root.font.pointSize * 0.8 font.pointSize: root.font.pointSize * 0.8
@@ -55,7 +60,7 @@ Item {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
} }
highlighted: parent.highlightedIndex === index // highlighted: parent.highlightedIndex === index
background: Rectangle { background: Rectangle {
color: selectSession.highlightedIndex === index ? config.DropdownSelectedBackgroundColor : "transparent" color: selectSession.highlightedIndex === index ? config.DropdownSelectedBackgroundColor : "transparent"
} }
@@ -77,13 +82,11 @@ Item {
background: Rectangle { background: Rectangle {
color: "transparent" color: "transparent"
border.width: parent.visualFocus ? 1 : 0
border.color: "transparent"
height: parent.visualFocus ? 2 : 0 height: parent.visualFocus ? 2 : 0
width: displayedItem.implicitWidth width: displayedItem.implicitWidth
anchors.top: parent.bottom // anchors.top: parent.bottom
anchors.left: parent.left // anchors.left: parent.left
anchors.leftMargin: 3 // anchors.leftMargin: 3
} }
popup: Popup { popup: Popup {
@@ -91,7 +94,6 @@ Item {
width: sessionButton.width width: sessionButton.width
y: parent.height - 1 y: parent.height - 1
x: -popupHandler.width/2 + displayedItem.width/2 x: -popupHandler.width/2 + displayedItem.width/2
// x: config.RightToLeftLayout == "true" ? -loginButtonWidth + displayedItem.width : 0
implicitHeight: contentItem.implicitHeight implicitHeight: contentItem.implicitHeight
padding: 10 padding: 10
@@ -122,10 +124,6 @@ Item {
target: displayedItem target: displayedItem
color: Qt.darker(config.HoverSessionButtonTextColor, 1.1) color: Qt.darker(config.HoverSessionButtonTextColor, 1.1)
} }
PropertyChanges {
target: selectSession.background
border.color: Qt.darker(config.HoverSessionButtonTextColor, 1.1)
}
}, },
State { State {
name: "hovered" name: "hovered"
@@ -134,10 +132,6 @@ Item {
target: displayedItem target: displayedItem
color: Qt.lighter(config.HoverSessionButtonTextColor, 1.1) color: Qt.lighter(config.HoverSessionButtonTextColor, 1.1)
} }
PropertyChanges {
target: selectSession.background
border.color: Qt.lighter(config.HoverSessionButtonTextColor, 1.1)
}
}, },
State { State {
name: "focused" name: "focused"
@@ -146,17 +140,13 @@ Item {
target: displayedItem target: displayedItem
color: config.HoverSessionButtonTextColor color: config.HoverSessionButtonTextColor
} }
PropertyChanges {
target: selectSession.background
border.color: config.HoverSessionButtonTextColor
}
} }
] ]
transitions: [ transitions: [
Transition { Transition {
PropertyAnimation { PropertyAnimation {
properties: "color, border.color" properties: "color"
duration: 150 duration: 150
} }
} }
+2 -7
View File
@@ -26,7 +26,8 @@ Pane {
palette.buttonText: config.HoverSystemButtonsIconsColor palette.buttonText: config.HoverSystemButtonsIconsColor
font.family: config.Font font.family: config.Font
font.pointSize: config.FontSize !== "" ? config.FontSize : parseInt(height / 80) font.pointSize: config.FontSize !== "" ? config.FontSize : parseInt(height / 80) || 13
focus: true focus: true
property bool leftleft: config.HaveFormBackground == "true" && property bool leftleft: config.HaveFormBackground == "true" &&
@@ -83,12 +84,6 @@ Pane {
anchors.left: config.FormPosition == "left" ? parent.left : undefined anchors.left: config.FormPosition == "left" ? parent.left : undefined
anchors.right: config.FormPosition == "right" ? parent.right : undefined anchors.right: config.FormPosition == "right" ? parent.right : undefined
z: 1 z: 1
SessionButton {
id: sessionSelect
anchors.bottom: parent.bottom
anchors.bottomMargin: parent.height/16
}
} }
Button { Button {