GNU General Public License for more details.
*/
-#include <QtGui>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QLabel>
#include "window.hpp"
+#include "colorbuttons.hpp"
#include "field.hpp"
+//#include "fullscreenexitbutton.hpp"
Window::Window ()
: QWidget()
{
- setWindowTitle(tr("Color Flood"));
+ setWindowTitle("Color Flood");
+ setWindowIcon(QIcon(":/images/icon_48x48.png"));
- //setWindowState(windowState() | Qt::WindowFullScreen);
+#if defined(Q_WS_HILDON) || defined(Q_WS_MAEMO_5)
+ setWindowState(windowState() | Qt::WindowFullScreen);
+#else
+ setFixedSize(800, 480);
+#endif
- QPushButton *button = new QPushButton("randomize", this);
- field = new Field(this);
+ //new FullScreenExitButton(this);
- QObject::connect(button, SIGNAL(pressed()), this, SLOT(randomize()));
+ int turns;
+ field = new Field(this, &turns);
+ colorButtons = new ColorButtons(this);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(button);
- layout->setAlignment(button, Qt::AlignLeft);
- layout->addWidget(field);
- layout->setAlignment(field, Qt::AlignRight);
- setLayout(layout);
+ QObject::connect(colorButtons,
+ SIGNAL(flood(int)),
+ field,
+ SLOT(flood(int)));
+
+ turnsLabel = new QLabel(this);
+
+ QObject::connect(field,
+ SIGNAL(turnsChanged(int)),
+ this,
+ SLOT(updateTurns(int)));
+
+ updateTurns(turns);
+
+ QVBoxLayout *vl = new QVBoxLayout;
+ vl->addWidget(colorButtons);
+ vl->setAlignment(colorButtons, Qt::AlignRight | Qt::AlignTop);
+ vl->addWidget(turnsLabel);
+ vl->setAlignment(turnsLabel, Qt::AlignRight | Qt::AlignTop);
+
+ QHBoxLayout *hl = new QHBoxLayout;
+ hl->addWidget(field);
+ hl->setAlignment(field, Qt::AlignLeft);
+ hl->addLayout(vl);
+
+ setLayout(hl);
}
-void Window::randomize ()
+void Window::updateTurns (int turns)
{
- field->randomize();
+ /*: number of turns */
+ turnsLabel->setText(tr("Turns: %1/%2")
+ .arg(turns)
+ .arg(field->getNumTurnsOfSize(field->getSize())));
}