fix build
[colorflood] / colorflood / src / window.cpp
1 /*
2   Copyright 2010 Serge Ziryukin <ftrvxmtrx@gmail.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation; version 2 of the License.
7
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   GNU General Public License for more details.
12 */
13
14 #include <QPushButton>
15 #include <QVBoxLayout>
16 #include <QHBoxLayout>
17 #include <QLabel>
18 #include "window.hpp"
19 #include "colorbuttons.hpp"
20 #include "field.hpp"
21 //#include "fullscreenexitbutton.hpp"
22
23 Window::Window ()
24     : QWidget()
25 {
26     setWindowTitle("Color Flood");
27
28     setWindowState(windowState() | Qt::WindowFullScreen);
29
30     //new FullScreenExitButton(this);
31
32     int turns;
33     field = new Field(this, &turns);
34     colorButtons = new ColorButtons(this);
35
36     QObject::connect(colorButtons,
37                      SIGNAL(flood(int)),
38                      field,
39                      SLOT(flood(int)));
40
41     turnsLabel = new QLabel(this);
42
43     QObject::connect(field,
44                      SIGNAL(turnsChanged(int)),
45                      this,
46                      SLOT(updateTurns(int)));
47
48     updateTurns(turns);
49
50     QVBoxLayout *vl = new QVBoxLayout;
51     vl->addWidget(turnsLabel);
52     vl->setAlignment(turnsLabel, Qt::AlignTop);
53
54     QHBoxLayout *hl = new QHBoxLayout;
55     hl->addWidget(colorButtons);
56     hl->setAlignment(colorButtons, Qt::AlignLeft);
57     hl->addWidget(field);
58     hl->setAlignment(field, Qt::AlignRight);
59
60     vl->addLayout(hl);
61     setLayout(vl);
62 }
63
64 void Window::updateTurns (int turns)
65 {
66     /*: number of turns */
67     turnsLabel->setText(tr("Turns: %1/%2")
68                         .arg(turns)
69                         .arg(field->getNumTurnsOfSize(field->getSize())));
70 }