def _createTrayMenu(self): '''Return a menu for system tray.''' menu = QtWidgets.QMenu(self) logoutAction = QtWidgets.QAction( 'Log Out && Quit', self, triggered=self.logout ) quitAction = QtWidgets.QAction( 'Quit', self, triggered=QtWidgets.qApp.quit ) focusAction = QtWidgets.QAction( 'Open', self, triggered=self.focus ) openPluginDirectoryAction = QtWidgets.QAction( 'Open plugin directory', self, triggered=self.openDefaultPluginDirectory ) aboutAction = QtWidgets.QAction( 'About', self, triggered=self.showAbout ) menu.addAction(aboutAction) menu.addAction(focusAction) menu.addSeparator() menu.addAction(openPluginDirectoryAction) menu.addSeparator() menu.addAction(logoutAction) menu.addSeparator() menu.addAction(quitAction) return menu
def mouseReleaseEvent(self, event): '''Launch action on mouse release. First show menu with variants if multiple actions are available. ''' if self._multiple: self.logger.debug('Launching menu to select action variant') menu = QtWidgets.QMenu(self) for index, variant in enumerate(self._variants): action = QtWidgets.QAction(variant, self) action.setData(index) menu.addAction(action) result = menu.exec_(QtWidgets.QCursor.pos()) if result is None: return action = self._actions[result.data()] else: action = self._actions[0] self._launchAction(action)
def __init__(self, parent, task=None, connector=None): '''Instantiate asset manager with *connector*.''' QtWidgets.QWidget.__init__(self, parent) if not connector: raise ValueError( 'Please provide a connector object for {0}'.format( self.__class__.__name__)) self.connector = connector self.ui = Ui_AssetManager() self.ui.setupUi(self) self.setMinimumWidth(500) self.ui.AssertManagerTableWidget.setSortingEnabled(True) self.ui.AssertManagerTableWidget.setShowGrid(False) self.ui.AssertManagerTableWidget.verticalHeader().hide() self.ui.AssertManagerTableWidget.setColumnCount(16) self.ui.AssertManagerTableWidget.horizontalHeader( ).setDefaultSectionSize(65) self.ui.AssertManagerTableWidget.setColumnWidth(0, 20) self.ui.AssertManagerTableWidget.setColumnWidth(5, 55) self.ui.AssertManagerTableWidget.setColumnWidth(6, 65) self.ui.AssertManagerTableWidget.setColumnWidth(9, 20) self.ui.AssertManagerTableWidget.setColumnWidth(10, 20) self.ui.AssertManagerTableWidget.setColumnWidth(11, 20) self.ui.AssertManagerTableWidget.setColumnWidth(15, 20) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( QtWidgets.QHeaderView.Stretch) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( 0, QtWidgets.QHeaderView.Fixed) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( 5, QtWidgets.QHeaderView.Fixed) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( 6, QtWidgets.QHeaderView.Fixed) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( 9, QtWidgets.QHeaderView.Fixed) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( 10, QtWidgets.QHeaderView.Fixed) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( 11, QtWidgets.QHeaderView.Fixed) self.ui.AssertManagerTableWidget.horizontalHeader().setResizeMode( 15, QtWidgets.QHeaderView.Fixed) self.ui.AssertManagerTableWidget.setColumnHidden(2, True) self.ui.AssertManagerTableWidget.setColumnHidden(3, True) self.ui.AssertManagerTableWidget.setColumnHidden(6, True) self.ui.AssertManagerTableWidget.setColumnHidden(10, True) self.ui.AssertManagerTableWidget.setColumnHidden(12, True) self.ui.AssertManagerTableWidget.setColumnHidden(13, True) self.ui.AssertManagerTableWidget.setColumnHidden(14, True) self.columnHeaders = [ '', 'Component', 'CmpId', 'AssetTypeShort', 'Type', 'Version', 'LatestV', 'Name', 'SceneName', '', '', '', 'AssetId', 'AssetVersionId', 'CurrentVersionFallback', '' ] self.ui.AssertManagerTableWidget.setHorizontalHeaderLabels( self.columnHeaders) self.ui.AssetManagerComboBoxModel = QtGui.QStandardItemModel() assetTypes = ftrack.getAssetTypes() assetTypes = sorted(assetTypes, key=lambda a: a.getName().lower()) assetTypeItem = QtGui.QStandardItem('Show All') self.ui.AssetManagerComboBoxModel.appendRow(assetTypeItem) for assetType in assetTypes: assetTypeItem = QtGui.QStandardItem(assetType.getName()) assetTypeItem.type = assetType.getShort() self.ui.AssetManagerComboBoxModel.appendRow(assetTypeItem) self.ui.AssetManagerComboBox.setModel( self.ui.AssetManagerComboBoxModel) self.signalMapperSelect = QtCore.QSignalMapper() self.signalMapperSelect.mapped[str].connect(self.selectObject) self.signalMapperRemove = QtCore.QSignalMapper() self.signalMapperRemove.mapped[str].connect(self.removeObject) self.signalMapperComment = QtCore.QSignalMapper() self.signalMapperComment.mapped[str].connect(self.openComments) extraOptionsMenu = QtWidgets.QMenu(self.ui.menuButton) extraOptionsMenu.addAction('Get SceneSelection', self.getSceneSelection) extraOptionsMenu.addAction('Set SceneSelection', self.setSceneSelection) self.ui.menuButton.setMenu(extraOptionsMenu) self.refreshAssetManager()