mirror of
https://github.com/borgbase/vorta
synced 2025-01-03 05:36:19 +00:00
sources: add option to add a single file
This commit is contained in:
parent
94f03f052c
commit
cd7c121c1f
3 changed files with 19 additions and 9 deletions
|
@ -17,7 +17,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Choose folders to back up.</string>
|
||||
<string>Source folders and files to back up</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -42,16 +42,23 @@
|
|||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="sourceAdd">
|
||||
<widget class="QPushButton" name="sourceAddFolder">
|
||||
<property name="text">
|
||||
<string>Add Folder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="sourceAddFile">
|
||||
<property name="text">
|
||||
<string>Add File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignTop">
|
||||
<widget class="QPushButton" name="sourceRemove">
|
||||
<property name="text">
|
||||
<string>Remove Folder</string>
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -57,11 +57,12 @@ def delete_password(self, service, repo_url):
|
|||
keyring.set_keyring(VortaKeyring())
|
||||
|
||||
|
||||
def choose_folder_dialog(parent, title):
|
||||
def choose_folder_dialog(parent, title, want_folder=True):
|
||||
options = QFileDialog.Options()
|
||||
options |= QFileDialog.ShowDirsOnly
|
||||
if want_folder:
|
||||
options |= QFileDialog.ShowDirsOnly
|
||||
dialog = QFileDialog(parent, title, os.path.expanduser('~'), options=options)
|
||||
dialog.setFileMode(QFileDialog.Directory)
|
||||
dialog.setFileMode(QFileDialog.Directory if want_folder else QFileDialog.AnyFile)
|
||||
dialog.setParent(parent, QtCore.Qt.Sheet)
|
||||
return dialog
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ def __init__(self, parent=None):
|
|||
super().__init__(parent)
|
||||
self.setupUi(parent)
|
||||
|
||||
self.sourceAdd.clicked.connect(self.source_add)
|
||||
self.sourceAddFolder.clicked.connect(lambda: self.source_add(want_folder=True))
|
||||
self.sourceAddFile.clicked.connect(lambda: self.source_add(want_folder=False))
|
||||
self.sourceRemove.clicked.connect(self.source_remove)
|
||||
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
||||
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)
|
||||
|
@ -33,7 +34,7 @@ def populate_from_profile(self):
|
|||
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
||||
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)
|
||||
|
||||
def source_add(self):
|
||||
def source_add(self, want_folder):
|
||||
def receive():
|
||||
dir = dialog.selectedFiles()
|
||||
if dir:
|
||||
|
@ -42,7 +43,8 @@ def receive():
|
|||
self.sourceDirectoriesWidget.addItem(dir[0])
|
||||
new_source.save()
|
||||
|
||||
dialog = choose_folder_dialog(self, "Choose Directory to back up")
|
||||
item = "directory" if want_folder else "file"
|
||||
dialog = choose_folder_dialog(self, "Choose %s to back up" % item, want_folder=want_folder)
|
||||
dialog.open(receive)
|
||||
|
||||
def source_remove(self):
|
||||
|
|
Loading…
Reference in a new issue