Skip to content

Commit

Permalink
bonded archive button toggles to context menu actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtedde committed Sep 1, 2023
1 parent 567a354 commit db86da4
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions src/vorta/views/archive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from PyQt6 import QtCore, uic
from PyQt6.QtCore import QItemSelectionModel, QMimeData, QPoint, Qt, pyqtSlot
from PyQt6.QtGui import QAction, QDesktopServices, QKeySequence, QShortcut
from PyQt6.QtGui import QDesktopServices, QKeySequence, QShortcut
from PyQt6.QtWidgets import (
QAbstractItemView,
QApplication,
Expand Down Expand Up @@ -183,46 +183,22 @@ def archiveitem_contextmenu(self, pos: QPoint):
return # popup only for selected items

menu = QMenu(self.archiveTable)
menu.addAction(
get_colored_icon('copy'),
self.tr("Copy"),
lambda: self.archive_copy(index=index),
)
menu.addAction(get_colored_icon('copy'), self.tr("Copy"), lambda: self.archive_copy(index=index))
menu.addSeparator()

# archive actions
archive_actions = []
archive_actions.append(
menu.addAction(
self.bRefreshArchive.icon(),
self.bRefreshArchive.text(),
self.refresh_archive_info,
)
)
archive_actions.append(
menu.addAction(
self.bMountArchive.icon(),
self.bMountArchive.text(),
self.bmountarchive_clicked,
)
)
archive_actions.append(menu.addAction(self.bExtract.icon(), self.bExtract.text(), self.extract_action))
archive_actions.append(menu.addAction(self.bRename.icon(), self.bRename.text(), self.cell_double_clicked))
# deletion possible with one but also multiple archives
menu.addAction(self.bDelete.icon(), self.bDelete.text(), self.delete_action)

if not (self.repoactions_enabled and len(selected_rows) <= 1):
for action in archive_actions:
action.setEnabled(False)

# diff action
menu.addSeparator()
diff_action = QAction(self.bDiff.icon(), self.bDiff.text(), menu)
diff_action.triggered.connect(self.diff_action)
menu.addAction(diff_action)

selected_rows = self.archiveTable.selectionModel().selectedRows(index.column())
diff_action.setEnabled(self.repoactions_enabled and len(selected_rows) == 2)
button_connection_pairs = [
(self.bRefreshArchive, self.refresh_archive_info),
(self.bMountArchive, self.bmountarchive_clicked),
(self.bExtract, self.extract_action),
(self.bRename, self.cell_double_clicked),
(self.bDelete, self.delete_action),
(self.bDiff, self.diff_action),
]

for button, connection in button_connection_pairs:
action = menu.addAction(button.icon(), button.text(), connection)
action.setEnabled(button.isEnabled())

menu.popup(self.archiveTable.viewport().mapToGlobal(pos))

Expand Down

0 comments on commit db86da4

Please sign in to comment.