def test_GIVEN_action_is_triggered_THEN_expected_trigger_method_is_called(
    icon_path, mouse_over_text, trigger_method_mock, tool_bar, tree_view_tab
):
    action = create_and_add_toolbar_action(
        icon_path, mouse_over_text, trigger_method_mock, tool_bar, tree_view_tab
    )
    action.trigger()
    trigger_method_mock.assert_called_once()
def edit_component_action(trigger_method_mock, tool_bar, tree_view_tab):
    return create_and_add_toolbar_action(
        "edit_component.png",
        "Edit Component",
        trigger_method_mock,
        tool_bar,
        tree_view_tab,
    )
def test_GIVEN_action_properties_WHEN_creating_enabled_action_THEN_action_has_expected_attributes(
        icon_path, mouse_over_text, trigger_method_mock, tool_bar,
        tree_view_tab):
    action = create_and_add_toolbar_action(icon_path, mouse_over_text,
                                           trigger_method_mock, tool_bar,
                                           tree_view_tab, True)

    assert action.toolTip() == mouse_over_text
    assert action.parent() is tree_view_tab
    assert not action.icon().isNull()
    assert action.isEnabled()
def create_link_action(trigger_method_mock, tool_bar, tree_view_tab):
    return create_and_add_toolbar_action("create_link.png", "Create Link",
                                         trigger_method_mock, tool_bar,
                                         tree_view_tab)
def new_rotation_action(trigger_method_mock, tool_bar, tree_view_tab):
    return create_and_add_toolbar_action("new_rotation.png", "New Rotation",
                                         trigger_method_mock, tool_bar,
                                         tree_view_tab)
def duplicate_action(trigger_method_mock, tool_bar, tree_view_tab):
    return create_and_add_toolbar_action("duplicate.png", "Duplicate",
                                         trigger_method_mock, tool_bar,
                                         tree_view_tab)
def zoom_action(trigger_method_mock, tool_bar, tree_view_tab):
    return create_and_add_toolbar_action("zoom.svg", "Zoom To Component",
                                         trigger_method_mock, tool_bar,
                                         tree_view_tab)
Пример #8
0
    def __init__(self, parent=None):
        super().__init__()
        self.setLayout(QVBoxLayout())
        self.setParent(parent)
        self.componentsTabLayout = QVBoxLayout()
        self.component_tree_view = QTreeView()
        self.componentsTabLayout.addWidget(self.component_tree_view)
        self.layout().addLayout(self.componentsTabLayout)

        self.component_tree_view.setDragEnabled(True)
        self.component_tree_view.setAcceptDrops(True)
        self.component_tree_view.setDropIndicatorShown(True)
        self.component_tree_view.header().hide()
        self.component_tree_view.updateEditorGeometries()
        self.component_tree_view.updateGeometries()
        self.component_tree_view.updateGeometry()
        self.component_tree_view.clicked.connect(self._set_button_state)
        self.component_tree_view.setSelectionMode(QAbstractItemView.SingleSelection)

        self.component_tool_bar = QToolBar("Actions", self)
        self.new_component_action = create_and_add_toolbar_action(
            "new_component.png",
            "New Component",
            self.parent().show_add_component_window,
            self.component_tool_bar,
            self,
            True,
        )
        self.new_translation_action = create_and_add_toolbar_action(
            "new_translation.png",
            "New Translation",
            lambda: self._add_transformation(TransformationType.TRANSLATION),
            self.component_tool_bar,
            self,
        )
        self.new_rotation_action = create_and_add_toolbar_action(
            "new_rotation.png",
            "New Rotation",
            lambda: self._add_transformation(TransformationType.ROTATION),
            self.component_tool_bar,
            self,
        )
        self.create_link_action = create_and_add_toolbar_action(
            "create_link.png",
            "Create Link",
            self.on_create_link,
            self.component_tool_bar,
            self,
        )
        self.duplicate_action = create_and_add_toolbar_action(
            "duplicate.png",
            "Duplicate",
            self.on_duplicate_node,
            self.component_tool_bar,
            self,
        )
        self.edit_component_action = create_and_add_toolbar_action(
            "edit_component.png",
            "Edit Component",
            self.parent().show_edit_component_dialog,
            self.component_tool_bar,
            self,
        )
        self.delete_action = create_and_add_toolbar_action(
            "delete.png", "Delete", self.on_delete_item, self.component_tool_bar, self
        )
        self.zoom_action = create_and_add_toolbar_action(
            "zoom.svg",
            "Zoom To Component",
            self.on_zoom_item,
            self.component_tool_bar,
            self,
        )
        self.component_tool_bar.insertSeparator(self.zoom_action)
        self.componentsTabLayout.insertWidget(0, self.component_tool_bar)
Пример #9
0
    def __init__(self, scene_widget: InstrumentView, parent=None):
        super().__init__()
        self.setLayout(QVBoxLayout())
        self.setParent(parent)
        self.componentsTabLayout = QVBoxLayout()
        self.component_tree_view = QNexusTreeView()
        self.parameters_widget = ParametersView(parent)
        self.componentsTabLayout.addWidget(self.parameters_widget)
        self.componentsTabLayout.addWidget(self.component_tree_view)

        self.layout().addLayout(self.componentsTabLayout)

        self.sceneWidget = scene_widget

        self.component_tree_view.setDragEnabled(True)
        self.component_tree_view.setAcceptDrops(True)
        self.component_tree_view.setDropIndicatorShown(True)
        self.component_tree_view.header().hide()
        self.component_tree_view.updateEditorGeometries()
        self.component_tree_view.updateGeometries()
        self.component_tree_view.updateGeometry()
        self.component_tree_view.clicked.connect(self._set_button_state)
        self.component_tree_view.setSelectionMode(
            QAbstractItemView.SingleSelection)

        self.component_tool_bar = QToolBar("Actions", self)
        self.new_component_action = create_and_add_toolbar_action(
            "new_component.png",
            "Group",
            self.parent().show_add_component_dialog,
            self.component_tool_bar,
            self,
            False,
        )
        self.new_translation_action = create_and_add_toolbar_action(
            "new_translation.png",
            "Translation",
            lambda: self._add_transformation(TransformationType.TRANSLATION),
            self.component_tool_bar,
            self,
        )
        self.new_rotation_action = create_and_add_toolbar_action(
            "new_rotation.png",
            "Rotation",
            lambda: self._add_transformation(TransformationType.ROTATION),
            self.component_tool_bar,
            self,
        )
        self.create_link_action = create_and_add_toolbar_action(
            "create_link.png",
            "Link",
            self.on_create_link,
            self.component_tool_bar,
            self,
        )
        self.edit_component_action = create_and_add_toolbar_action(
            "edit_component.png",
            "Edit",
            self.parent().show_edit_component_dialog,
            self.component_tool_bar,
            self,
        )
        self.zoom_action = create_and_add_toolbar_action(
            "zoom.svg",
            "Zoom",
            self.on_zoom_item,
            self.component_tool_bar,
            self,
        )
        self.component_tool_bar.insertSeparator(self.zoom_action)

        self.spacer = QWidget()
        self.spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.component_tool_bar.addWidget(self.spacer)
        self.delete_action = create_and_add_toolbar_action(
            "delete.png", "Delete", self.on_delete_item,
            self.component_tool_bar, self)
        self.component_tool_bar.insertSeparator(self.delete_action)
        self.componentsTabLayout.insertWidget(0, self.component_tool_bar)