Ejemplo n.º 1
0
 def test_add_actions_with_qtoolbar_target(self):
     test_act_1 = create_action(None, "Test Action 1")
     test_act_2 = create_action(None, "Test Action 2")
     test_toolbar = QToolBar()
     # There seems to be no easy access to check the size of the list
     # so check the number of children increases by 2
     nchildren_before = len(test_toolbar.children())
     add_actions(test_toolbar, [test_act_1, test_act_2])
     self.assertEquals(nchildren_before + 2, len(test_toolbar.children()))
Ejemplo n.º 2
0
 def test_add_actions_with_qtoolbar_target(self):
     test_act_1 = create_action(None, "Test Action 1")
     test_act_2 = create_action(None, "Test Action 2")
     test_toolbar = QToolBar()
     # There seems to be no easy access to check the size of the list
     # so check the number of children increases by 2
     nchildren_before = len(test_toolbar.children())
     add_actions(test_toolbar, [test_act_1, test_act_2])
     self.assertEquals(nchildren_before + 2, len(test_toolbar.children()))
Ejemplo n.º 3
0
    def populate_layout_menu(self):
        self.view_menu_layouts.clear()
        try:
            layout_dict = CONF.get("MainWindow/user_layouts")
        except KeyError:
            layout_dict = {}
        layout_keys = sorted(layout_dict.keys())
        layout_options = []
        for item in layout_keys:
            layout_options.append(self.create_load_layout_action(item, layout_dict[item]))
        layout_options.append(None)
        action_settings = create_action(
            self, "Settings", on_triggered=self.open_settings_layout_window)
        layout_options.append(action_settings)

        add_actions(self.view_menu_layouts, layout_options)
Ejemplo n.º 4
0
 def test_add_actions_with_qmenu_target(self):
     test_act_1 = create_action(None, "Test Action 1")
     test_act_2 = create_action(None, "Test Action 2")
     test_menu = QMenu()
     add_actions(test_menu, [test_act_1, test_act_2])
     self.assertFalse(test_menu.isEmpty())
Ejemplo n.º 5
0
 def populate_menus(self):
     # Link to menus
     add_actions(self.file_menu, self.file_menu_actions)
     add_actions(self.view_menu, self.view_menu_actions)
     add_actions(self.help_menu, self.help_menu_actions)
     self.populate_interfaces_menu()
Ejemplo n.º 6
0
 def populate_menus(self):
     # Link to menus
     add_actions(self.file_menu, self.file_menu_actions)
     add_actions(self.view_menu, self.view_menu_actions)
Ejemplo n.º 7
0
 def register_plugin(self):
     self.main.add_dockwidget(self)
     # menus
     add_actions(self.main.editor_menu, self.editor_actions)
Ejemplo n.º 8
0
    def setup_options_actions(self, parent):
        """
        Setup the actions for the Options menu. The actions are handled by the parent widget
        """
        container_widget = QWidget(self)
        layout = QHBoxLayout(container_widget)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        container_widget.setLayout(layout)
        self.setCornerWidget(container_widget, Qt.TopRightCorner)

        run_button = QPushButton(container_widget)
        run_button.setObjectName(self.RUN_BUTTON_OBJECT_NAME)
        run_button.setIcon(get_icon("mdi.play", PLAY_BUTTON_GREEN_COLOR, 1.6))
        run_button.clicked.connect(parent.execute_current_async)
        layout.addWidget(run_button)

        abort_button = QPushButton(container_widget)
        abort_button.setObjectName(self.ABORT_BUTTON_OBJECT_NAME)
        abort_button.setIcon(
            get_icon("mdi.square", ABORT_BUTTON_RED_COLOR, 1.1))
        abort_button.clicked.connect(parent.abort_current)
        layout.addWidget(abort_button)

        options_button = QPushButton(container_widget)
        options_button.setObjectName(self.OPTIONS_BUTTON_OBJECT_NAME)
        options_button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        options_button.setText("Options")

        options_menu = QMenu("", self)
        options_button.setMenu(options_menu)
        layout.addWidget(options_button)

        self.tabCloseRequested.connect(parent.close_tab)

        run_action = create_action(self,
                                   "Run",
                                   on_triggered=parent.execute_current_async,
                                   shortcut=("Ctrl+Enter", "Ctrl+Return"),
                                   shortcut_context=Qt.ApplicationShortcut,
                                   shortcut_visible_in_context_menu=True)

        run_all_action = create_action(self,
                                       "Run All",
                                       on_triggered=parent.execute_async,
                                       shortcut=("Ctrl+Shift+Enter",
                                                 "Ctrl+Shift+Return"),
                                       shortcut_context=Qt.ApplicationShortcut,
                                       shortcut_visible_in_context_menu=True)

        abort_action = create_action(self,
                                     "Abort",
                                     on_triggered=parent.abort_current,
                                     shortcut="Ctrl+D",
                                     shortcut_context=Qt.ApplicationShortcut,
                                     shortcut_visible_in_context_menu=True)

        # menu action to toggle the find/replace dialog
        toggle_find_replace = create_action(
            self,
            'Find/Replace...',
            on_triggered=parent.toggle_find_replace_dialog,
            shortcut='Ctrl+F',
            shortcut_visible_in_context_menu=True)

        toggle_comment_action = create_action(
            self,
            "Comment/Uncomment",
            on_triggered=parent.toggle_comment_current,
            shortcut="Ctrl+/",
            shortcut_context=Qt.ApplicationShortcut,
            shortcut_visible_in_context_menu=True)

        tabs_to_spaces_action = create_action(
            self,
            'Tabs to Spaces',
            on_triggered=parent.tabs_to_spaces_current,
            shortcut_visible_in_context_menu=True)

        spaces_to_tabs_action = create_action(
            self,
            'Spaces to Tabs',
            on_triggered=parent.spaces_to_tabs_current,
            shortcut_visible_in_context_menu=True)

        toggle_whitespace_action = create_action(
            self,
            'Toggle Whitespace Visible',
            on_triggered=parent.toggle_whitespace_visible_all,
            shortcut_visible_in_context_menu=True)

        # Store actions for adding to menu bar; None will add a separator
        editor_actions = [
            run_action, run_all_action, abort_action, None,
            toggle_find_replace, None, toggle_comment_action,
            toggle_whitespace_action, None, tabs_to_spaces_action,
            spaces_to_tabs_action
        ]

        add_actions(options_menu, editor_actions)
Ejemplo n.º 9
0
 def populate_menus(self):
     # Link to menus
     add_actions(self.file_menu, self.file_menu_actions)
     add_actions(self.view_menu, self.view_menu_actions)
Ejemplo n.º 10
0
 def test_add_actions_with_qmenu_target(self):
     test_act_1 = create_action(None, "Test Action 1")
     test_act_2 = create_action(None, "Test Action 2")
     test_menu = QMenu()
     add_actions(test_menu, [test_act_1, test_act_2])
     self.assertFalse(test_menu.isEmpty())
Ejemplo n.º 11
0
 def register_plugin(self):
     self.main.add_dockwidget(self)
     # menus
     add_actions(self.main.editor_menu, self.editor_actions)
Ejemplo n.º 12
0
 def populate_menus(self):
     # Link to menus
     add_actions(self.file_menu, self.file_menu_actions)
     add_actions(self.view_menu, self.view_menu_actions)
     add_actions(self.help_menu, self.help_menu_actions)
     self.populate_interfaces_menu()