def createMenu(self, parent): """ Creates a new menu for the inputed parent item. :param parent | <QMenu> """ menu = QtGui.QMenu(parent) menu.setTitle('&View') act = menu.addAction('&Lock/Unlock Layout') act.setIcon(QtGui.QIcon(projexui.resources.find('img/view/lock.png'))) act.triggered.connect(self.toggleLocked) menu.addSeparator() act = menu.addAction('&Export Layout as...') act.setIcon(QtGui.QIcon( projexui.resources.find('img/view/export.png'))) act.triggered.connect(self.exportProfile) act = menu.addAction('&Import Layout from...') act.setIcon(QtGui.QIcon( projexui.resources.find('img/view/import.png'))) act.triggered.connect(self.importProfile) menu.addSeparator() act = menu.addAction('&Clear Layout') act.setIcon(QtGui.QIcon( projexui.resources.find('img/view/remove.png'))) act.triggered.connect(self.resetForced) return menu
def showMenu(self, point): menu = QtGui.QMenu(self) acts = {} acts['clear'] = menu.addAction('Clear logs') menu.addSeparator() acts['copy'] = menu.addAction('Copy') acts['cut'] = menu.addAction('Cut') acts['paste'] = menu.addAction('Paste') trigger = menu.exec_(QtGui.QCursor.pos()) if trigger == acts.get('clear'): self.clear()