Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix textfield layout on basic auth credentials page #11921

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 58 additions & 51 deletions src/gui/qml/credentials/BasicAuthCredentials.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,67 +30,74 @@ Credentials {
text: credentials.isReadOnlyName ? qsTr("Please enter your password to log in.") : qsTr("Please enter %1 and password to log in.").arg(credentials.userNameLabel)
}

Label {
text: credentials.userNameLabel
}
TextField {
id: userNameField
placeholderText: qsTr("Enter %1").arg(credentials.userNameLabel)
horizontalAlignment: TextField.AlignHCenter
text: credentials.userName
enabled: !credentials.isReadOnlyName
onTextChanged: {
credentials.userName = text;
ColumnLayout {
// Treat the user name and password fields, the labels, and the buttons as one single group,
// so they are always placed and layed out together.
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: false

Label {
text: credentials.userNameLabel
}
TextField {
id: userNameField
Layout.fillWidth: true
placeholderText: qsTr("Enter %1").arg(credentials.userNameLabel)
horizontalAlignment: TextField.AlignHCenter
text: credentials.userName
enabled: !credentials.isReadOnlyName
onTextChanged: {
credentials.userName = text;
}

erikjv marked this conversation as resolved.
Show resolved Hide resolved
Keys.onBacktabPressed: {
widget.parentFocusWidget.focusPrevious();
Keys.onBacktabPressed: {
widget.parentFocusWidget.focusPrevious();
}
}
}

Label {
text: qsTr("Password")
}
TextField {
id: passwordField
horizontalAlignment: TextField.AlignHCenter
placeholderText: qsTr("Enter Password")
text: credentials.password
echoMode: TextField.PasswordEchoOnEdit
onTextChanged: {
credentials.password = text;
Label {
text: qsTr("Password")
}
Keys.onTabPressed: event => {
// there is no lougout button
if (!credentials.isRefresh) {
widget.parentFocusWidget.focusNext();
event.accepted = true;
} else {
event.accepted = false;
TextField {
id: passwordField
Layout.fillWidth: true
horizontalAlignment: TextField.AlignHCenter
placeholderText: qsTr("Enter Password")
text: credentials.password
echoMode: TextField.PasswordEchoOnEdit
onTextChanged: {
credentials.password = text;
}
Keys.onTabPressed: event => {
// there is no lougout button
if (!credentials.isRefresh) {
widget.parentFocusWidget.focusNext();
event.accepted = true;
} else {
event.accepted = false;
}
}
}
}

Item {
Layout.maximumHeight: 40
Layout.fillHeight: true
}
Item {
Layout.maximumHeight: 40
Layout.fillHeight: true
}

Button {
id: loginButton
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: userNameField.implicitWidth
// don't show this button in the wizard
visible: credentials.isRefresh
text: qsTr("Log in")
enabled: credentials.ready
onClicked: credentials.loginRequested()
}
Button {
id: loginButton
Layout.fillWidth: true
// don't show this button in the wizard
visible: credentials.isRefresh
text: qsTr("Log in")
enabled: credentials.ready
onClicked: credentials.loginRequested()
}

Loader {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: passwordField.implicitWidth
sourceComponent: logOutButton
Loader {
Layout.fillWidth: true
sourceComponent: logOutButton
}
}

Connections {
Expand Down