def contextMenuEvent(self, event): """ contextMenuEvent Menu when an item in the view is right clicked Args: event (event): used to get the row/column right clicked """ model = self.proxyModel.sourceModel() index = self.indexAt(event.pos()) modelIndex = self.proxyModel.mapToSource(index) row = modelIndex.row() totalSelectedRows = len(self.selectedIndexes()) # row = self.rowAt(event.pos().y()) totalRows = self.proxyModel.rowCount() if 0 <= row < totalRows: menu = QMenu() menu.setFont(self.parent.font()) if totalSelectedRows == 1: menu.addAction(_("Copy")) if model.dataset[row, JobKey.Status] not in [ JobStatus.Running, JobStatus.Skip, JobStatus.Abort, ]: menu.addAction(_("Remove")) menu.addAction(_("Save")) if action := menu.exec_(event.globalPos()): result = action.text() if result == _("Copy"): self.copySelection() elif result == _("Remove"): ## # BUG #7 # # Jobs still execute after been removed from list # validate before remove ## self.removeSelection() elif result == _("Save"): self.saveSelection()
def contextMenuEvent(self, event): """Context Menu""" row = self.rowAt(event.pos().y()) totalRows = self.proxyModel.rowCount() if 0 <= row < totalRows: menu = QMenu() menu.setFont(self.parent.font()) menu.addAction(_("Copy to command")) # menu.addAction(_("Remove")) menu.addAction(_("Delete")) if action := menu.exec_(event.globalPos()): result = action.text() if result == _("Copy to command"): self.copyCommand() if result == _("Delete"): self.deleteSelectedRows() elif result == _("Remove"): self.removeSelection()
def contextMenuEvent(self, event): menu = QMenu() menu.setStyleSheet(Theme.contextMenu.style) menu.setFont(Theme.contextMenu.font) menu.addActions(self.actions()) menu.exec_(event.globalPos())