mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Use non-native QFileDialog for file selection as well as directory selection, to have a consistent UI
This commit is contained in:
parent
9385487c10
commit
e828b2f9cd
@ -214,11 +214,19 @@ 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]:
|
||||
self.file_list.add_file(filename)
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user