Beispiel #1
0
def test_empty(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240, 'spargo_empty') as (
            actual,
            expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SpargoDisplay.load_pixmap('board-1.png',
                                      QSize(240, 240))).setPos(1, 0)

        expected_scene.render(expected)

        display = SpargoDisplay()
        display.resize(348, 264)

        render_display(display, actual)
    assert display.ui.move_text.text() == 'to move'
    assert display.ui.black_count.text() == '0'
    assert display.ui.red_count.text() == ''
    assert display.ui.white_count.text() == '0'
    black_icon = display.black_pixmap.toImage()
    assert display.ui.black_count_pixmap.pixmap().toImage() == black_icon
    assert display.ui.player_pixmap.pixmap().toImage() == black_icon
    white_icon = display.white_pixmap.toImage()
    assert display.ui.white_count_pixmap.pixmap().toImage() == white_icon
Beispiel #2
0
def test_empty(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'sandbox_empty') as (actual, expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SandboxDisplay.load_pixmap('board-1.png',
                                       QSize(240, 240))).setPos(1, 0)

        expected_scene.render(expected)

        display = SandboxDisplay()

        display.resize(348, 264)

        render_display(display, actual)
    for widget in (display.ui.move_black, display.ui.move_white,
                   display.ui.move_red, display.ui.remove,
                   display.ui.black_count_pixmap,
                   display.ui.white_count_pixmap, display.ui.red_count_pixmap,
                   display.ui.black_count, display.ui.white_count,
                   display.ui.red_count):
        assert widget.isVisibleTo(display)
    assert display.ui.move_black.isChecked()
    assert display.ui.red_count.text() == '0'
Beispiel #3
0
def test_coordinates(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 200,
                                       'spline_coordinates') as (actual,
                                                                 expected):
        expected_scene = QGraphicsScene(0, 0, 240, 200)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png',
                                      QSize(160, 160))).setPos(36, 0)

        for i in range(7):
            add_text(expected_scene, str(7 - i), 15 + i % 2 * 10, i * 17 + 27,
                     10)
            add_text(expected_scene, chr(65 + i), i * 17 + 64,
                     178 - i % 2 * 10, 10)

        expected_scene.render(expected)

        display = SplineDisplay()
        display.resize(348, 224)

        display.show_coordinates = True

        render_display(display, actual)
Beispiel #4
0
def test_hover_enter_red(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(
            240, 240, 'sandbox_hover_enter_red') as (actual, expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SandboxDisplay.load_pixmap('board-1.png',
                                       QSize(240, 240))).setPos(1, 0)
        red_ball = SandboxDisplay.load_pixmap('ball-r-shadow-1.png',
                                              QSize(60, 60))

        new_piece = expected_scene.addPixmap(red_ball)
        new_piece.setPos(115, 114)
        new_piece.setOpacity(0.5)
        expected_scene.render(expected)

        display = SandboxDisplay()
        display.selected_move_type = MoveType.RED
        height = 0
        row = 1
        column = 2
        piece_item = display.item_levels[height][row][column]

        display.resize(348, 264)
        display.grab()  # Force layout to recalculate.

        display.on_hover_enter(piece_item)

        render_display(display, actual)
Beispiel #5
0
def test_update(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240, 'spargo_update') as (
            actual,
            expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SpargoDisplay.load_pixmap('board-1.png',
                                      QSize(240, 240))).setPos(1, 0)
        black_ball = SpargoDisplay.load_pixmap('ball-b-shadow-1.png',
                                               QSize(60, 60))

        expected_scene.addPixmap(black_ball).setPos(63, 166)
        expected_scene.render(expected)

        display = SpargoDisplay()

        display.resize(348, 264)
        display.update_board(SpargoState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . . . . 3

1 . B . . 1
  A C E G
>W
"""))

        render_display(display, actual)
    assert display.ui.black_count.text() == '1'
    assert display.ui.white_count.text() == '0'
Beispiel #6
0
def test_hover_leave(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'spline_hover_leave') as (actual,
                                                                 expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png', QSize(240,
                                                           240))).setPos(1, 0)
        expected_scene.render(expected)

        display = SplineDisplay()
        height = 0
        row = 1
        column = 2
        piece_item = display.item_levels[height][row][column]

        display.resize(348, 264)
        display.grab()  # Force layout to recalculate.

        display.on_hover_enter(piece_item)
        display.on_hover_leave(piece_item)

        render_display(display, actual)
def draw_text(expected: QPainter, x: int, y: int, text: str):
    window = expected.window()
    scene = QGraphicsScene(0, 0, window.width(), window.height())
    text_item = scene.addSimpleText(text)
    font = expected.font()
    text_item.setFont(font)
    center_text_item(text_item, x, y)
    scene.render(expected)
def test_hover_enter_remove(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(
            240, 240, 'spook_hover_enter_remove') as (actual, expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SpookDisplay.load_pixmap('board-1.png', QSize(240,
                                                          240))).setPos(1, 0)
        white_ball = SpookDisplay.load_pixmap('ball-w-shadow-1.png',
                                              QSize(60, 60))
        red_ball = SpookDisplay.load_pixmap('ball-r-shadow-1.png',
                                            QSize(60, 60))
        black_ball = SpookDisplay.load_pixmap('ball-b-shadow-1.png',
                                              QSize(60, 60))

        black_piece = expected_scene.addPixmap(black_ball)
        black_piece.setPos(115, 114)
        black_piece.setOpacity(0.5)
        red_piece = expected_scene.addPixmap(red_ball)
        red_piece.setPos(63, 62)
        white_piece = expected_scene.addPixmap(white_ball)
        white_piece.setPos(115, 62)
        expected_scene.render(expected)

        display = SpookDisplay()
        display.update_board(
            SpookState('''\
  A C E G
7 . . . . 7

5 . R W . 5

3 . . B . 3

1 . . . . 1
  A C E G
>R(R,B)
'''))
        height = 0
        row = 1
        column = 2
        piece_item = display.item_levels[height][row][column]

        display.resize(348, 264)
        display.grab()  # Force layout to recalculate.

        display.on_hover_enter(piece_item)

        render_display(display, actual)
Beispiel #9
0
def test_double_update(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'spline_double_update') as (actual,
                                                                   expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png', QSize(240,
                                                           240))).setPos(1, 0)
        white_ball = SplineDisplay.load_pixmap('ball-w-shadow-1.png',
                                               QSize(60, 60))
        black_ball = SplineDisplay.load_pixmap('ball-b-shadow-1.png',
                                               QSize(60, 60))

        expected_scene.addPixmap(black_ball).setPos(11, 10)
        expected_scene.addPixmap(white_ball).setPos(63, 10)
        expected_scene.addPixmap(black_ball).setPos(115, 62)
        expected_scene.render(expected)

        display = SplineDisplay()
        trigger_resize(display, 300, 240)
        display.update_board(
            SplineState("""\
  A C E G
7 W B . . 7

5 . . . W 5

3 . . . . 3

1 . . . . 1
  A C E G
"""))
        display.update_board(
            SplineState("""\
  A C E G
7 B W . . 7

5 . . B . 5

3 . . . . 3

1 . . . . 1
  A C E G
"""))

        display.resize(348, 264)

        render_display(display, actual)
Beispiel #10
0
def test_second_level(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'spline_second_level') as (actual,
                                                                  expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png', QSize(240,
                                                           240))).setPos(1, 0)
        white_ball = SplineDisplay.load_pixmap('ball-w-shadow-1.png',
                                               QSize(60, 60))
        black_ball = SplineDisplay.load_pixmap('ball-b-shadow-1.png',
                                               QSize(60, 60))

        expected_scene.addPixmap(black_ball).setPos(11, 62)
        expected_scene.addPixmap(white_ball).setPos(63, 62)
        expected_scene.addPixmap(white_ball).setPos(11, 10)
        expected_scene.addPixmap(black_ball).setPos(63, 10)
        expected_scene.addPixmap(black_ball).setPos(37, 36)
        expected_scene.render(expected)

        display = SplineDisplay()
        display.update_board(
            SplineState("""\
  A C E G
7 W B . . 7

5 B W . . 5

3 . . . . 3

1 . . . . 1
  A C E G
   B D F
 6 B . . 6

 4 . . . 4

 2 . . . 2
   B D F
"""))

        display.resize(348, 264)

        render_display(display, actual)
Beispiel #11
0
def test_resize_narrow(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(120, 240,
                                       'spline_resize_narrow') as (actual,
                                                                   expected):
        expected_scene = QGraphicsScene(0, 0, 120, 240)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png',
                                      QSize(120, 123))).setPos(0, 59)

        expected_scene.render(expected)

        display = SplineDisplay()

        display.resize(204, 264)

        render_display(display, actual)
Beispiel #12
0
def test_hover_enter_leave(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(
            240, 240, 'sandbox_hover_enter_leave') as (actual, expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SandboxDisplay.load_pixmap('board-1.png',
                                       QSize(240, 240))).setPos(1, 0)
        white_ball = SandboxDisplay.load_pixmap('ball-w-shadow-1.png',
                                                QSize(60, 60))

        new_piece = expected_scene.addPixmap(white_ball)
        new_piece.setPos(115, 114)
        expected_scene.render(expected)

        display = SandboxDisplay()
        display.update_board(
            SandboxState('''\
  A C E G
7 . . . . 7

5 . . . . 5

3 . . W . 3

1 . . . . 1
  A C E G
'''))
        display.selected_move_type = MoveType.REMOVE
        height = 0
        row = 1
        column = 2
        piece_item = display.item_levels[height][row][column]

        display.resize(348, 264)
        display.grab()  # Force layout to recalculate.

        display.on_hover_enter(piece_item)
        display.on_hover_leave(piece_item)

        render_display(display, actual)
Beispiel #13
0
def test_empty(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'spline_empty') as (actual, expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png', QSize(240,
                                                           240))).setPos(1, 0)

        expected_scene.render(expected)

        display = SplineDisplay()

        display.resize(348, 264)

        render_display(display, actual)
    black_icon = SplineDisplay.load_pixmap('ball-b-shadow-1.png').toImage()
    assert display.ui.player_pixmap.pixmap().toImage() == black_icon
    assert display.ui.move_text.text() == 'to move'
Beispiel #14
0
def test_first_level(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'spline_first_level') as (actual,
                                                                 expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png', QSize(240,
                                                           240))).setPos(1, 0)
        white_ball = SplineDisplay.load_pixmap('ball-w-shadow-1.png',
                                               QSize(60, 60))
        black_ball = SplineDisplay.load_pixmap('ball-b-shadow-1.png',
                                               QSize(60, 60))

        expected_scene.addPixmap(white_ball).setPos(11, 10)
        expected_scene.addPixmap(black_ball).setPos(63, 10)
        expected_scene.addPixmap(black_ball).setPos(167, 62)
        expected_scene.render(expected)

        display = SplineDisplay()
        display.update_board(
            SplineState("""\
  A C E G
7 W B . . 7

5 . . . B 5

3 . . . . 3

1 . . . . 1
  A C E G
"""))

        display.resize(348, 264)

        render_display(display, actual)
    white_icon = SplineDisplay.load_pixmap('ball-w-shadow-1.png').toImage()
    assert display.ui.player_pixmap.pixmap().toImage() == white_icon
Beispiel #15
0
def test_red(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'sandbox_red') as (actual, expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SandboxDisplay.load_pixmap('board-1.png',
                                       QSize(240, 240))).setPos(1, 0)
        white_ball = SandboxDisplay.load_pixmap('ball-w-shadow-1.png',
                                                QSize(60, 60))
        black_ball = SandboxDisplay.load_pixmap('ball-b-shadow-1.png',
                                                QSize(60, 60))
        red_ball = SandboxDisplay.load_pixmap('ball-r-shadow-1.png',
                                              QSize(60, 60))

        expected_scene.addPixmap(white_ball).setPos(11, 10)
        expected_scene.addPixmap(red_ball).setPos(63, 10)
        expected_scene.addPixmap(black_ball).setPos(167, 62)
        expected_scene.render(expected)

        display = SandboxDisplay()
        display.update_board(
            SandboxState("""\
  A C E G
7 W R . . 7

5 . . . B 5

3 . . . . 3

1 . . . . 1
  A C E G
"""))

        display.resize(348, 264)

        render_display(display, actual)
    assert display.ui.player_pixmap.pixmap().isNull()
Beispiel #16
0
def test_hover_leave_existing(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(
            240, 240, 'spline_hover_leave_existing') as (actual, expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        expected_scene.addPixmap(
            SplineDisplay.load_pixmap('board-1.png', QSize(240,
                                                           240))).setPos(1, 0)
        black_ball = SplineDisplay.load_pixmap('ball-b-shadow-1.png',
                                               QSize(60, 60))

        expected_scene.addPixmap(black_ball).setPos(115, 114)
        expected_scene.render(expected)

        display = SplineDisplay()
        display.update_board(
            SplineState("""\
  A C E G
7 . . . . 7

5 . . . . 5

3 . . B . 3

1 . . . . 1
  A C E G
"""))
        height = 0
        row = 1
        column = 2
        piece_item = display.item_levels[height][row][column]

        display.resize(348, 264)
        display.grab()  # Force layout to recalculate.

        display.on_hover_leave(piece_item)

        render_display(display, actual)
def test_coordinates(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(360, 240,
                                       'margo_coordinates') as (actual,
                                                                expected):
        expected_scene = QGraphicsScene(0, 0, 360, 240)
        display = MargoDisplay(size=2)
        full_board = display.assemble_board()
        scaled_board = display.scale_pixmap(full_board, 185, 192)
        expected_scene.addPixmap(scaled_board).setPos(82, 0)
        add_text(expected_scene, '3', 57, 57, 12)
        add_text(expected_scene, '2', 68, 93, 12)
        add_text(expected_scene, '1', 57, 129, 12)
        add_text(expected_scene, 'A', 141, 214, 12)
        add_text(expected_scene, 'B', 177, 203, 12)
        add_text(expected_scene, 'C', 213, 214, 12)
        expected_scene.render(expected)

        display.resize(492, 264)

        display.show_coordinates = True

        render_display(display, actual)
def test_board_size_2(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'margo_board_size_2') as (actual,
                                                                 expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        full_board = MargoDisplay.load_pixmap('board-1.png')
        width = full_board.width()
        height = full_board.height()
        top_height = round(height * 0.28)
        left_width = round(width * 0.28)
        right_width = round(width * 0.279)
        bottom_height = round(height * 0.29)
        assembled_board = QPixmap(left_width + right_width,
                                  top_height + bottom_height)
        assembled_board.fill(Qt.transparent)
        assembled_painter = QPainter(assembled_board)
        # top left
        assembled_painter.drawPixmap(0, 0, left_width, top_height, full_board,
                                     0, 0, left_width, top_height)
        # top right
        assembled_painter.drawPixmap(left_width, 0, right_width, top_height,
                                     full_board, width - right_width, 0,
                                     right_width, top_height)
        # bottom left
        assembled_painter.drawPixmap(0, top_height, left_width, bottom_height,
                                     full_board, 0, height - bottom_height,
                                     left_width, bottom_height)
        # bottom right
        assembled_painter.drawPixmap(left_width, top_height, right_width,
                                     bottom_height, full_board,
                                     width - right_width,
                                     height - bottom_height, right_width,
                                     bottom_height)
        assembled_painter.end()
        scaled_board = assembled_board.scaled(232, 240, Qt.KeepAspectRatio,
                                              Qt.SmoothTransformation)
        board_item = expected_scene.addPixmap(scaled_board)
        board_item.setPos(4, 0)
        white_ball = MargoDisplay.load_pixmap('ball-w-shadow-1.png',
                                              QSize(103, 103))
        black_ball = MargoDisplay.load_pixmap('ball-b-shadow-1.png',
                                              QSize(103, 103))

        expected_scene.addPixmap(white_ball).setPos(23, 108)
        expected_scene.addPixmap(black_ball).setPos(113, 18)
        expected_scene.render(expected)

        display = MargoDisplay(size=2)

        trigger_resize(display, 292, 240)
        display.resize(348, 264)
        board_text = """\
  A C
3 . B 3

1 W . 1
  A C
>B
"""
        display.update_board(SpargoState(board_text, size=2))

        render_display(display, actual)
Beispiel #19
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        # Załadowanie layoutu [Modyfikować tylko w Designerze!]:
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Ustawienie kilku parametrów aplikacji
        self.setWindowTitle("Paint Application")
        self.setWindowIcon(QIcon("../Icons/main_icon.png"))
        self.ui.actionselect.setChecked(True)
        self.unsaved_changes = False

        # GraphicItemModel i listView
        self.gim = GraphicItemModel()
        self.ui.listView.setModel(self.gim)

        # Scena
        self.scene = QGraphicsScene()

        # Widok - utworzenie, połączenie z widokiem, dodanie do okienka aplikacji
        self.graphicsView = CustomQGraphicsView(self.scene,
                                                self.centralWidget(), self.gim)
        self.graphicsView.setObjectName(u"graphicsView")
        self.graphicsView.setMinimumSize(QSize(250, 250))
        self.ui.gridLayout.addWidget(self.graphicsView, 0, 0, 1, 1)

        # Dialogi:
        # PrePickerDialog - wyświetlanie dialogu przed wyborem koloru (dla brush lub pen)
        self.color_picker_decide = PrePickerDialog()
        # ColorDialog - wybór koloru, dialog wyświetlany po PrePickerDialog
        self.color_picker_dialog = QColorDialog()
        # UnsavedChangesDialog - wyświetalnie dialogu np. po "Quit" lub "New" gdy są niezapisane zmiany
        self.unsaved_changes_dialog = UnsavedChangesDialog()
        # AboutDialog - wyświetalnie dialogu z informacjami o aplikacji
        self.about_dialog = AboutDialog()
        # AboutDialog - wyświetalnie dialogu z informacjami o nawigacji
        self.navigation_dialog = NavigationDialog()

        # ItemsInputOutput - menadżer zapisu i odczytu plików zawierających figury
        self.reader_writer = ItemsInputOutput(self.scene)

        # Powiązanie sygnałów ze slotami
        self.ui.actionNew.triggered.connect(self.slot_menu_new)
        self.ui.actionExport.triggered.connect(self.slot_menu_export)
        self.ui.actionSave.triggered.connect(self.slot_menu_save)
        self.ui.actionOpen.triggered.connect(self.slot_menu_open)
        self.ui.actionQuit.triggered.connect(self.slot_menu_quit)
        self.ui.actionAbout.triggered.connect(self.slot_menu_about)
        self.ui.actionNavigation.triggered.connect(self.slot_menu_navigation)

        self.ui.actionselect.triggered.connect(self.slot_trigger_select)
        self.ui.actionrectangle.triggered.connect(self.slot_trigger_rectangle)
        self.ui.actiontriangle.triggered.connect(self.slot_trigger_triangle)
        self.ui.actionellipse.triggered.connect(self.slot_trigger_ellipse)
        self.ui.actionline.triggered.connect(self.slot_trigger_line)
        self.ui.actionpolygon.triggered.connect(self.slot_trigger_polygon)
        self.ui.actionpicker.triggered.connect(self.slot_trigger_picker)
        self.ui.actionWidth.triggered.connect(self.slot_trigger_line_width)

        self.ui.lineEdit.textEdited.connect(self.slot_text_edited)
        self.color_picker_dialog.colorSelected.connect(
            self.slot_color_selected)
        self.gim.renamed.connect(self.unsaved_changes_detected)
        self.graphicsView.changed.connect(self.unsaved_changes_detected)

    # Sloty dla sygnałów z akcji menu-bara

    def slot_menu_new(self):
        if self.unsaved_changes:
            if not self.unsaved_changes_dialog.exec_():
                return
        self.scene.clear()
        self.unsaved_changes = False
        self.gim.remove_all_rows()

    def slot_menu_export(self):
        image = QImage(100, 100, QImage.Format_RGB32)
        painter = QPainter(image)
        painter.setRenderHint(QPainter.Antialiasing)
        self.scene.render(painter)
        image.save("saved_image.png")

    def slot_menu_save(self):
        file_name: tuple = QFileDialog.getSaveFileName(
            self, "Choose file with shapes to save", "", "Data (*.txt)")
        self.reader_writer.save_items(file_name[0], self.gim)

    def slot_menu_open(self):
        file_name: tuple = QFileDialog.getOpenFileName(
            self, "Choose file with shapes to load", "", "Data (*.txt)")
        self.reader_writer.load_items(file_name[0], self.gim)

    def slot_menu_quit(self):
        if self.unsaved_changes:
            if not self.unsaved_changes_dialog.exec_():
                return
        QApplication.quit()

    def slot_menu_about(self):
        self.about_dialog.exec_()

    def slot_menu_navigation(self):
        self.navigation_dialog.exec_()

    # Sloty dla sygnałów z akcji tool-bara

    def slot_trigger_select(self):
        self.graphicsView.actual_selection = self.graphicsView.Selection.SELECT

    def slot_trigger_rectangle(self):
        self.graphicsView.actual_selection = self.graphicsView.Selection.RECTANGLE

    def slot_trigger_triangle(self):
        self.graphicsView.actual_selection = self.graphicsView.Selection.TRIANGLE

    def slot_trigger_ellipse(self):
        self.graphicsView.actual_selection = self.graphicsView.Selection.ELLIPSE

    def slot_trigger_line(self):
        self.graphicsView.actual_selection = self.graphicsView.Selection.LINE

    def slot_trigger_polygon(self):
        self.graphicsView.actual_selection = self.graphicsView.Selection.POLYGON

    def slot_trigger_picker(self):
        if self.color_picker_decide.exec_():
            self.color_picker_dialog.show()

    def slot_trigger_line_width(self):
        width = QInputDialog.getDouble(
            self, "Width selection",
            "Please pass decimal value from range 0.01 to 20.00 <br /> with maximally "
            "2 decimal places", self.graphicsView.actual_pen.width(), 0.01,
            20.00, 2, Qt.WindowFlags(), 1.0)
        if width[1]:
            self.graphicsView.actual_pen.setWidthF(width[0])

    # Sloty dla pozostałych sygnałów

    def slot_color_selected(self):
        if self.color_picker_decide.radioButton.isChecked():
            self.graphicsView.actual_pen.setColor(
                self.color_picker_dialog.selectedColor())
        else:
            self.graphicsView.actual_brush.setColor(
                self.color_picker_dialog.selectedColor())

    def slot_text_edited(self, text: str):
        data: list[GraphicItemModel.Item] = self.gim.return_shapes()
        if len(text) == 0:
            for i in range(0, len(data)):
                self.ui.listView.setRowHidden(i, False)
        else:
            for i in range(0, len(data)):
                if not data[i].name.lower().startswith(text.lower()):
                    self.ui.listView.setRowHidden(i, True)
                else:
                    self.ui.listView.setRowHidden(i, False)

    def unsaved_changes_detected(self):
        self.unsaved_changes = True
def test_board_size_3(pixmap_differ: PixmapDiffer):
    actual: QPainter
    expected: QPainter
    with pixmap_differ.create_painters(240, 240,
                                       'margo_board_size_3') as (actual,
                                                                 expected):
        expected_scene = QGraphicsScene(0, 0, 240, 240)
        full_board = MargoDisplay.load_pixmap('board-1.png')
        width = full_board.width()
        height = full_board.height()
        top_height = round(height * 0.28)
        mid_height = round(height * 0.21)
        bottom_height = round(height * 0.29)
        left_width = round(width * 0.28)
        mid_width = round(width * 0.22)
        right_width = round(width * 0.279)
        assembled_board = QPixmap(left_width + mid_width + right_width,
                                  top_height + mid_height + bottom_height)
        assembled_board.fill(Qt.transparent)
        assembled_painter = QPainter(assembled_board)
        # top left
        assembled_painter.drawPixmap(0, 0, left_width, top_height, full_board,
                                     0, 0, left_width, top_height)
        # top middle
        assembled_painter.drawPixmap(left_width, 0, mid_width, top_height,
                                     full_board, left_width, 0, mid_width,
                                     top_height)
        # top right
        assembled_painter.drawPixmap(left_width + mid_width, 0, right_width,
                                     top_height, full_board,
                                     width - right_width, 0, right_width,
                                     top_height)
        # left middle
        assembled_painter.drawPixmap(0, top_height, left_width, mid_height,
                                     full_board, 0, top_height, left_width,
                                     mid_height)
        # middle middle
        assembled_painter.drawPixmap(left_width, top_height, mid_width,
                                     mid_height, full_board, left_width,
                                     top_height, mid_width, mid_height)
        # right middle
        assembled_painter.drawPixmap(left_width + mid_width, top_height,
                                     right_width, mid_height, full_board,
                                     width - right_width, top_height,
                                     right_width, mid_height)
        # bottom left
        assembled_painter.drawPixmap(0, top_height + mid_height, left_width,
                                     bottom_height, full_board, 0,
                                     height - bottom_height, left_width,
                                     bottom_height)
        # bottom middle
        assembled_painter.drawPixmap(left_width, top_height + mid_height,
                                     mid_width, bottom_height, full_board,
                                     left_width, height - bottom_height,
                                     mid_width, bottom_height)
        # bottom right
        assembled_painter.drawPixmap(left_width + mid_width,
                                     top_height + mid_height, right_width,
                                     bottom_height, full_board,
                                     width - right_width,
                                     height - bottom_height, right_width,
                                     bottom_height)
        assembled_painter.end()
        scaled_board = assembled_board.scaled(240, 240, Qt.KeepAspectRatio,
                                              Qt.SmoothTransformation)
        board_item = expected_scene.addPixmap(scaled_board)
        board_item.setPos(2, 0)
        white_ball = MargoDisplay.load_pixmap('ball-w-shadow-1.png',
                                              QSize(76, 76))
        black_ball = MargoDisplay.load_pixmap('ball-b-shadow-1.png',
                                              QSize(76, 76))

        expected_scene.addPixmap(white_ball).setPos(15, 145)
        expected_scene.addPixmap(black_ball).setPos(81, 79)
        expected_scene.render(expected)

        display = MargoDisplay(size=3)
        display.resize(348, 264)

        board_text = """\
  A C E
5 . . . 5

3 . B . 3

1 W . . 1
  A C E
>B
"""
        display.update_board(SpargoState(board_text, size=3))

        render_display(display, actual)