Skip to content

Commit 6fca787

Browse files
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.
1 parent a7ccfc3 commit 6fca787

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/qml/components/StorageLocations.qml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,28 @@ ColumnLayout {
2929
ButtonGroup.group: group
3030
text: qsTr("Custom")
3131
description: qsTr("Choose the directory and storage device.")
32-
onClicked: fileDialog.open()
32+
onClicked: {
33+
if (AppMode.isDesktop) {
34+
if (!singleClickTimer.running) {
35+
// Start the timer if it's not already running
36+
singleClickTimer.start();
37+
} else {
38+
// If the timer is running, it's a double-click
39+
singleClickTimer.stop();
40+
}
41+
} else {
42+
fileDialog.open()
43+
}
44+
}
45+
Timer {
46+
id: singleClickTimer
47+
interval: 50
48+
onTriggered: {
49+
// If the timer times out, it's a single-click
50+
fileDialog.open()
51+
}
52+
repeat: false // No need to repeat the timer
53+
}
3354
}
3455
FileDialog {
3556
id: fileDialog

0 commit comments

Comments
 (0)