-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwidget.cpp
62 lines (53 loc) · 1.32 KB
/
mainwidget.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
//#include "board.h"
#include "mainwidget.h"
#include <QComboBox>
#include <QDebug>
//#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QToolBar>
#include <QSpinBox>
#include <QVBoxLayout>
MainWidget::MainWidget(QWidget*) : board(NULL)
{
layout = new QVBoxLayout(this);
//cubeSettingsLayout = new QHBoxLayout;
QPushButton* newgame = new QPushButton(tr("&New game"));
QLabel* cubeLabel = new QLabel(tr("Board size: "));
QComboBox* opponent = new QComboBox;
status = new QLabel;
cubeSize = new QSpinBox;
cubeSize->setRange(6, 50);
cubeSize->setValue(15);
connect(newgame, SIGNAL(clicked()), this, SLOT(newGame()));
QToolBar* toolbar = new QToolBar(tr("Settings"));
toolbar->addWidget(cubeLabel);
toolbar->addWidget(cubeSize);
toolbar->addSeparator();
toolbar->addWidget(opponent);
//cubeSettingsLayout->addWidget(cubeLabel);
//cubeSettingsLayout->addWidget(cubeSize);
layout->addWidget(newgame, 1);
layout->addWidget(toolbar);
layout->addWidget(status);
newGame();
setLayout(layout);
//setFixedSize(sizeHint());
}
void MainWidget::newGame()
{
if(board)
{
layout->removeWidget(board);
delete board;
}
board = new Board(cubeSize->value(), this);
board->hide();
board->show();
layout->addWidget(board);
resize(sizeHint());
}
void MainWidget::setStatus(QString str)
{
status->setText(str);
}