mirror of
https://github.com/borgbase/vorta
synced 2025-01-03 05:36:19 +00:00
Retain source tab sort settings. By @jetchirag (#1649)
This commit is contained in:
parent
a64493d254
commit
6d5e738107
2 changed files with 29 additions and 2 deletions
|
@ -100,6 +100,18 @@ def get_misc_settings() -> List[Dict[str, str]]:
|
||||||
'type': 'internal',
|
'type': 'internal',
|
||||||
'label': 'Previous window height',
|
'label': 'Previous window height',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'key': 'sourcetab_sort_column',
|
||||||
|
'str_value': '0',
|
||||||
|
'type': 'internal',
|
||||||
|
'label': 'Source Tab Sort Column',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'key': 'sourcetab_sort_order',
|
||||||
|
'str_value': '0',
|
||||||
|
'type': 'internal',
|
||||||
|
'label': 'Source Tab Sort Order',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
settings += [
|
settings += [
|
||||||
|
|
|
@ -88,6 +88,7 @@ def __init__(self, parent=None):
|
||||||
self.updateButton.clicked.connect(self.sources_update)
|
self.updateButton.clicked.connect(self.sources_update)
|
||||||
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
||||||
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)
|
self.excludeIfPresentField.textChanged.connect(self.save_exclude_if_present)
|
||||||
|
header.sortIndicatorChanged.connect(self.update_sort_order)
|
||||||
|
|
||||||
# Connect to palette change
|
# Connect to palette change
|
||||||
QApplication.instance().paletteChanged.connect(lambda p: self.set_icons())
|
QApplication.instance().paletteChanged.connect(lambda p: self.set_icons())
|
||||||
|
@ -244,13 +245,27 @@ def populate_from_profile(self):
|
||||||
for source in SourceFileModel.select().where(SourceFileModel.profile == profile):
|
for source in SourceFileModel.select().where(SourceFileModel.profile == profile):
|
||||||
self.add_source_to_table(source, False)
|
self.add_source_to_table(source, False)
|
||||||
|
|
||||||
# Initially, sort entries by path name in ascending order
|
# Fetch the Sort by Column and order
|
||||||
self.sourceFilesWidget.sortItems(SourceColumn.Path, QtCore.Qt.AscendingOrder)
|
sourcetab_sort_column = int(SettingsModel.get(key='sourcetab_sort_column').str_value)
|
||||||
|
sourcetab_sort_order = int(SettingsModel.get(key='sourcetab_sort_order').str_value)
|
||||||
|
|
||||||
|
# Sort items as per settings
|
||||||
|
self.sourceFilesWidget.sortItems(sourcetab_sort_column, sourcetab_sort_order)
|
||||||
|
|
||||||
self.excludePatternsField.appendPlainText(profile.exclude_patterns)
|
self.excludePatternsField.appendPlainText(profile.exclude_patterns)
|
||||||
self.excludeIfPresentField.appendPlainText(profile.exclude_if_present)
|
self.excludeIfPresentField.appendPlainText(profile.exclude_if_present)
|
||||||
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
self.excludePatternsField.textChanged.connect(self.save_exclude_patterns)
|
||||||
self.excludeIfPresentField.textChanged.connect(self.save_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(
|
||||||
|
SettingsModel.key == 'sourcetab_sort_column'
|
||||||
|
).execute()
|
||||||
|
SettingsModel.update({SettingsModel.str_value: str(order)}).where(
|
||||||
|
SettingsModel.key == 'sourcetab_sort_order'
|
||||||
|
).execute()
|
||||||
|
|
||||||
def sources_update(self):
|
def sources_update(self):
|
||||||
"""
|
"""
|
||||||
Update each row in the sources table.
|
Update each row in the sources table.
|
||||||
|
|
Loading…
Reference in a new issue