mirror of https://github.com/borgbase/vorta
Remove *unset* repository value from combobox when a repo is selected.
* src/vorta/views/repo_tab.py (init_repo_stats): Remove *unset* item from combobox. * src/vorta/views/repo_tab.py (populate_from_profile): Move into `populate_repositories`. * src/vorta/views/repo_tab.py (repo_unlink_action): Update unset condition. And repopulate repo combobox. * src/vorta/views/repo_tab.py populate_repositories -> populate_from_profile * src/vorta/views/main_window.py * tests/test_repo.py : Fix tests.
This commit is contained in:
parent
14d587876e
commit
2126ef769d
|
@ -213,7 +213,7 @@ class MainWindow(MainWindowBase, MainWindowUI):
|
|||
self.tr('Profile import successful!'),
|
||||
self.tr('Profile {} imported.').format(profile.name),
|
||||
)
|
||||
self.repoTab.populate_repositories()
|
||||
self.repoTab.populate_from_profile()
|
||||
self.scheduleTab.populate_logs()
|
||||
self.scheduleTab.populate_wifi()
|
||||
self.miscTab.populate()
|
||||
|
|
|
@ -22,7 +22,7 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
self.setupUi(parent)
|
||||
|
||||
# Populate dropdowns
|
||||
self.populate_repositories()
|
||||
self.populate_from_profile()
|
||||
self.repoRemoveToolbutton.clicked.connect(self.repo_unlink_action)
|
||||
self.copyURLbutton.clicked.connect(self.copy_URL_action)
|
||||
|
||||
|
@ -60,7 +60,6 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
self.sshKeyToClipboardButton.clicked.connect(self.ssh_copy_to_clipboard_action)
|
||||
self.bAddSSHKey.clicked.connect(self.create_ssh_key)
|
||||
|
||||
self.populate_from_profile()
|
||||
self.set_icons()
|
||||
|
||||
# Connect to palette change
|
||||
|
@ -79,16 +78,16 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
for repo in RepoModel.select():
|
||||
self.repoSelector.addItem(repo.url, repo.id)
|
||||
|
||||
def populate_repositories(self):
|
||||
def populate_from_profile(self):
|
||||
try:
|
||||
self.repoSelector.currentIndexChanged.disconnect(self.repo_select_action)
|
||||
except TypeError: # raised when signal is not connected
|
||||
pass
|
||||
self.set_repos()
|
||||
self.populate_from_profile()
|
||||
self.repoSelector.currentIndexChanged.connect(self.repo_select_action)
|
||||
|
||||
def populate_from_profile(self):
|
||||
# populate repositories
|
||||
self.set_repos()
|
||||
|
||||
# load profile configuration
|
||||
profile = self.profile()
|
||||
if profile.repo:
|
||||
self.repoSelector.setCurrentIndex(self.repoSelector.findData(profile.repo.id))
|
||||
|
@ -99,6 +98,8 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
self.sshComboBox.setCurrentIndex(self.sshComboBox.findData(profile.ssh_key))
|
||||
self.init_repo_stats()
|
||||
|
||||
self.repoSelector.currentIndexChanged.connect(self.repo_select_action)
|
||||
|
||||
def init_repo_stats(self):
|
||||
"""Set the strings of the repo stats labels."""
|
||||
# prepare translations
|
||||
|
@ -110,6 +111,8 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
repo: RepoModel = self.profile().repo
|
||||
if repo is not None:
|
||||
self.frameRepoSettings.setEnabled(True)
|
||||
# remove *unset* item
|
||||
self.repoSelector.removeItem(self.repoSelector.findData(None))
|
||||
|
||||
# local repo doesn't use ssh
|
||||
ssh_enabled = repo.is_remote_repo()
|
||||
|
@ -267,7 +270,7 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
selected_repo_id = self.repoSelector.currentData()
|
||||
selected_repo_index = self.repoSelector.currentIndex()
|
||||
|
||||
if selected_repo_index <= 0:
|
||||
if not selected_repo_id:
|
||||
# QComboBox is empty / repo unset
|
||||
return
|
||||
|
||||
|
@ -285,7 +288,7 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
|
|||
msg.show()
|
||||
|
||||
self.repo_changed.emit()
|
||||
self.init_repo_stats()
|
||||
self.populate_from_profile()
|
||||
|
||||
def copy_URL_action(self):
|
||||
selected_repo_id = self.repoSelector.currentData()
|
||||
|
|
|
@ -50,7 +50,7 @@ def test_repo_unlink(qapp, qtbot):
|
|||
main = qapp.main_window
|
||||
tab = main.repoTab
|
||||
|
||||
main.tabWidget.setCurrentIndex(1)
|
||||
main.tabWidget.setCurrentIndex(0)
|
||||
qtbot.mouseClick(tab.repoRemoveToolbutton, QtCore.Qt.LeftButton)
|
||||
qtbot.waitUntil(lambda: tab.repoSelector.count() == 1, **pytest._wait_defaults)
|
||||
assert RepoModel.select().count() == 0
|
||||
|
|
Loading…
Reference in New Issue