Example #1
0
    def addAction(self, path, action, icon=QIcon(), shortcut=None):
        """Add new action to the menu.
        Returns created QAction object.
        ``action`` might be string text or QAction instance.
        """
        subPath = self._parentPath(path)
        parentAction = self.action(subPath)
        if parentAction is None:
            assert False, "Menu path not found: " + subPath

        if isinstance(action, str):
            action = QAction(icon, action, parentAction)
        else:
            action.setParent(parentAction)

        if shortcut is not None:
            action.setShortcut(shortcut)

        parentAction.menu().addAction(action)

        self._pathToAction[path] = action
        action.path = path

        action.changed.connect(self._onActionChanged)
        """ On Ubuntu 14.04 keyboard shortcuts doesn't work without this line
        http://stackoverflow.com/questions/23916623/
            qt5-doesnt-recognised-shortcuts-unless-actions-are-added-to-a-toolbar
        """
        core.mainWindow().addAction(action)
        self.actionInserted.emit(action)

        return action
Example #2
0
    def addAction(self, path, action, icon=QIcon(), shortcut=None):
        """Add new action to the menu.
        Returns created QAction object.
        ``action`` might be string text or QAction instance.
        """
        subPath = self._parentPath(path)
        parentAction = self.action(subPath)
        if parentAction is None:
            assert False, "Menu path not found: " + subPath

        if isinstance(action, str):
            action = QAction(icon, action, parentAction)
        else:
            action.setParent(parentAction)

        if shortcut is not None:
            action.setShortcut(shortcut)

        parentAction.menu().addAction(action)

        self._pathToAction[path] = action
        action.path = path

        action.changed.connect(self._onActionChanged)

        self.actionInserted.emit(action)

        return action
Example #3
0
    def addAction(self, path, action, icon=QIcon(), shortcut=None):
        """Add new action to the menu.
        Returns created QAction object.
        ``action`` might be string text or QAction instance.
        """
        subPath = self._parentPath(path)
        parentAction = self.action(subPath)
        if parentAction is None:
            assert False, "Menu path not found: " + subPath

        if isinstance(action, str):
            action = QAction(icon, action, parentAction)
        else:
            action.setParent(parentAction)

        if shortcut is not None:
            action.setShortcut(shortcut)

        parentAction.menu().addAction(action)

        self._pathToAction[path] = action
        action.path = path

        action.changed.connect(self._onActionChanged)

        """ On Ubuntu 14.04 keyboard shortcuts doesn't work without this line
        http://stackoverflow.com/questions/23916623/
            qt5-doesnt-recognised-shortcuts-unless-actions-are-added-to-a-toolbar
        """
        core.mainWindow().addAction(action)
        self.actionInserted.emit(action)

        return action
Example #4
0
    def addAction(self, path, action, icon=QIcon(), shortcut=None):
        """Add new action to the menu.
        Returns created QAction object.
        ``action`` might be string text or QAction instance.
        """
        subPath = self._parentPath(path)
        parentAction = self.action(subPath)
        if parentAction is None:
            assert False, "Menu path not found: " + subPath

        if isinstance(action, str):
            action = QAction(icon, action, parentAction)
        else:
            action.setParent(parentAction)

        if shortcut is not None:
            action.setShortcut(shortcut)

        parentAction.menu().addAction(action)

        self._pathToAction[path] = action
        action.path = path

        action.changed.connect(self._onActionChanged)

        self.actionInserted.emit(action)

        return action