Prevent borg operation while renaming. By @bigtedde (#1791)

This commit is contained in:
Ted Lawson 2023-09-11 12:29:07 -07:00 committed by GitHub
parent 7d2b3634f1
commit 4350f78de5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -825,6 +825,9 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
self._toggle_all_buttons(True)
def cell_double_clicked(self, row=None, column=None):
if not self.bRename.isEnabled():
return
if not row or not column:
row = self.archiveTable.currentRow()
column = self.archiveTable.currentColumn()

View File

@ -179,7 +179,10 @@ def test_refresh_archive_info(qapp, qtbot, mocker, borg_json_output, archive_env
qtbot.waitUntil(lambda: tab.mountErrors.text() == 'Refreshed archives.', **pytest._wait_defaults)
def test_archive_rename(qapp, qtbot, mocker, borg_json_output, archive_env):
def test_inline_archive_rename(qapp, qtbot, mocker, borg_json_output, archive_env):
"""
Tests the functionality of in-line renaming an archive by double-clicking its name.
"""
main, tab = archive_env
tab.archiveTable.selectRow(0)
@ -190,9 +193,12 @@ def test_archive_rename(qapp, qtbot, mocker, borg_json_output, archive_env):
pos = tab.archiveTable.visualRect(tab.archiveTable.model().index(0, 4)).center()
qtbot.mouseClick(tab.archiveTable.viewport(), QtCore.Qt.MouseButton.LeftButton, pos=pos)
assert tab.bRename.isEnabled()
qtbot.mouseDClick(tab.archiveTable.viewport(), QtCore.Qt.MouseButton.LeftButton, pos=pos)
tab.archiveTable.viewport().focusWidget().setText("")
qtbot.keyClicks(tab.archiveTable.viewport().focusWidget(), new_archive_name)
qtbot.keyClick(tab.archiveTable.viewport().focusWidget(), QtCore.Qt.Key.Key_Return)
# Successful rename case
qtbot.waitUntil(lambda: tab.archiveTable.model().index(0, 4).data() == new_archive_name, **pytest._wait_defaults)
assert tab.archiveTable.model().index(0, 4).data() == new_archive_name