Merge branch 'mig5-select_multiple_folders'

This commit is contained in:
Micah Lee 2017-05-22 16:11:06 -07:00
commit de4739e458
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 31 additions and 13 deletions

View File

@ -214,21 +214,39 @@ class FileSelection(QtWidgets.QVBoxLayout):
"""
Add files button clicked.
"""
filenames = QtWidgets.QFileDialog.getOpenFileNames(
caption=strings._('gui_choose_files', True), options=QtWidgets.QFileDialog.ReadOnly)
if filenames:
for filename in filenames[0]:
file_dialog = QtWidgets.QFileDialog(caption=strings._('gui_choose_files', True))
file_dialog.setFileMode(QtWidgets.QFileDialog.ExistingFiles)
file_dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
file_dialog.setOption(QtWidgets.QFileDialog.ReadOnly, 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 add_dir(self):
"""
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):

View File

@ -24,10 +24,10 @@
"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",
"gui_choose_folder": "Choose folders",
"gui_start_server": "Start Sharing",
"gui_stop_server": "Stop Sharing",
"gui_copy_url": "Copy URL",

View File

@ -21,10 +21,10 @@
"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",
"gui_choose_folder": "Sélectionnez des dossiers",
"gui_start_server": "Démarrer le serveur",
"gui_stop_server": "Arrêter le serveur",
"gui_copy_url": "Copier URL",