示例#1
0
    def contextEditMenu(self, menu, items=None):
        """
        Called when the user would like to edit the item from the menu.

        The given menu is shown as a submenu of the main context menu.

        :type menu: QtWidgets.QMenu
        :type items: list[LibraryItem]
        :rtype: None
        """
        if self.ENABLE_DELETE:
            action = QtWidgets.QAction("Delete", menu)
            action.triggered.connect(self.showDeleteDialog)
            menu.addAction(action)
            menu.addSeparator()

        action = QtWidgets.QAction("Rename", menu)
        action.triggered.connect(self.showRenameDialog)
        menu.addAction(action)

        action = QtWidgets.QAction("Move to", menu)
        action.triggered.connect(self.showMoveDialog)
        menu.addAction(action)

        action = QtWidgets.QAction("Show in Folder", menu)
        action.triggered.connect(self.showInFolder)
        menu.addAction(action)
示例#2
0
 def createSpaceOperatorMenu(self, parent=None):
     """
     Return the menu for changing the space operator.
     
     :type parent: QGui.QMenu
     :rtype: QGui.QMenu
     """
     searchFilter = self.searchFilter()
     menu = QtWidgets.QMenu(parent)
     menu.setTitle('Space Operator')
     action = QtWidgets.QAction(menu)
     action.setText('OR')
     action.setCheckable(True)
     callback = partial(self.setSpaceOperator, searchFilter.Operator.OR)
     action.triggered.connect(callback)
     if searchFilter.spaceOperator() == searchFilter.Operator.OR:
         action.setChecked(True)
     menu.addAction(action)
     action = QtWidgets.QAction(menu)
     action.setText('AND')
     action.setCheckable(True)
     callback = partial(self.setSpaceOperator, searchFilter.Operator.AND)
     action.triggered.connect(callback)
     if searchFilter.spaceOperator() == searchFilter.Operator.AND:
         action.setChecked(True)
     menu.addAction(action)
     return menu
示例#3
0
    def reload(self):
        """
        :rtype: None
        """
        self.clear()

        if self._enableSelectContent:
            action = selectContentAction(item=self.item(), parent=self)
            self.addAction(action)
            self.addSeparator()

        selectionSets = self.selectionSets()

        if selectionSets:
            for selectionSet in selectionSets:
                dirname = os.path.basename(selectionSet.dirname())
                basename = selectionSet.name().replace(
                    selectionSet.extension(), "")
                nicename = dirname + ": " + basename

                action = QtWidgets.QAction(nicename, self)
                callback = partial(selectionSet.load,
                                   namespaces=self.namespaces())
                action.triggered.connect(callback)
                self.addAction(action)
        else:
            action = QtWidgets.QAction("No selection sets found!", self)
            action.setEnabled(False)
            self.addAction(action)
示例#4
0
 def dockMenu(self):
     """
     Return a menu for editing the dock settings.
     
     :rtype: QtWidgets.QMenu
     """
     menu = QtWidgets.QMenu(self)
     menu.setTitle('Dock')
     action = QtWidgets.QAction('Set Floating', menu)
     action.setEnabled(self.isDocked())
     action.triggered.connect(self.setFloating)
     menu.addAction(action)
     menu.addSeparator()
     action = QtWidgets.QAction('Dock top', menu)
     action.setCheckable(True)
     action.setChecked(self.isDockedTop())
     action.triggered.connect(self.dockTop)
     menu.addAction(action)
     action = QtWidgets.QAction('Dock left', menu)
     action.setCheckable(True)
     action.setChecked(self.isDockedLeft())
     action.triggered.connect(self.dockLeft)
     menu.addAction(action)
     action = QtWidgets.QAction('Dock right', menu)
     action.setCheckable(True)
     action.setChecked(self.isDockedRight())
     action.triggered.connect(self.dockRight)
     menu.addAction(action)
     action = QtWidgets.QAction('Dock bottom', menu)
     action.setCheckable(True)
     action.setChecked(self.isDockedBottom())
     action.triggered.connect(self.dockBottom)
     menu.addAction(action)
     return menu
示例#5
0
    def createEditMenu(self, parent=None):
        """
        Return the edit menu for deleting, renaming folders.

        :rtype: QtWidgets.QMenu
        """
        selectedFolders = self.selectedFolders()

        menu = QtWidgets.QMenu(parent)
        menu.setTitle("Edit")

        if len(selectedFolders) == 1:
            action = QtWidgets.QAction("Rename", menu)
            action.triggered.connect(self.showRenameDialog)
            menu.addAction(action)

            action = QtWidgets.QAction("Show in folder", menu)
            action.triggered.connect(self.openSelectedFolders)
            menu.addAction(action)

        separator = QtWidgets.QAction("Separator2", menu)
        separator.setSeparator(True)
        menu.addAction(separator)

        action = QtWidgets.QAction("Show icon", menu)
        action.setCheckable(True)
        action.setChecked(self.isFolderIconVisible())
        action.triggered[bool].connect(self.setFolderIconVisible)
        menu.addAction(action)

        action = QtWidgets.QAction("Show bold", menu)
        action.setCheckable(True)
        action.setChecked(self.isFolderBold())
        action.triggered[bool].connect(self.setFolderBold)

        menu.addAction(action)
        separator = QtWidgets.QAction("Separator2", menu)
        separator.setSeparator(True)
        menu.addAction(separator)

        action = QtWidgets.QAction("Change icon", menu)
        action.triggered.connect(self.browseFolderIcon)
        menu.addAction(action)

        action = QtWidgets.QAction("Change color", menu)
        action.triggered.connect(self.browseFolderColor)
        menu.addAction(action)

        separator = QtWidgets.QAction("Separator3", menu)
        separator.setSeparator(True)
        menu.addAction(separator)

        action = QtWidgets.QAction("Reset settings", menu)
        action.triggered.connect(self.resetFolderSettings)
        menu.addAction(action)

        return menu
示例#6
0
    def createActions(self):
        """
        Crate the actions to be shown in the menu.
        
        :rtype: None 
        """
        # Create the menu actions for setting the accent color
        action = SeparatorAction("Accent", self)
        self.addAction(action)

        themes = self._themes

        if not themes:
            themes = themePresets()

        for theme in themes:
            if theme.accentColor():
                action = ThemeAction(theme, self)
                self.addAction(action)

        if self.ENABLE_CUSTOM_ACTION:
            action = QtWidgets.QAction("Custom", self)
            action.triggered.connect(self.theme().browseAccentColor)
            color = self.theme().accentColor().toString()
            icon = studiolibrary.resource().icon(ThemesMenu.THEME_ICON,
                                                 color=color)
            action.setIcon(icon)
            self.addAction(action)

        # Create the menu actions for setting the background color
        action = SeparatorAction("Background", self)
        self.addAction(action)

        for theme in themes:
            if not theme.accentColor() and theme.backgroundColor():
                action = ThemeAction(theme, self)
                self.addAction(action)

        if self.ENABLE_CUSTOM_ACTION:
            action = QtWidgets.QAction("Custom", self)
            action.triggered.connect(self._theme.browseBackgroundColor)
            color = self._theme.backgroundColor().toString()
            icon = studiolibrary.resource().icon(ThemesMenu.THEME_ICON,
                                                 color=color)
            action.setIcon(icon)
            self.addAction(action)

        self.triggered.connect(self._triggered)
示例#7
0
    def addAction(self, path, text, tip, callback):
        """
        Add an action to the tool bar.
        
        :type path: str 
        :type text: str
        :type tip: str
        :type callback: func
        
        :rtype: QtWidgets.QAction
        """
        icon = studioqt.Icon.fa(path,
                                color="rgb(250,250,250,160)",
                                color_active="rgb(250,250,250,250)",
                                color_disabled="rgb(0,0,0,20)")

        action = QtWidgets.QAction(icon, text, self._toolBar)
        action.setToolTip(tip)
        # action.setStatusTip(tip)
        # action.setWhatsThis(tip)

        self._toolBar.insertAction(self._firstSpacer, action)
        action.triggered.connect(callback)

        return action
示例#8
0
 def createItemSettingsMenu(self):
     menu = QtWidgets.QMenu('Item View', self)
     action = QtWidgets.QAction('Show labels', menu)
     action.setCheckable(True)
     action.setChecked(self.isItemTextVisible())
     action.triggered[bool].connect(self.setItemTextVisible)
     menu.addAction(action)
     menu.addSeparator()
     action = studioqt.SliderAction('Size', menu)
     action.slider().setMinimum(10)
     action.slider().setMaximum(200)
     action.slider().setValue(self.zoomAmount())
     action.slider().valueChanged.connect(self.setZoomAmount)
     menu.addAction(action)
     action = studioqt.SliderAction('Border', menu)
     action.slider().setMinimum(0)
     action.slider().setMaximum(20)
     action.slider().setValue(self.padding())
     action.slider().valueChanged.connect(self.setPadding)
     menu.addAction(action)
     action = studioqt.SliderAction('Spacing', menu)
     action.slider().setMinimum(self.DEFAULT_MIN_SPACING)
     action.slider().setMaximum(self.DEFAULT_MAX_SPACING)
     action.slider().setValue(self.spacing())
     action.slider().valueChanged.connect(self.setSpacing)
     menu.addAction(action)
     return menu
    def __init__(self, libraryWindow=None):
        super(LibrariesMenu, self).__init__(libraryWindow)

        self.setTitle('Libraries')

        libraries = studiolibrary.readSettings()
        default = studiolibrary.defaultLibrary()

        for name in libraries:

            library = libraries[name]

            path = library.get('path', '')
            kwargs = library.get('kwargs', {})

            enabled = True
            if libraryWindow:
                enabled = name != libraryWindow.name()

            text = name
            if name == default and name.lower() != "default":
                text = name + " (default)"

            action = QtWidgets.QAction(text, self)
            action.setEnabled(enabled)
            callback = partial(self.showLibrary, name, path, **kwargs)
            action.triggered.connect(callback)
            self.addAction(action)
示例#10
0
 def lockedMenu(self, menu):
     """
     :type menu: QtWidgets.QMenu
     :rtype: None
     """
     action = QtWidgets.QAction("Locked", menu)
     action.setEnabled(False)
     menu.addAction(action)
示例#11
0
def selectContentAction(record, parent=None):
    """
    :param record: mayabaseplugin.Record
    :param parent: QtWidgets.QMenu
    """
    icon = studiolibraryplugins.resource().icon("arrow")
    action = QtWidgets.QAction(icon, "Select content", parent)
    action.triggered.connect(record.selectContent)
    return action
示例#12
0
def selectContentAction(item, parent=None):
    """
    :param item: mayabaseitem.MayaBaseItem
    :param parent: QtWidgets.QMenu
    """
    icon = studiolibraryitems.resource().icon("arrow")
    action = QtWidgets.QAction(icon, "Select content", parent)
    action.triggered.connect(item.selectContent)
    return action
    def createOverwriteMenu(self, menu):
        """
        Create a menu or action to trigger the overwrite method.

        :type menu: QtWidgets.QMenu
        """
        if not self.isReadOnly():
            menu.addSeparator()
            action = QtWidgets.QAction("Overwrite", menu)
            action.triggered.connect(self.overwrite)
            menu.addAction(action)
示例#14
0
    def createSettingsMenu(self):
        """
        Create and return the settings menu for the widget.

        :rtype: QtWidgets.QMenu
        """
        menu = QtWidgets.QMenu("Item View", self)

        menu.addSeparator()

        action = QtWidgets.QAction("Show labels", menu)
        action.setCheckable(True)
        action.setChecked(self.isItemTextVisible())
        action.triggered[bool].connect(self.setItemTextVisible)
        menu.addAction(action)

        menu.addSeparator()

        sortByMenu = self.treeWidget().createSortByMenu()
        menu.addMenu(sortByMenu)

        groupByMenu = self.treeWidget().createGroupByMenu()
        menu.addMenu(groupByMenu)

        copyTextMenu = self.treeWidget().createCopyTextMenu()
        menu.addMenu(copyTextMenu)

        menu.addSeparator()

        action = studioqt.SliderAction("Size", menu)
        action.slider().setMinimum(10)
        action.slider().setMaximum(200)
        action.slider().setValue(self.zoomAmount())
        action.slider().valueChanged.connect(self.setZoomAmount)
        menu.addAction(action)

        action = studioqt.SliderAction("Border", menu)
        action.slider().setMinimum(0)
        action.slider().setMaximum(20)
        action.slider().setValue(self.padding())
        action.slider().valueChanged.connect(self.setPadding)
        menu.addAction(action)
        #
        action = studioqt.SliderAction("Spacing", menu)
        action.slider().setMinimum(self.DEFAULT_MIN_SPACING)
        action.slider().setMaximum(self.DEFAULT_MAX_SPACING)
        action.slider().setValue(self.spacing())
        action.slider().valueChanged.connect(self.setSpacing)
        menu.addAction(action)

        return menu
示例#15
0
    def createSpaceOperatorMenu(self, parent=None):
        """
        Return the menu for changing the space operator.

        :type parent: QGui.QMenu
        :rtype: QGui.QMenu
        """
        menu = QtWidgets.QMenu(parent)
        menu.setTitle("Space Operator")

        # Create the space operator for the OR operator
        action = QtWidgets.QAction(menu)
        action.setText("OR")
        action.setCheckable(True)

        callback = partial(self.setSpaceOperator, "or")
        action.triggered.connect(callback)

        if self.spaceOperator() == "or":
            action.setChecked(True)

        menu.addAction(action)

        # Create the space operator for the AND operator
        action = QtWidgets.QAction(menu)
        action.setText("AND")
        action.setCheckable(True)

        callback = partial(self.setSpaceOperator, "and")
        action.triggered.connect(callback)

        if self.spaceOperator() == "and":
            action.setChecked(True)

        menu.addAction(action)

        return menu
示例#16
0
    def reload(self):
        """
        :rtype: None
        """
        self.clear()

        if self._enableSelectContent:
            action = selectContentAction(item=self.item(), parent=self)
            self.addAction(action)
            self.addSeparator()

        selectionSets = self.selectionSets()

        if selectionSets:
            for selectionSet in selectionSets:
                dirname = os.path.basename(selectionSet.dirname())
                basename = selectionSet.name().replace(
                    selectionSet.extension(), "")
                nicename = '{0}{1}{2}'.format(dirname,
                                              ": " if dirname != '' else '',
                                              basename)

                if selectionSet.menuItemIcon() != '':
                    icon = studiolibrarymaya.resource().icon(
                        selectionSet.menuItemIcon())
                    action = QtWidgets.QAction(icon, nicename, self)
                else:
                    action = QtWidgets.QAction(nicename, self)
                callback = partial(selectionSet.load,
                                   namespaces=self.namespaces())
                action.triggered.connect(callback)
                self.addAction(action)
        else:
            action = QtWidgets.QAction("No selection sets found!", self)
            action.setEnabled(False)
            self.addAction(action)
    def __init__(self, path, force=False, parent=None):
        """
        Thumbnail capture menu.

        :type path: str
        :type force: bool
        :type parent: None or QtWidgets.QWidget
        """
        QtWidgets.QMenu.__init__(self, parent)

        self._path = path
        self._force = force

        changeImageAction = QtWidgets.QAction('Capture new image', self)
        changeImageAction.triggered.connect(self.capture)
        self.addAction(changeImageAction)

        changeImageAction = QtWidgets.QAction('Show Capture window', self)
        changeImageAction.triggered.connect(self.showCaptureWindow)
        self.addAction(changeImageAction)

        loadImageAction = QtWidgets.QAction('Load image from disk', self)
        loadImageAction.triggered.connect(self.showLoadImageDialog)
        self.addAction(loadImageAction)
示例#18
0
    def createAction(cls, menu, libraryWidget):
        """
        Return the action to be displayed when the user clicks the "plus" icon.

        :type menu: QtWidgets.QMenu
        :type libraryWidget: studiolibrary.LibraryWidget
        :rtype: QtCore.QAction
        """
        icon = QtGui.QIcon(cls.typeIconPath())
        callback = partial(cls.showCreateWidget, libraryWidget)

        action = QtWidgets.QAction(icon, "Pose", menu)
        action.triggered.connect(callback)

        return action
示例#19
0
    def contextMenu(self, menu, items=None):
        """
        Called when the user right clicks on the item.

        :type menu: QtWidgets.QMenu
        :type items: list[LibraryItem]
        :rtype: None
        """
        callback = partial(
            self._filterLibraries,
            [item for item in items if isinstance(item, FolderLibraryItem)])

        action = QtWidgets.QAction("Display only selected libraries", menu)
        action.triggered.connect(callback)
        menu.addAction(action)

        super(FolderLibraryItem, self).contextMenu(menu, items)
示例#20
0
    def createAction(cls, menu, libraryWindow):
        """
        Return the action to be displayed when the user 
        ks the "plus" icon.

        :type menu: QtWidgets.QMenu
        :type libraryWindow: studiolibrary.LibraryWindow
        :rtype: QtCore.QAction
        """
        if cls.MenuName:

            icon = QtGui.QIcon(cls.MenuIconPath)
            callback = partial(cls.showCreateWidget, libraryWindow)

            action = QtWidgets.QAction(icon, cls.MenuName, menu)
            action.triggered.connect(callback)

            return action
示例#21
0
    def createItemsMenu(self, items = None):
        """
        Create the item menu for given item.
        
        :rtype: QtWidgets.QMenu
        """
        item = items or self.selectedItem()
        menu = QtWidgets.QMenu(self)
        if item:
            try:
                item.contextMenu(menu)
            except Exception as msg:
                logger.exception(msg)

        else:
            action = QtWidgets.QAction(menu)
            action.setText('No Item selected')
            action.setDisabled(True)
            menu.addAction(action)
        return menu
示例#22
0
def showExample():
    """
    Run a simple example of the widget.

    :rtype: QtWidgets.QWidget
    """

    with studioqt.app():

        menuBarWidget = MenuBarWidget(None)

        def setIconColor():
            menuBarWidget.setIconColor(QtGui.QColor(255, 255, 0))

        def collapse():
            menuBarWidget.collapse()

        menuBarWidget.show()

        action = menuBarWidget.addAction("Collapse")
        action.triggered.connect(collapse)

        w = QtWidgets.QLineEdit()
        menuBarWidget.addWidget(w)

        icon = studiolibrary.resource().icon("add")
        menuBarWidget.addAction(icon, "Plus")
        menuBarWidget.setStyleSheet("""
background-color: rgb(0,200,100);
spacing:5px;
        """)

        menuBarWidget.setChildrenHeight(50)

        action = QtWidgets.QAction("Yellow", None)
        action.triggered.connect(setIconColor)
        menuBarWidget.insertAction("Plus", action)
        menuBarWidget.setGeometry(400, 400, 400, 100)

        menuBarWidget.expand()
    def createItemSettingsMenu(self):

        menu = QtWidgets.QMenu("Item View", self)

        action = SeparatorAction("View Settings", menu)
        menu.addAction(action)

        action = SliderAction("Size", menu)
        action.slider().setMinimum(10)
        action.slider().setMaximum(200)
        action.slider().setValue(self.zoomAmount())
        action.slider().valueChanged.connect(self.setZoomAmount)
        menu.addAction(action)

        action = SliderAction("Border", menu)
        action.slider().setMinimum(0)
        action.slider().setMaximum(20)
        action.slider().setValue(self.padding())
        action.slider().valueChanged.connect(self.setPadding)
        menu.addAction(action)
        #
        action = SliderAction("Spacing", menu)
        action.slider().setMinimum(self.DEFAULT_MIN_SPACING)
        action.slider().setMaximum(self.DEFAULT_MAX_SPACING)
        action.slider().setValue(self.spacing())
        action.slider().valueChanged.connect(self.setSpacing)
        menu.addAction(action)

        action = SeparatorAction("Item Options", menu)
        menu.addAction(action)

        action = QtWidgets.QAction("Show labels", menu)
        action.setCheckable(True)
        action.setChecked(self.isItemTextVisible())
        action.triggered[bool].connect(self.setItemTextVisible)
        menu.addAction(action)

        return menu
示例#24
0
    def __init__(self, libraryWindow=None):
        super(LibrariesMenu, self).__init__(libraryWindow)

        self.setTitle('Libraries')

        libraries = self.libraries()

        for name in libraries:

            library = libraries[name]

            path = library.get('path', '')
            kwargs = library.get('kwargs', {})

            enabled = True
            if libraryWindow:
                enabled = name != libraryWindow.name()

            action = QtWidgets.QAction(name, self)
            action.setEnabled(enabled)
            callback = partial(self.showLibrary, name, path, **kwargs)
            action.triggered.connect(callback)
            self.addAction(action)
示例#25
0
    def contextEditMenu(self, menu, items=None):
        """
        Called when the user would like to edit the item from the menu.

        The given menu is shown as a submenu of the main context menu.

        :type menu: QtWidgets.QMenu
        :type items: list[LibraryItem]
        :rtype: None
        """
        
        action = QtWidgets.QAction("Rename", menu)
        action.triggered.connect(self.showRenameDialog)
        menu.addAction(action)

        if self.EnableMoveCopy:
            action = QtWidgets.QAction("Replace", menu)
            action.triggered.connect(self.showCreateWidgetOverride)
            menu.addAction(action)

        self.contextMoveMenu(menu, items)
        self.contextCopyMenu(menu, items)

        if self.libraryWindow():
            action = QtWidgets.QAction("Select Folder", menu)
            action.triggered.connect(self.selectFolder)
            menu.addAction(action)

        menu.addSeparator()

        action = QtWidgets.QAction("Show in Folder", menu)
        action.triggered.connect(self.showInFolder)
        menu.addAction(action)

        action = QtWidgets.QAction("Copy Path", menu)
        action.triggered.connect(self.copyPathToClipboard)
        menu.addAction(action)

        if self.isDeleteEnabled():
            menu.addSeparator()
            action = QtWidgets.QAction("Delete", menu)
            action.triggered.connect(self.showDeleteDialog)
            menu.addAction(action)
示例#26
0
 def addRightAction(self, text):
     action = QtWidgets.QAction(text, self._rightToolBar)
     self._rightToolBar.addAction(action)
     return action
示例#27
0
    def createFolderFilterMenu(self, owner):

        menu = QtWidgets.QMenu("Folder Filter", owner)

        action = SeparatorAction("Library Filter", menu)
        menu.addAction(action)

        action = QtWidgets.QAction("Active Character", menu)
        action.setCheckable(True)
        action.setChecked(self.displayLibs() == SideBarDisplayLibs.FROM_SCENE)
        callback = partial(self.setLibraryFilter,
                           SideBarDisplayLibs.FROM_SCENE)
        action.triggered.connect(callback)
        menu.addAction(action)

        action = QtWidgets.QAction("All libraries", menu)
        action.setCheckable(True)
        action.setChecked(self.displayLibs() == SideBarDisplayLibs.ALL)
        callback = partial(self.setLibraryFilter, SideBarDisplayLibs.ALL)
        action.triggered.connect(callback)
        menu.addAction(action)

        action = QtWidgets.QAction("User defined", menu)
        action.setCheckable(True)
        action.setChecked(
            self.displayLibs() == SideBarDisplayLibs.USER_DEFINED)
        callback = partial(self.setLibraryFilter,
                           SideBarDisplayLibs.USER_DEFINED)
        action.triggered.connect(callback)
        menu.addAction(action)

        #find all the libraries
        libItems = self.dataset().findItems([{
            'operator':
            'or',
            'filters': [('type', 'is', 'Library')]
        }])
        libPaths = list(set([item.itemData()['lib_id'] for item in libItems]))

        def _libraryContextMenu(libPaths, lineEditAction, event):
            menu = LibrarySelectMenu(libPaths, parent=lineEditAction.line())
            menu.menu().setStyleSheet('background-color:black;')
            point = lineEditAction.line().mapToGlobal(
                QtCore.QPoint(lineEditAction.line().width(), 0))
            menu.show(point)
            lineEditAction.line().setText(menu.selected(full=False))
            lineEditAction.line().clearFocus()

        action = LineEditAction("Libraries Name", menu)
        action.line().setText(self._displayLibsDefined)
        action.line().contextMenuEvent = partial(_libraryContextMenu, libPaths,
                                                 action)
        action.valueChanged.connect(self.setLibaryFilterText)
        menu.addAction(action)

        action = SeparatorAction("Users Filter", menu)
        menu.addAction(action)

        action = QtWidgets.QAction(
            "Only [{0}]".format(self.dataset().currentUser()), menu)
        action.setCheckable(True)
        action.setChecked(self.displayUsers() == SideBarDisplayUser.CURRENT)
        callback = partial(self.setUserFilter, SideBarDisplayUser.CURRENT)
        action.triggered.connect(callback)
        menu.addAction(action)

        action = QtWidgets.QAction("All Active Users", menu)
        action.setCheckable(True)
        action.setChecked(
            self.displayUsers() == SideBarDisplayUser.ACTIVE_USERS)
        callback = partial(self.setUserFilter, SideBarDisplayUser.ACTIVE_USERS)
        action.triggered.connect(callback)
        menu.addAction(action)

        action = QtWidgets.QAction("All Users", menu)
        action.setCheckable(True)
        action.setChecked(self.displayUsers() == SideBarDisplayUser.ALL)
        callback = partial(self.setUserFilter, SideBarDisplayUser.ALL)
        action.triggered.connect(callback)
        menu.addAction(action)

        action = QtWidgets.QAction("User Defined", menu)
        action.setCheckable(True)
        action.setChecked(
            self.displayUsers() == SideBarDisplayUser.USER_DEFINED)
        callback = partial(self.setUserFilter, SideBarDisplayUser.USER_DEFINED)
        action.triggered.connect(callback)
        menu.addAction(action)

        #find all users
        userItems = self.dataset().findItems([{
            'operator':
            'or',
            'filters': [('type', 'is', 'User')]
        }])
        users = [item.name()[:-5] for item in userItems]

        def _userContextMenu(users, lineEditAction, event):
            menu = LibrarySelectMenu(users, parent=lineEditAction.line())
            menu.menu().setStyleSheet('background-color:black;')
            point = lineEditAction.line().mapToGlobal(
                QtCore.QPoint(lineEditAction.line().width(), 0))
            menu.show(point)
            lineEditAction.line().setText(menu.selected(full=False))
            lineEditAction.line().clearFocus()

        action = LineEditAction("Users Name", menu)
        action.line().setText(self._displayUsersDefined)
        action.line().contextMenuEvent = partial(_userContextMenu, users,
                                                 action)
        action.valueChanged.connect(self.setUsersFilterText)
        menu.addAction(action)

        return menu
示例#28
0
 def addLeftAction(self, text):
     action = QtWidgets.QAction(text, self._leftToolBar)
     self._leftToolBar.addAction(action)
     return action
示例#29
0
        """
        Create the item menu for given item.

        :rtype: QtWidgets.QMenu
        """
        item = items or self.selectedItem()

        menu = QtWidgets.QMenu(self)

        if item:
            try:
                item.contextMenu(menu)
            except Exception, msg:
                logger.exception(msg)
        else:
            action = QtWidgets.QAction(menu)
            action.setText("No Item selected")
            action.setDisabled(True)

            menu.addAction(action)

        return menu

    def createContextMenu(self):
        """
        Create and return the context menu for the widget.

        :rtype: QtWidgets.QMenu
        """
        menu = self.createItemsMenu()