-
Notifications
You must be signed in to change notification settings - Fork 1
/
newgamedialog.cpp
57 lines (47 loc) · 1.53 KB
/
newgamedialog.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
#include "newgamedialog.h"
NewGameDialog::NewGameDialog(QWidget *parent) :
QDialog(parent)
{
QStringList list;
list << "9" << "13" << "19";
m_width = new QComboBox(this);
m_height = new QComboBox(this);
m_width->addItems(list);
m_height->addItems(list);
m_width->setEditable(true);
m_height->setEditable(true);
m_width->lineEdit()->setValidator(new QIntValidator(1, 52, m_width->lineEdit()));
m_height->lineEdit()->setValidator(m_width->validator());
m_rules = new QComboBox(this);
m_rules->addItem(tr("Japanese rules"), int(SgfGame::JapaneseRules));
m_rules->addItem(tr("Chinese rules"), int(SgfGame::ChineseRules));
m_bbox = new QDialogButtonBox(Qt::Horizontal, this);
connect(m_bbox->addButton(QDialogButtonBox::Ok),
SIGNAL(clicked()),
this,
SLOT(accept()));
connect(m_bbox->addButton(QDialogButtonBox::Cancel),
SIGNAL(clicked()),
this,
SLOT(reject()));
QFrame *frame = new QFrame(this);
QGridLayout *fla = new QGridLayout(frame);
fla->addWidget(new QLabel(tr("Width"), this), 0, 0);
fla->addWidget(new QLabel(tr("Height"), this), 0, 1);
fla->addWidget(m_width, 1, 0);
fla->addWidget(m_height, 1, 1);
fla->addWidget(m_rules, 2, 0, 1, 2);
frame->setLayout(fla);
QVBoxLayout *la = new QVBoxLayout(this);
la->addWidget(frame);
la->addWidget(m_bbox);
}
QSize NewGameDialog::boardSize()
{
return QSize(m_width->currentText().toInt(),
m_height->currentText().toInt());
}
SgfGame::Rules NewGameDialog::rules()
{
return SgfGame::Rules(m_rules->itemData(m_rules->currentIndex(), Qt::UserRole).toInt());
}