Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiselection of folders in sources tab #1871

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/vorta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
import psutil
from PyQt6 import QtCore
from PyQt6.QtCore import QFileInfo, QThread, pyqtSignal
from PyQt6.QtWidgets import QApplication, QFileDialog, QSystemTrayIcon
from PyQt6.QtWidgets import (
QAbstractItemView,
QApplication,
QFileDialog,
QListView,
QSystemTrayIcon,
)

from vorta.borg._compatibility import BorgCompatibility
from vorta.log import logger
Expand Down Expand Up @@ -172,6 +178,10 @@ def choose_file_dialog(parent, title, want_folder=True):
dialog.setParent(parent, QtCore.Qt.WindowType.Sheet)
if want_folder:
dialog.setOption(QFileDialog.Option.ShowDirsOnly)
list_view = dialog.findChild(QListView)
if list_view:
list_view.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)

return dialog


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
6 changes: 4 additions & 2 deletions src/vorta/views/source_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ def receive():
new_source.save()

msg = self.tr("Choose directory to back up") if want_folder else self.tr("Choose file(s) to back up")
dialog = choose_file_dialog(self, msg, want_folder=want_folder)
dialog.open(receive)

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
Loading