-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
85 lines (63 loc) · 2.21 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "mainwindow.h"
#include <QDebug>
#include "piece.h"
#include "pawnpromotiondialog.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUI();
}
MainWindow::~MainWindow()
{
}
void MainWindow::setupUI() {
setWindowTitle("QChess");
this->setFixedSize(w, h+28);
messageLabel = new QLabel(this);
messageLabel->setGeometry(5, h+4, 400, 20);
centralWidget = new QWidget(this);
centralWidget->setGeometry(0, 0, w, h+20);
castlingLeftBtn = new QPushButton(this);
castlingLeftBtn->setText("◀ Рокировка");
castlingLeftBtn->setEnabled(false);
castlingLeftBtn->setGeometry(w - 2*castlingLeftBtn->width()-10, h + 2, castlingLeftBtn->width(), castlingLeftBtn->height()-5);
connect(castlingLeftBtn, SIGNAL(clicked(bool)), this, SLOT(leftCastling()));
castlingRightBtn = new QPushButton(this);
castlingRightBtn->setText("Рокировка ▶");
castlingRightBtn->setEnabled(false);
castlingRightBtn->setGeometry(w - castlingRightBtn->width() - 5, h + 2, castlingRightBtn->width(), castlingRightBtn->height()-5);
connect(castlingRightBtn, SIGNAL(clicked(bool)), this, SLOT(rightCastling()));
board = new Chessboard(this);
board->setSceneRect(0, 0, w, h);
view = new QGraphicsView(centralWidget);
view->setGeometry(0, 0, w, h);
view->setScene(board);
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->viewport()->setAcceptDrops(true);
drawBtn = new QPushButton(this);
drawBtn->setText("Ничья");
drawBtn->setGeometry(w - 3*castlingRightBtn->width() - 15 , h + 2, castlingRightBtn->width(), castlingRightBtn->height());
connect(drawBtn, SIGNAL(clicked(bool)), this, SLOT(draw()));
}
void MainWindow::draw() {
board->stopGame("Ничья.");
}
void MainWindow::leftCastling() {
board->leftCastling();
}
void MainWindow::rightCastling() {
board->rightCastling();
}
void MainWindow::pawnToRook() {
board->pawnToRook();
}
void MainWindow::pawnToKnight() {
board->pawnToKnight();
}
void MainWindow::pawnToBishop() {
board->pawnToBishop();
}
void MainWindow::pawnToQueen() {
board->pawnToQueen();
}