コード例 #1
0
ファイル: window.py プロジェクト: D3f0/prymatex
        def extendMainMenu(klass):
            menuExtensions = issubclass(klass, PrymatexComponent) and klass.contributeToMainMenu() or None
            if menuExtensions is not None:
                objects = []
                for name, settings in menuExtensions.items():
                    if not settings:
                        continue
    
                    # Find parent menu
                    parentMenu = self.findChild(QtGui.QMenu, 
                        text_to_objectname(name, prefix = "menu"))
                    # Extend
                    if parentMenu is not None:
                        # Fix menu extensions
                        if not isinstance(settings, list):
                            settings = [ settings ]
                        objects += extend_menu(parentMenu, settings,
                            dispatcher = self.componentInstanceDispatcher,
                            sequence_handler = self.application.registerShortcut,
                            icon_resolver = resources.get_icon)
                    else:
                        objs = create_menu(self, settings,
                            dispatcher = self.componentInstanceDispatcher,
                            allObjects = True,
                            sequence_handler = self.application.registerShortcut,
                            icon_resolver = resources.get_icon)
                        add_actions(self.menuBar(), [ objs[0] ], settings.get("before", None))
                        objects += objs

                # Store all new objects from creation or extension
                self.customComponentObjects.setdefault(klass, []).extend(objects)

                for componentClass in self.application.pluginManager.findComponentsForClass(klass):
                    extendMainMenu(componentClass)
コード例 #2
0
ファイル: actions.py プロジェクト: D3f0/prymatex
 def globalEditAction(text):
     objectName = text_to_objectname(text)
     iconName = text_to_iconname(text, prefix = "icon")
     return {
         "text": text,
         "sequence": resources.get_sequence("Global", objectName),
         "icon": resources.get_icon(iconName),
         "triggered": cls.globalCallback,
         "data": objectName
     }
コード例 #3
0
ファイル: toolbar.py プロジェクト: prymatex/prymatex
 def __init__(self, name, area, parent):
     QtWidgets.QToolBar.__init__(self, parent)
     assert isinstance(parent, QtWidgets.QMainWindow)
     assert area in self.DOCK_AREA_TO_TB
     self._area = area
     self.setObjectName(text_to_objectname(name, prefix="ToolBar"))
     self.setWindowTitle(name)
     
     #Button Style
     #self.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
     
     self.setFloatable(False)
     self.setMovable(False)
     self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.MinimumExpanding))
     self.setIconSize(QtCore.QSize(16,16));
     
     #Restore action
     self.restoreAction = QtWidgets.QAction(self)
     self.restoreAction.setIcon(self.parent().resources().get_icon("TitleBarUnshadeButton"))
     self.restoreAction.triggered.connect(self.hide)
     self.addAction(self.restoreAction)
コード例 #4
0
ファイル: menubar.py プロジェクト: prymatex/prymatex
    def extend(self, klass, parent=None):
        # Build handlers
        dispatcher = partial(self.componentInstanceDispatcher, klass)
        sequence_handler = partial(self.registerShortcut, klass)
        icon_handler = partial(self.registerIcon, klass)
        
        menuExtensions = issubclass(klass, PrymatexComponent) and \
            klass.contributeToMainMenu() or {}
        for name, settings in menuExtensions.items():
            # Find parent menu
            menu = self.parent().findChild(QtWidgets.QMenu, 
                text_to_objectname(name, prefix="menu"))

            # Extend menu or create new one
            if menu is None:
                menu, objects = create_menu(parent, settings,
                    dispatcher = dispatcher,
                    sequence_handler = sequence_handler,
                    icon_handler = icon_handler)
                add_actions(self, [ menu ], settings.get("before", None), prefix="actionMenu")
            else:
                objects = extend_menu(menu,
                    isinstance(settings, (list, tuple)) and settings or [settings],
                    dispatcher = dispatcher,
                    sequence_handler = sequence_handler,
                    icon_handler = icon_handler)
            
            menu.aboutToShow.connect(
                lambda klass=klass, objects=objects: self.on_menu_aboutToShow(klass, objects)
            )

        # Store all actions for component
        # self.componentActions.setdefault(klass, []).extend(actions + [m.menuAction() for m in menus])
        
        for componentClass in self.parent().application().findComponentsForClass(klass):
            self.extend(componentClass, parent)
コード例 #5
0
ファイル: actions.py プロジェクト: prymatex/prymatex
 def globalEditAction(text):
     return {
         "text": text,
         "triggered": cls.globalCallback,
         "data": text_to_objectname(text)
     }