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"));
30 new FullScreenExitButton(this);
33 field = new Field(this, &turns);
34 colorButtons = new ColorButtons(this);
36 QObject::connect(colorButtons,
41 turnsLabel = new QLabel(this);
42 turnsLabel->setAlignment(Qt::AlignRight);
44 QObject::connect(field,
45 SIGNAL(turnsChanged(int)),
47 SLOT(updateTurns(int)));
51 QHBoxLayout *secondary = new QHBoxLayout;
52 QPushButton *toggleFS = new QPushButton(QPixmap("/usr/share/icons/hicolor/64x64/hildon/general_fullsize"), tr("Toggle fullscreen"), this);
53 QObject::connect(toggleFS, SIGNAL(pressed()), this, SLOT(toggleFullscreen()));
54 QPushButton *newGame = new QPushButton(tr("New game"), this);
55 QObject::connect(newGame, SIGNAL(pressed()), field, SLOT(randomize()));
57 secondary->addWidget(newGame);
58 secondary->addWidget(toggleFS);
60 QVBoxLayout *vl = new QVBoxLayout;
61 vl->addWidget(colorButtons);
62 vl->setAlignment(colorButtons, Qt::AlignRight | Qt::AlignTop);
63 vl->addWidget(turnsLabel);
64 vl->setAlignment(turnsLabel, Qt::AlignRight | Qt::AlignTop);
65 vl->addLayout(secondary);
66 vl->setAlignment(secondary, Qt::AlignRight | Qt::AlignBottom);
68 QHBoxLayout *hl = new QHBoxLayout;
70 hl->setAlignment(field, Qt::AlignLeft);
77 if (settings.value("fullscreen", true).toBool())
81 void Window::updateTurns (int turns)
83 /*: number of turns */
84 turnsLabel->setText(tr("<font size=\"16\">Turns: %1/%2</font>")
86 .arg(field->getNumTurnsOfSize(field->getSize())));
89 void Window::toggleFullscreen ()
91 bool isFullscreen = windowState() & Qt::WindowFullScreen;
94 settings.setValue("fullscreen", !isFullscreen);