From 3eb912bf5ac8f405c8c9838fb8ca0bba73bc4a9b Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sun, 14 Nov 2021 15:46:20 -0800 Subject: [PATCH] Move drag and drop logic into dropEvent --- desktop/src/onionshare/tab/mode/file_selection.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/desktop/src/onionshare/tab/mode/file_selection.py b/desktop/src/onionshare/tab/mode/file_selection.py index daf347c0..7ab110fc 100644 --- a/desktop/src/onionshare/tab/mode/file_selection.py +++ b/desktop/src/onionshare/tab/mode/file_selection.py @@ -225,6 +225,14 @@ class FileList(QtWidgets.QListWidget): """ dropEvent for dragging files and directories into the widget. """ + # Drag and drop doesn't work in Flatpak, because of the sandbox + if self.common.platform == "Linux" and os.path.exists("/app/manifest.json"): + Alert( + self.common, strings._("gui_dragdrop_sandbox_flatpak").format(filename) + ) + event.ignore() + return + if event.mimeData().hasUrls: event.setDropAction(QtCore.Qt.CopyAction) event.accept() @@ -243,13 +251,6 @@ class FileList(QtWidgets.QListWidget): """ Add a file or directory to this widget. """ - # Drag and drop doesn't work in Flatpak, because of the sandbox - if self.common.platform == "Linux" and os.path.exists("/app/manifest.json"): - Alert( - self.common, strings._("gui_dragdrop_sandbox_flatpak").format(filename) - ) - return - filenames = [] for index in range(self.count()): filenames.append(self.item(index).filename)