Esempio n. 1
0
    def __init__(self):
        super(ShortcutSection, self).__init__()
        container = QVBoxLayout(self)
        self.tree = QTreeWidget()
        self.tree.setHeaderLabels([self.tr("Keys"), self.tr("Description")])
        self.tree.header().setStretchLastSection(True)
        self.tree.setColumnWidth(0, 200)
        container.addWidget(self.tree)

        self.items = {
            "new": "Create a new editor to work in a file",
            "new-project": "Create a new project",
            "open": "Open one or more files",
            "open-project": "Opens an existing project Edis",
            "reload": "Reload file",
            "save": "Save file"
            }

        for i, e in list(self.items.items()):
            item = QTreeWidgetItem(self.tree,
                                   [keymap.get_keymap(i).toString(), e])
            item.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled)

        self.tree.itemDoubleClicked.connect(self._change_shortcut)
        # Install
        EnvironmentConfiguration.install_widget(self.tr("Shortcuts"), self)
Esempio n. 2
0
    def __init__(self):
        super(ShortcutSection, self).__init__()
        container = QVBoxLayout(self)
        self.tree = QTreeWidget()
        self.tree.setHeaderLabels([self.tr("Keys"), self.tr("Description")])
        self.tree.header().setStretchLastSection(True)
        self.tree.setColumnWidth(0, 200)
        container.addWidget(self.tree)

        self.items = {
            "new": "Create a new editor to work in a file",
            "new-project": "Create a new project",
            "open": "Open one or more files",
            "open-project": "Opens an existing project Edis",
            "reload": "Reload file",
            "save": "Save file"
        }

        for i, e in list(self.items.items()):
            item = QTreeWidgetItem(self.tree,
                                   [keymap.get_keymap(i).toString(), e])
            item.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled)

        self.tree.itemDoubleClicked.connect(self._change_shortcut)
        # Install
        EnvironmentConfiguration.install_widget(self.tr("Shortcuts"), self)
Esempio n. 3
0
    def setup_menu(self, menu_bar):
        """ Instala la barra de menú (QMenuBar), acciones, shortcuts, toolbars
        y conexiones de cada QAction.
        """

        from src.ui import actions

        menubar_items = [
            self.tr("&Archivo"),
            self.tr("&Editar"),
            self.tr("&Ver"),
            self.tr("&Buscar"),
            self.tr("Có&digo"),
            self.tr("&Construcción"),
            self.tr("A&yuda")
            ]
        menu_items = {}
        toolbar_actions = {}
        editor_container = Edis.get_component("principal")
        #shortcuts = keymap.KEYMAP
        #keymap = keymap.get_keymap
        toolbar_items = TOOLBAR_ITEMS
        for i, m in enumerate(menubar_items):
            menu = menu_bar.addMenu(m)
            menu_items[i] = menu
        for i, _actions in enumerate(actions.ACTIONS):
            for action in _actions:
                obj = editor_container
                menu_name = menu_items[i]
                name = action.get('name', None)
                connection = action.get('connection', None)
                shortcut = action.get('shortcut', None)
                icon_action = action.get('icon', None)
                if icon_action is not None:
                    icon = QIcon(":image/%s" % icon_action)
                else:
                    # FIXME: No depender de shortcut
                    icon = QIcon(":image/%s" % shortcut)
                separator = action.get('separator', False)
                subm = action.get('menu', False)
                if subm:
                    # Archivos recientes
                    submenu = menu_name.addMenu(name)
                    Edis.load_component("menu_recent_file", submenu)
                    continue
                qaction = menu_name.addAction(name)
                qaction.setIcon(icon)
                if shortcut is not None:
                    #qaction.setShortcut(shortcuts[shortcut])
                    qaction.setShortcut(keymap.get_keymap(shortcut))
                if connection.startswith('edis'):
                    obj = self
                    connection = connection.split('.')[-1]
                slot = getattr(obj, connection, None)
                if hasattr(slot, "__call__"):
                    self.connect(qaction, SIGNAL("triggered()"), slot)
                if separator:
                    menu_name.addSeparator()
                if shortcut in toolbar_items:
                    toolbar_actions[shortcut] = qaction
        # Load toolbar
        for item in toolbar_items:
            action = toolbar_actions.get(item, None)
            if action is None:
                self.toolbar.addSeparator()
            else:
                self.toolbar.addAction(action)
Esempio n. 4
0
File: main.py Progetto: Garjy/edis
    def setup_menu(self, menu_bar):
        """ Instala la barra de menú (QMenuBar), acciones, shortcuts, toolbars
        y conexiones de cada QAction.
        """

        from src.ui import actions

        menubar_items = [
            self.tr("&Archivo"),
            self.tr("&Editar"),
            self.tr("&Ver"),
            self.tr("&Buscar"),
            self.tr("Có&digo"),
            self.tr("&Construcción"),
            self.tr("A&yuda"),
        ]
        menu_items = {}
        toolbar_actions = {}
        editor_container = Edis.get_component("principal")
        # shortcuts = keymap.KEYMAP
        # keymap = keymap.get_keymap
        toolbar_items = TOOLBAR_ITEMS
        for i, m in enumerate(menubar_items):
            menu = menu_bar.addMenu(m)
            menu_items[i] = menu
        for i, _actions in enumerate(actions.ACTIONS):
            for action in _actions:
                obj = editor_container
                menu_name = menu_items[i]
                name = action.get("name", None)
                connection = action.get("connection", None)
                shortcut = action.get("shortcut", None)
                icon_action = action.get("icon", None)
                if icon_action is not None:
                    icon = QIcon(":image/%s" % icon_action)
                else:
                    # FIXME: No depender de shortcut
                    icon = QIcon(":image/%s" % shortcut)
                separator = action.get("separator", False)
                subm = action.get("menu", False)
                if subm:
                    # Archivos recientes
                    submenu = menu_name.addMenu(name)
                    Edis.load_component("menu_recent_file", submenu)
                    continue
                qaction = menu_name.addAction(name)
                qaction.setIcon(icon)
                if shortcut is not None:
                    # qaction.setShortcut(shortcuts[shortcut])
                    qaction.setShortcut(keymap.get_keymap(shortcut))
                if connection.startswith("edis"):
                    obj = self
                    connection = connection.split(".")[-1]
                slot = getattr(obj, connection, None)
                if hasattr(slot, "__call__"):
                    self.connect(qaction, SIGNAL("triggered()"), slot)
                if separator:
                    menu_name.addSeparator()
                if shortcut in toolbar_items:
                    toolbar_actions[shortcut] = qaction
        # Load toolbar
        for item in toolbar_items:
            action = toolbar_actions.get(item, None)
            if action is None:
                self.toolbar.addSeparator()
            else:
                self.toolbar.addAction(action)