#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
+#include <QSettings>
#include "window.hpp"
#include "colorbuttons.hpp"
#include "field.hpp"
Window::Window ()
: QWidget()
{
- setWindowTitle(tr("Color Flood"));
-
- setWindowState(windowState() | Qt::WindowFullScreen);
-
- new FullScreenExitButton(this);
+ setWindowTitle("Color Flood");
+ setWindowIcon(QIcon(":/images/icon_48x48.png"));
int turns;
field = new Field(this, &turns);
SLOT(flood(int)));
turnsLabel = new QLabel(this);
+ turnsLabel->setAlignment(Qt::AlignRight);
QObject::connect(field,
SIGNAL(turnsChanged(int)),
updateTurns(turns);
+ QPushButton *newGame = new QPushButton(tr("New game"), this);
+ QObject::connect(newGame, SIGNAL(pressed()), field, SLOT(randomize()));
+
QVBoxLayout *vl = new QVBoxLayout;
+ vl->addWidget(colorButtons);
+ vl->setAlignment(colorButtons, Qt::AlignRight | Qt::AlignTop);
vl->addWidget(turnsLabel);
- vl->setAlignment(turnsLabel, Qt::AlignTop);
+ vl->setAlignment(turnsLabel, Qt::AlignRight | Qt::AlignBottom);
+ vl->addWidget(newGame);
+ vl->setAlignment(newGame, Qt::AlignRight | Qt::AlignTop);
QHBoxLayout *hl = new QHBoxLayout;
- hl->addWidget(colorButtons);
- hl->setAlignment(colorButtons, Qt::AlignLeft);
hl->addWidget(field);
- hl->setAlignment(field, Qt::AlignRight);
+ hl->setAlignment(field, Qt::AlignLeft);
+ hl->addLayout(vl);
+
+ setLayout(hl);
+
+ QSettings settings;
+
+ if (settings.value("fullscreen", true).toBool())
+ showFullScreen();
+
+ new FullScreenExitButton(this);
+}
+
+Window::~Window ()
+{
+ bool isFullscreen = windowState() & Qt::WindowFullScreen;
- vl->addLayout(hl);
- setLayout(vl);
+ QSettings settings;
+ settings.setValue("fullscreen", isFullscreen);
}
void Window::updateTurns (int turns)
{
- turnsLabel->setText(QString("%1/%2")
+ /*: number of turns */
+ turnsLabel->setText(tr("<font size=\"16\">Turns: %1/%2</font>")
.arg(turns)
.arg(field->getNumTurnsOfSize(field->getSize())));
}