From a9433291848cfbad1e42a6db685d00f2730cc579 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 acaa69b40a..6a3eea9245 100644 --- a/src/qml/components/StorageLocations.qml +++ b/src/qml/components/StorageLocations.qml @@ -37,7 +37,28 @@ ColumnLayout { description: qsTr("Choose the directory and storage device.") customDir: customDirOption.checked ? fileDialog.folder : "" checked: optionsModel.dataDir !== optionsModel.getDefaultDataDirString - 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: 300 + onTriggered: { + // If the timer times out, it's a single-click + fileDialog.open() + } + repeat: false // No need to repeat the timer + } } FileDialog { id: fileDialog