-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoinrushstagewidget.cpp
More file actions
59 lines (44 loc) · 1.42 KB
/
coinrushstagewidget.cpp
File metadata and controls
59 lines (44 loc) · 1.42 KB
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
#include "coinrushstagewidget.h"
#include <QHBoxLayout>
#include <QLabel>
CoinRushStageWidget::CoinRushStageWidget(QWidget *parent) : QWidget(parent)
{
QHBoxLayout* mainLayout = new QHBoxLayout();
// World
worldSpinbox = new QSpinBox(this);
worldSpinbox->setRange(1, 256);
connect(worldSpinbox, SIGNAL(valueChanged(int)), this, SLOT(worldChanged(int)));
mainLayout->addWidget(worldSpinbox);
mainLayout->addWidget(new QLabel(" -"), Qt::AlignRight);
// Level
levelSpinbox = new QSpinBox(this);
levelSpinbox->setRange(1, 256);
connect(levelSpinbox, SIGNAL(valueChanged(int)), this, SLOT(levelChanged(int)));
mainLayout->addWidget(levelSpinbox);
this->setLayout(mainLayout);
}
void CoinRushStageWidget::loadStage(quint8 world, quint8 level)
{
this->world = world;
this->level = level;
blockAllSignals(true);
worldSpinbox->setValue(world + 1);
levelSpinbox->setValue(level + 1);
blockAllSignals(false);
}
void CoinRushStageWidget::blockAllSignals(bool block)
{
worldSpinbox->blockSignals(block);
levelSpinbox->blockSignals(block);
}
// SLOTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void CoinRushStageWidget::worldChanged(int value)
{
world = static_cast<quint8>(value - 1);
emit stageChanged(world, level);
}
void CoinRushStageWidget::levelChanged(int value)
{
level = static_cast<quint8>(value - 1);
emit stageChanged(world, level);
}