From dd2beba676e89c52961ad28bbfd895463eff83bf Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Mon, 23 Dec 2024 00:09:44 +0100 Subject: [PATCH] =?UTF-8?q?Change=20port=E2=80=99s=20Label=20to=20a=20Chec?= =?UTF-8?q?kBox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For host, database name, and options i can leave them blank to use the default value, but for the port i can’t with a SpinBox, since it _must_ have a value. Qt’s driver uses -1 to mean “default port”, but i can not use the same approach with the user interface, because there is no port -1, and makes no sense to allow that value, specially since i then i have to allow 0 as well, which is a reserved port. I also can not leave the SpinBox with PostgreSQL’s default port, 5432, because that is slightly different than telling libpq to use the “default”: if someone uses a ‘service=’ option, it would use the port in the SpinBox rather than the one in ‘pg_service.conf’, if any. My solution is to use a checkbox to tell the application “i wan to use a port number”, and (will) only pass the port number if it is checked. On the other hand, now i do not have a keyboard shortcut to focus on the port number field. --- src/LoginPage.qml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/LoginPage.qml b/src/LoginPage.qml index b57ffba..e40876a 100644 --- a/src/LoginPage.qml +++ b/src/LoginPage.qml @@ -67,17 +67,27 @@ Page { onAccepted: loginAction.trigger() } - MnemonicLabel { + CheckBox { + id: port + Layout.alignment: Qt.AlignRight - buddy: port - mnemonic: qsTr("Por&t:") + Mnemonic.label: qsTr("Por&t:") + text: Mnemonic.richTextLabel + + Shortcut { + sequence: port.Mnemonic.sequence + + onActivated: port.click() + } } SpinBox { - id: port + id: portNumber + Accessible.name: qsTr("Port number") Layout.fillWidth: true editable: true + enabled: port.checked from: 1 to: 65535 }