Add automatic login feature

I am using .pg_service.conf to define all connection parameters, and
.pgpass for the password, thus i never have to input anything to the
login form, and want to skip it.

However, just in case someday i need to set the connection up
differently, i only try to log in automatically on startup, and can go
back to the login page by logging out, as usual.
This commit is contained in:
jordi fita mas 2024-12-27 19:28:31 +01:00
parent 5f1e2b3b2d
commit f4affd9241
2 changed files with 28 additions and 0 deletions

View File

@ -8,6 +8,7 @@ Page {
id: page
function saveSettings() {
settings.autoLogIn = autoLogIn.checked;
settings.connectOptions = connectOptions.text;
settings.databaseName = databaseName.text;
settings.hostName = hostName.text;
@ -15,6 +16,12 @@ Page {
settings.usePort = usePort.checked;
}
function tryAutoLogIn() {
if (autoLogIn.checked) {
loginAction.trigger();
}
}
title: qsTr("Login")
ColumnLayout {
@ -133,6 +140,22 @@ Page {
onAccepted: loginAction.trigger()
}
CheckBox {
id: autoLogIn
Layout.alignment: Qt.AlignRight
Layout.columnSpan: 2
Mnemonic.label: qsTr("Log in auto&matically")
checked: settings.autoLogIn
text: Mnemonic.richTextLabel
Shortcut {
sequence: autoLogIn.Mnemonic.sequence
onActivated: autoLogIn.click()
}
}
}
}
@ -145,6 +168,7 @@ Page {
Settings {
id: settings
property bool autoLogIn: false
property string connectOptions: ""
property string databaseName: ""
property string hostName: ""

View File

@ -9,6 +9,10 @@ ApplicationWindow {
visible: true
width: 640
Component.onCompleted: function () {
(pageStack.currentItem as LoginPage)?.tryAutoLogIn();
}
StackView {
id: pageStack