From 236bc33bc850f3209934de003b732705a4b984f4 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 16 Nov 2021 18:15:07 -0800 Subject: [PATCH] Don't try adding a folder if the user clicks cancel, and add additional logging --- .../src/onionshare/tab/mode/file_selection.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/desktop/src/onionshare/tab/mode/file_selection.py b/desktop/src/onionshare/tab/mode/file_selection.py index c75e9db6..1addba22 100644 --- a/desktop/src/onionshare/tab/mode/file_selection.py +++ b/desktop/src/onionshare/tab/mode/file_selection.py @@ -435,6 +435,7 @@ class FileSelection(QtWidgets.QVBoxLayout): """ file_dialog = AddFileDialog(self.common, caption=strings._("gui_choose_items")) if file_dialog.exec_() == QtWidgets.QDialog.Accepted: + self.common.log("FileSelection", "add", file_dialog.selectedFiles()) for filename in file_dialog.selectedFiles(): self.file_list.add_file(filename) @@ -443,25 +444,34 @@ class FileSelection(QtWidgets.QVBoxLayout): def add_files(self): """ - Add files button clicked. + Add Files button clicked. """ files = QtWidgets.QFileDialog.getOpenFileNames( self.parent, caption=strings._("gui_choose_items") ) + self.common.log("FileSelection", "add_files", files) + filenames = files[0] for filename in filenames: self.file_list.add_file(filename) + self.file_list.setCurrentItem(None) + self.update() + def add_folder(self): """ - Add folder button clicked. + Add Folder button clicked. """ filename = QtWidgets.QFileDialog.getExistingDirectory( self.parent, caption=strings._("gui_choose_items"), options=QtWidgets.QFileDialog.ShowDirsOnly, ) - self.file_list.add_file(filename) + self.common.log("FileSelection", "add_folder", filename) + if filename: + self.file_list.add_file(filename) + self.file_list.setCurrentItem(None) + self.update() def delete(self): """