From 5d292077f5a3ea4e3b723dae2e9db7e324051419 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..0e1656b24a 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: 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