Skip to content

Commit

Permalink
remove styling from elements and add back exclude_if_present box
Browse files Browse the repository at this point in the history
  • Loading branch information
diivi authored and m3nu committed Nov 16, 2023
1 parent 9cae9f6 commit 9f5736a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 28 deletions.
27 changes: 27 additions & 0 deletions src/vorta/assets/UI/sourcetab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,33 @@
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1">
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Exclude If Present (exclude folders with these files):</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="excludeIfPresentField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
<property name="placeholderText">
<string>E.g. .nobackup</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
Expand Down
5 changes: 5 additions & 0 deletions src/vorta/borg/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def prepare(cls, profile):
cmd.extend(['--exclude-from', pattern_file.name])
ret['cleanup_files'].append(pattern_file)

if profile.exclude_if_present is not None:
for f in profile.exclude_if_present.split('\n'):
if f.strip():
cmd.extend(['--exclude-if-present', f.strip()])

# Add repo url and source dirs.
new_archive_name = format_archive_name(profile, profile.new_archive_name)

Expand Down
1 change: 1 addition & 0 deletions src/vorta/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class BackupProfileModel(BaseModel):
compression = pw.CharField(default='lz4')
raw_exclusions = pw.TextField(default='')
exclude_patterns = pw.TextField(null=True)
exclude_if_present = pw.TextField(null=True)
schedule_mode = pw.CharField(default='off')
schedule_interval_count = pw.IntegerField(default=3)
schedule_interval_unit = pw.CharField(default='hours')
Expand Down
26 changes: 0 additions & 26 deletions src/vorta/views/exclude_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ def __init__(self, profile, parent=None):
self.customExclusionsList.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.customExclusionsList.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.customExclusionsList.setAlternatingRowColors(True)
self.customExclusionsList.setStyleSheet(
'''
QListView::item {
padding: 10px 0px;
border-bottom: .5px solid black;
}
QListView::item:selected {
background-color: palette(highlight);
}
'''
)
self.customExclusionsListDelegate = QStyledItemDelegate()
self.customExclusionsList.setItemDelegate(self.customExclusionsListDelegate)
self.customExclusionsListDelegate.closeEditor.connect(self.custom_pattern_editing_finished)
Expand All @@ -91,20 +79,6 @@ def __init__(self, profile, parent=None):
self.exclusionPresetsList.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
self.exclusionPresetsList.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.exclusionPresetsList.setAlternatingRowColors(True)
self.exclusionPresetsList.setStyleSheet(
'''
QListView::item {
padding: 10px 0px;
border-bottom: .5px solid black;
}
QListView::item:selected {
background-color: palette(highlight);
}
QListView::item::icon {
padding-right: 10px;
}
'''
)

self.exclusionsPreviewText.setReadOnly(True)

Expand Down
10 changes: 8 additions & 2 deletions src/vorta/views/source_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(self, parent=None):
# Connect signals
self.removeButton.clicked.connect(self.source_remove)
self.updateButton.clicked.connect(self.sources_update)
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)
self.bExclude.clicked.connect(self.show_exclude_dialog)
header.sortIndicatorChanged.connect(self.update_sort_order)

Expand Down Expand Up @@ -251,7 +252,9 @@ def add_source_to_table(self, source, update_data=None):

def populate_from_profile(self):
profile = self.profile()
self.excludeIfPresentField.textChanged.disconnect()
self.sourceFilesWidget.setRowCount(0) # Clear rows
self.excludeIfPresentField.clear()

for source in SourceFileModel.select().where(SourceFileModel.profile == profile):
self.add_source_to_table(source, False)
Expand All @@ -263,6 +266,9 @@ def populate_from_profile(self):
# Sort items as per settings
self.sourceFilesWidget.sortItems(sourcetab_sort_column, Qt.SortOrder(sourcetab_sort_order))

self.excludeIfPresentField.appendPlainText(profile.exclude_if_present)
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)

def update_sort_order(self, column: int, order: int):
"""Save selected sort by column and order to settings"""
SettingsModel.update({SettingsModel.str_value: str(column)}).where(
Expand Down Expand Up @@ -347,9 +353,9 @@ def show_exclude_dialog(self):
self._window = window # for testing
window.show()

def save_exclude_patterns(self):
def save_exclude_if_present(self):
profile = self.profile()
profile.exclude_patterns = ""
profile.exclude_if_present = self.excludeIfPresentField.toPlainText()
profile.save()

def paste_text(self):
Expand Down

0 comments on commit 9f5736a

Please sign in to comment.