-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget.cpp
145 lines (117 loc) · 4.54 KB
/
widget.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "widget.h"
Widget::Widget(QWidget *parent) : QWidget(parent), _connectedBars(false)
{
resize(1400,900);
setMinimumWidth(1540);
setMinimumHeight(950);
setStyleSheet("Widget {background-color: brown;}");
setAutoFillBackground(true);
_mainLayout = new QHBoxLayout(this);
_leftLayout = new QVBoxLayout;
_middleLayout = new QVBoxLayout;
_rightLayout = new QVBoxLayout;
/* inicializace widgetů (prvky hry) */
_mainBoard = new MainBoard(this);
_bottomBar = new BottomBar(this);
_bottomBar->hide();
_toolBar = new ToolBar(this);
_toolBar->hide();
_menuButton = new QPushButton("Pass");
_menuButton->setStyleSheet( "QPushButton { border-image: url(:/images/pozadi/s30.png);\
border-radius: 10px;\
font-weight: bold;\
font-family: palatino;\
font-size: 40px;}\
QPushButton:pressed { border-image: url(:/images/pozadi/s80.png); }\
QPushButton:hover {border-image: url(:/images/pozadi/s50.png);}\
");
_menuButton->setToolTip("Pass the game and return to main menu.");
_menuButton->setFixedSize(280, 50);
_menuButton->hide();
_leftBar = new LeftBar;
_rightBar = new LeftBar;
/* naplnime levy layout <><> */
_leftLayout->addWidget(_leftBar);
_leftLayout->addStretch();
_leftLayout->addWidget(_menuButton);
/* naplnime prostredni layout <><> */
_middleLayout->addWidget(_toolBar);
_middleLayout->addWidget(_mainBoard);
_middleLayout->addWidget(_bottomBar);
/* naplnime pravy layout <><> */
_rightLayout->addStretch();
_rightLayout->addWidget(_rightBar);
/* layouty se vlozi do hlavniho layoutu */
_mainLayout->addLayout(_leftLayout);
_mainLayout->addLayout(_middleLayout);
_mainLayout->addLayout(_rightLayout);
setLayout(_mainLayout);
connect(_mainBoard, SIGNAL(showBarsPlz()), this, SLOT(showBars()));
connect(_mainBoard, SIGNAL(hideBarsPlz()), this, SLOT(hideBars()));
connect(this->_menuButton, SIGNAL(clicked(bool)), this->_mainBoard, SLOT(toMenu()));
connect(_mainBoard, SIGNAL(showMenuButton()), this, SLOT(showMenuButton()));
connect(_mainBoard, SIGNAL(hideMenuButton()), this, SLOT(hideMenuButton()));
connect(_mainBoard, SIGNAL(uncheckAllExcept(uint)), this->_toolBar, SLOT(uncheckAllExcept(uint)));
connect(_mainBoard, SIGNAL(exitGame()), this, SIGNAL(exitGame()));
}
Widget::~Widget()
{
}
void Widget::connectWidgets()
{
if(_connectedBars == false)
{
/* propojeni BottomBaru se sloty */
connect(_bottomBar->_beginButton, SIGNAL(clicked(bool)), _mainBoard->_activeBoard, SLOT(toStart()));
connect(_bottomBar->_nextMoveButton, SIGNAL(clicked(bool)), _mainBoard->_activeBoard, SLOT(nextMove()));
connect(_bottomBar->_prevMoveButton, SIGNAL(clicked(bool)), _mainBoard->_activeBoard, SLOT(prevMove()));
connect(_bottomBar->_endButton, SIGNAL(clicked(bool)), _mainBoard->_activeBoard, SLOT(toEnd()));
/* propojeni ToolBaru se sloty */
connect(_toolBar->_numbersButton, SIGNAL(toggled(bool)), _mainBoard->_activeBoard, SLOT(setSequence(bool)));
connect(_toolBar->_triangleButton, SIGNAL(toggled(bool)), _mainBoard->_activeBoard, SLOT(setTriangle(bool)));
connect(_toolBar->_squareButton, SIGNAL(toggled(bool)), _mainBoard->_activeBoard, SLOT(setSquare(bool)));
connect(_toolBar->_blackButton, SIGNAL(toggled(bool)), _mainBoard->_activeBoard, SLOT(setBlackOnly(bool)));
connect(_toolBar->_whiteButton, SIGNAL(toggled(bool)), _mainBoard->_activeBoard, SLOT(setWhiteOnly(bool)));
connect(_toolBar->_eraseButton, SIGNAL(toggled(bool)), _mainBoard->_activeBoard, SLOT(setErase(bool)));
_connectedBars = true;
}
}
void Widget::showMenuButton()
{
_menuButton->show();
_leftBar->_scoreBoard->show();
_rightBar->_scoreBoard->show();
}
void Widget::hideMenuButton()
{
_menuButton->hide();
_leftBar->_scoreBoard->hide();
_rightBar->_scoreBoard->hide();
}
void Widget::showBars()
{
connectWidgets();
showBottomBar();
showToolBar();
}
void Widget::showBottomBar()
{
_bottomBar->show();
}
void Widget::showToolBar()
{
_toolBar->show();
}
void Widget::hideBars()
{
hideBottomBar();
hideToolBar();
}
void Widget::hideBottomBar()
{
_bottomBar->hide();
}
void Widget::hideToolBar()
{
_toolBar->hide();
}