Skip to content

Commit

Permalink
feat: directories multiselections
Browse files Browse the repository at this point in the history
  • Loading branch information
SAMAD101 committed Feb 20, 2024
1 parent 259c6d5 commit aa8f26c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/vorta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ def choose_file_dialog(parent, title, want_folder=True):
dialog.setFileMode(QFileDialog.FileMode.Directory if want_folder else QFileDialog.FileMode.ExistingFiles)
dialog.setParent(parent, QtCore.Qt.WindowType.Sheet)
if want_folder:
dialog.setOption(QFileDialog.Option.ShowDirsOnly)
list_view = dialog.findChild(QTreeView)
list_view.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
dialog.exec()
return dialog.selectedFiles()

return dialog


def is_ssh_private_key_file(filepath: str) -> bool:
Expand Down
3 changes: 2 additions & 1 deletion src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ def receive():
self.app.jobs_manager.add_job(job)

dialog = choose_file_dialog(self, self.tr("Choose Mount Point"), want_folder=True)
dialog.open(receive)
dialog.exec()
receive()

def mount_result(self, result):
if result['returncode'] == 0:
Expand Down
3 changes: 2 additions & 1 deletion src/vorta/views/repo_add_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def receive():
self.is_remote_repo = False

dialog = choose_file_dialog(self, self.tr("Choose Location of Borg Repository"))
dialog.open(receive)
dialog.exec()
receive()

def use_remote_repo_action(self):
self.repoURL.setText('')
Expand Down
8 changes: 5 additions & 3 deletions src/vorta/views/source_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def sources_update(self):
self.update_path_info(row) # Update data for each entry

def source_add(self, want_folder):
def receive(dirs):
def receive():
dirs = dialog.selectedFiles()
for dir in dirs:
if not os.access(dir, os.R_OK):
msg = QMessageBox()
Expand All @@ -301,8 +302,9 @@ def receive(dirs):

msg = self.tr("Choose directory to back up") if want_folder else self.tr("Choose file(s) to back up")

paths = choose_file_dialog(self, msg, want_folder=want_folder)
receive(paths)
dialog = choose_file_dialog(self, msg, want_folder)
dialog.exec()
receive()

def source_copy(self, index=None):
"""
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ def __init__(self, *args, **kwargs):
def open(self, func):
func()

def exec(self):
return 1

def selectedFiles(self):
if self.subdirectory:
return [str(tmpdir.join(self.subdirectory))]
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def __init__(self, *args, **kwargs):
def open(self, func):
func()

def exec(self):
return 1

def selectedFiles(self):
return ['/tmp']

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class MockFileDialog:
def open(self, func):
func()

def exec(self):
return 1

def selectedFiles(self):
return ['/tmp']

Expand Down

0 comments on commit aa8f26c

Please sign in to comment.