1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-21 23:33:13 +00:00

Disable Archive tab buttons during backup. By @sunny775 (#1587)

* Disable archive action buttons when running backup.
* Disable archive action buttons only individually.
* Fix enabling.
* fixup! Fix enabling.

---------

Co-authored-by: real-yfprojects <real-yfprojects@users.noreply.github.com>
Co-authored-by: Manu <3916435+m3nu@users.noreply.github.com>
This commit is contained in:
Nkwuda Sunday Cletus 2023-03-23 15:15:07 +01:00 committed by GitHub
parent 3ebb078409
commit d0245977d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -231,8 +231,10 @@ def _toggle_all_buttons(self, enabled=True):
self.bList,
self.bPrune,
self.bDiff,
self.fArchiveActions,
self.bMountRepo,
self.bDelete,
self.compactButton,
self.fArchiveActions,
]:
button.setEnabled(enabled)
button.repaint()
@ -322,17 +324,22 @@ def on_selection_change(self, selected=None, deselected=None):
# Toggle archive actions frame
layout: QLayout = self.fArchiveActions.layout()
# task in progress -> disable all
reason = ""
if not self.repoactions_enabled:
reason = self.tr("(borg already running)")
# toggle delete button
if len(indexes) > 0:
if self.repoactions_enabled and len(indexes) > 0:
self.bDelete.setEnabled(True)
self.bDelete.setToolTip(self.tooltip_dict.get(self.bDelete, ""))
else:
self.bDelete.setEnabled(False)
tooltip = self.tooltip_dict[self.bDelete]
self.bDelete.setToolTip(tooltip + " " + self.tr("(Select minimum one archive)"))
self.bDelete.setToolTip(tooltip + " " + reason or self.tr("(Select minimum one archive)"))
# Toggle diff button
if len(indexes) == 2:
if self.repoactions_enabled and len(indexes) == 2:
# Enable diff button
self.bDiff.setEnabled(True)
self.bDiff.setToolTip(self.tooltip_dict.get(self.bDiff, ""))
@ -341,9 +348,9 @@ def on_selection_change(self, selected=None, deselected=None):
self.bDiff.setEnabled(False)
tooltip = self.tooltip_dict[self.bDiff]
self.bDiff.setToolTip(tooltip + " " + self.tr("(Select two archives)"))
self.bDiff.setToolTip(tooltip + " " + reason or self.tr("(Select two archives)"))
if len(indexes) == 1:
if self.repoactions_enabled and len(indexes) == 1:
# Enable archive actions
self.fArchiveActions.setEnabled(True)
@ -354,6 +361,8 @@ def on_selection_change(self, selected=None, deselected=None):
# refresh bMountArchive for the selected archive
self.bmountarchive_refresh()
else:
reason = reason or self.tr("(Select exactly one archive)")
# too few or too many selected.
self.fArchiveActions.setEnabled(False)
@ -362,12 +371,12 @@ def on_selection_change(self, selected=None, deselected=None):
tooltip = widget.toolTip()
tooltip = self.tooltip_dict.setdefault(widget, tooltip)
widget.setToolTip(tooltip + " " + self.tr("(Select exactly one archive)"))
widget.setToolTip(tooltip + " " + reason)
# special treatment for dynamic mount/unmount button.
self.bmountarchive_refresh()
tooltip = self.bMountArchive.toolTip()
self.bMountArchive.setToolTip(tooltip + " " + self.tr("(Select exactly one archive)"))
self.bMountArchive.setToolTip(tooltip + " " + reason)
def archive_copy(self, index=None):
"""