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