#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
+#include <QSettings>
#include "window.hpp"
#include "colorbuttons.hpp"
#include "field.hpp"
-//#include "fullscreenexitbutton.hpp"
+#include "fullscreenexitbutton.hpp"
Window::Window ()
: QWidget()
setWindowTitle("Color Flood");
setWindowIcon(QIcon(":/images/icon_48x48.png"));
-#if defined(Q_WS_HILDON) || defined(Q_WS_MAEMO_5)
- setWindowState(windowState() | Qt::WindowFullScreen);
-#else
- setFixedSize(800, 480);
-#endif
-
- //new FullScreenExitButton(this);
-
int turns;
field = new Field(this, &turns);
colorButtons = new ColorButtons(this);
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::AlignRight | 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(field);
hl->addLayout(vl);
setLayout(hl);
+
+ QSettings settings;
+
+ if (settings.value("fullscreen", true).toBool())
+ showFullScreen();
+
+ new FullScreenExitButton(this);
+}
+
+Window::~Window ()
+{
+ bool isFullscreen = windowState() & Qt::WindowFullScreen;
+
+ QSettings settings;
+ settings.setValue("fullscreen", isFullscreen);
}
void Window::updateTurns (int turns)
{
/*: number of turns */
- turnsLabel->setText(tr("<font size=\"24\">Turns: %1/%2</font>")
+ turnsLabel->setText(tr("<font size=\"16\">Turns: %1/%2</font>")
.arg(turns)
.arg(field->getNumTurnsOfSize(field->getSize())));
}