vorta
vorta copied to clipboard
Multiple selection does not work for directories.
Discussed in https://github.com/borgbase/vorta/discussions/1867
Originally posted by user723045 December 10, 2023 Hello. On the Source tab, I add directories and files to the list for backup. I noticed that when I select multiple files by holding down the shift key it works fine. But when I try to add several directories at a time in the same way, it does not work and only one single directory is added. This is very inconvenient if you need to select many directories, you have to make many more clicks.
I'm using borg 1.2.6 and Vorta 0.8.12 on Kali linux. I installed packages using apt.
Possible bug in how we deal with dirs/files.
In src/vorta/utils.py:
def choose_file_dialog(parent, title, want_folder=True):
dialog = QFileDialog(parent, title, os.path.expanduser('~'))
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)
return dialog
This is the function responsible for selecting sources, as we are using QFileDialog which doesn't have any feature to allow us to select multiple directories in one go. To do this, we need to find an alternative.
Is this really a limitation of Qt or are we using QFileDialog incorrectly?
Is this really a limitation of Qt or are we using QFileDialog incorrectly? Its is a limitation. Though alternatively, we can use
QTreeViewwithQAbstractItemView.SelectionMode.MultiSelectionselection mode.
def choose_file_dialog(parent, title, want_folder=True):
dialog = QFileDialog(parent, title, os.path.expanduser('~'))
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)
dir_dialog = dialog.findChild(QTreeView)
dir_dialog.setSelectionMode(QAbstractItemView.SelectionMode.MultiSelection)
return dialog
But here, just the problem is that dialog.selectedFiles() will not return the directories so, need to figure out a way to make it happen somehow.
Made a PR, not complete yet, now you can select multiple directories but none of them get added to the sources if selected multiple. If you select only one, that will do. So, it's halfway there.
Is this really a limitation of Qt or are we using QFileDialog incorrectly?
Its is a limitation. Though alternatively, we can use
QTreeViewwithQAbstractItemView.SelectionMode.MultiSelectionselection mode.
I think QFileDialog is better suited for single file/dir selection such as save dialog, than is the case here. Even if the manual says it's for single and multi.
I agree with the use of a treeview way as stated. Its more efficient and user friendly IMHO. I've worked with such a GUI in KDE's integrated kup-backup solution and it was very good.
Example for treeview:
The checkboxes are great for this i think. If you guys want to take a look at the code they use... warning, its in C++ / QT). This should be the right func for this:filedigger.cpp#L122
Greets
Is it still open? Can I work on this? I have worked on qt5 before, I think i can fix this. Can you assign it to me?
Is it still open? Can I work on this? I have worked on qt5 before, I think i can fix this. Can you assign it to me?
I'm still looking into it, but you can surely help
Is it still open? Can I work on this? I have worked on qt5 before, I think i can fix this. Can you assign it to me?
Whoever provides a mergeable PR first will be merged. However you can also choose to tackle another issue as there are plenty floating around.
I've analyzed the issue and concluded that it can be effectively resolved by using a custom QFileDialog. Most native file dialogs do not support selecting multiple directories due to inherent limitations in their standard interfaces. However, a custom file dialog can overcome this problem.
By enabling the DontUseNativeDialog option, QFileDialog switches from using the operating system's native dialog to a Qt-implemented dialog. This custom dialog is consistent across all platforms and can be extensively customized. Importantly, it supports features not available in native dialogs, such as the ability to select multiple directories at once. This functionality is essential for our use case but is typically unsupported by the default file dialogs on most operating systems.
Should I proceed with implementing this solution? It would involve using a custom QFileDialog to open when the user needs to select multiple folders, allowing for the selection of multiple directories in a single action.
It would involve using a custom QFileDialog
You mean custom in the sense of not being native, although provided by the framework? In that case this seems to be a good solution. If this would mean implementing a file dialog in Vorta's code base, I would oppose the idea.
Yes i mean custom in sense of not being native, but provided by the framework. It would uniformize the FileDialog across all operating systems and the FileDialog set by the user's file manager will not be used.
I have made a pull request and allowed multiselecting directories at other places as well including archives and choosing borg backup directory at places where only one directory needs to be selected if multiple directories are selected the first directory selected will be taken
Hello, I've made some updates to the pull request. I believe the changes are ready for review and merging. Could you please take a look and let me know if there are any further changes needed or if it's ready for merging? Thanks!
Hi there, I've just noticed there might be one trailing whitespace that I forgot to remove. However, aside from that, all test cases pass on my local machine. I'm a bit puzzled by the font-related test case failure. Could you please take a look at the latest changes and help identify the issue with the font test case? Your insights would be greatly appreciated. Thanks in advance for your assistance!
Hi @real-yfprojects, If this issue is still open, I would like to work on it. Can you assign it to me?
We already have 2 PRs for this. Would be good to take the best of each and just merge something
https://github.com/borgbase/vorta/pulls?q=is%3Apr+is%3Aopen+multiselect+OR+multiselection