Skip to content

Commit

Permalink
Disable Archive tab buttons during backup. By @sunny775 (#1587)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Mar 23, 2023
1 parent 3ebb078 commit d024597
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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, ""))
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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):
"""
Expand Down

0 comments on commit d024597

Please sign in to comment.