Skip to content

Commit

Permalink
qml, desktop: Fix custom datadir doubleclick
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pablomartin4btc committed Aug 31, 2024
1 parent e7bea2d commit a943329
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/qml/components/StorageLocations.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a943329

Please sign in to comment.