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 May 27, 2024
1 parent a7ccfc3 commit 6fca787
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 @@ -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
Expand Down

0 comments on commit 6fca787

Please sign in to comment.