2 Copyright 2010 Serge Ziryukin <ftrvxmtrx@gmail.com>
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.
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.
14 #include <QPushButton>
15 #include <QVBoxLayout>
16 #include <QHBoxLayout>
20 #include "colorbuttons.hpp"
22 #include "fullscreenexitbutton.hpp"
27 setWindowTitle("Color Flood");
28 setWindowIcon(QIcon(":/images/icon_48x48.png"));
31 field = new Field(this, &turns);
32 colorButtons = new ColorButtons(this);
34 QObject::connect(colorButtons,
39 turnsLabel = new QLabel(this);
40 turnsLabel->setAlignment(Qt::AlignRight);
42 QObject::connect(field,
43 SIGNAL(turnsChanged(int)),
45 SLOT(updateTurns(int)));
49 QPushButton *newGame = new QPushButton(tr("New game"), this);
50 QObject::connect(newGame, SIGNAL(pressed()), field, SLOT(randomize()));
52 QVBoxLayout *vl = new QVBoxLayout;
53 vl->addWidget(colorButtons);
54 vl->setAlignment(colorButtons, Qt::AlignRight | Qt::AlignTop);
55 vl->addWidget(turnsLabel);
56 vl->setAlignment(turnsLabel, Qt::AlignRight | Qt::AlignBottom);
57 vl->addWidget(newGame);
58 vl->setAlignment(newGame, Qt::AlignRight | Qt::AlignTop);
60 QHBoxLayout *hl = new QHBoxLayout;
62 hl->setAlignment(field, Qt::AlignLeft);
69 if (settings.value("fullscreen", true).toBool())
72 new FullScreenExitButton(this);
77 bool isFullscreen = windowState() & Qt::WindowFullScreen;
80 settings.setValue("fullscreen", isFullscreen);
83 void Window::updateTurns (int turns)
85 /*: number of turns */
86 turnsLabel->setText(tr("<font size=\"16\">Turns: %1/%2</font>")
88 .arg(field->getNumTurnsOfSize(field->getSize())));