From be402aa82f05a19a2e2e975c86632724d9c9b59d Mon Sep 17 00:00:00 2001 From: pablomartin4btc Date: Sun, 14 Apr 2024 21:55:26 -0300 Subject: [PATCH] qml, desktop: Fix custom datadir doubleclick This is a desktop-only (not mobile) workaround to disable doubleclick on custom datadir which is on the StorageLocations.qml componennt. Double-clicking was causing the file dialog to get open but losing focus and moving to the background, bringing upfront the main window which was useless because the file dialog is modal. --- src/qml/components/StorageLocations.qml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qml/components/StorageLocations.qml b/src/qml/components/StorageLocations.qml index b5fac4aa4d..acf94c2c29 100644 --- a/src/qml/components/StorageLocations.qml +++ b/src/qml/components/StorageLocations.qml @@ -29,7 +29,28 @@ ColumnLayout { ButtonGroup.group: group text: qsTr("Custom") description: qsTr("Choose the directory and storage device.") - onClicked: fileDialog.open() + onClicked: { + if (AppMode.isDesktop) { + if (!singleClickTimer.running) { + // Start the timer if it's not already running + singleClickTimer.start(); + } else { + // If the timer is running, it's a double-click + singleClickTimer.stop(); + } + } else { + fileDialog.open() + } + } + Timer { + id: singleClickTimer + interval: 50 + onTriggered: { + // If the timer times out, it's a single-click + fileDialog.open() + } + repeat: false // No need to repeat the timer + } } FileDialog { id: fileDialog