[Pkg-privacy-commits] [onionshare] 216/256: Make it possible to select multiple folders by using non-native QFileDialog

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit b35e3b76d586f39f29cf4049a02ab2d028a0d40d
Author: Miguel Jacq <mig at mig5.net>
Date:   Sun May 21 16:14:32 2017 +1000

    Make it possible to select multiple folders by using non-native QFileDialog
---
 onionshare_gui/file_selection.py | 18 ++++++++++++++----
 share/locale/en.json             |  2 +-
 share/locale/fr.json             |  2 +-
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/onionshare_gui/file_selection.py b/onionshare_gui/file_selection.py
index 2ebbbb7..0de96e0 100644
--- a/onionshare_gui/file_selection.py
+++ b/onionshare_gui/file_selection.py
@@ -225,10 +225,20 @@ class FileSelection(QtWidgets.QVBoxLayout):
         """
         Add folder button clicked.
         """
-        filename = QtWidgets.QFileDialog.getExistingDirectory(
-            caption=strings._('gui_choose_folder', True), options=QtWidgets.QFileDialog.ReadOnly)
-        if filename:
-            self.file_list.add_file(str(filename))
+        file_dialog = QtWidgets.QFileDialog(caption=strings._('gui_choose_folder', True))
+        file_dialog.setFileMode(QtWidgets.QFileDialog.Directory)
+        file_dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
+        file_dialog.setOption(QtWidgets.QFileDialog.ReadOnly, True)
+        file_dialog.setOption(QtWidgets.QFileDialog.ShowDirsOnly, True)
+        tree_view = file_dialog.findChild(QtWidgets.QTreeView)
+        tree_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
+        list_view = file_dialog.findChild(QtWidgets.QListView, "listView")
+        list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
+
+        if file_dialog.exec_() == QtWidgets.QDialog.Accepted:
+          for filename in file_dialog.selectedFiles():
+              self.file_list.add_file(filename)
+
         self.update()
 
     def delete_file(self):
diff --git a/share/locale/en.json b/share/locale/en.json
index 701b067..2b4fa11 100644
--- a/share/locale/en.json
+++ b/share/locale/en.json
@@ -24,7 +24,7 @@
     "help_filename": "List of files or folders to share",
     "gui_drag_and_drop": "Drag and drop\nfiles here",
     "gui_add_files": "Add Files",
-    "gui_add_folder": "Add Folder",
+    "gui_add_folder": "Add Folders",
     "gui_delete": "Delete",
     "gui_choose_files": "Choose files",
     "gui_choose_folder": "Choose folder",
diff --git a/share/locale/fr.json b/share/locale/fr.json
index ce9cfa1..842bf22 100644
--- a/share/locale/fr.json
+++ b/share/locale/fr.json
@@ -21,7 +21,7 @@
     "help_filename": "Liste des fichiers ou dossiers à partager",
     "gui_drag_and_drop": "Glissez déposez\nles fichiers ici",
     "gui_add_files": "Ajouter des fichiers",
-    "gui_add_folder": "Ajouter un dossier",
+    "gui_add_folder": "Ajouter des dossiers",
     "gui_delete": "Supprimer",
     "gui_choose_files": "Sélectionnez des fichiers",
     "gui_choose_folder": "Sélectionnez un dossier",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list