X-Git-Url: http://git.maemo.org/git/?p=colorflood;a=blobdiff_plain;f=colorflood%2Fsrc%2Fwindow.cpp;h=7ade0a38fddd4c8accf75f031c117a81f135c7c8;hp=e0b64ea412c6e8249eba5b8cf84e30e5b78424ab;hb=c9371ba06d07bf654792588bd008af0efe940dc0;hpb=28227549a34ad895f59a94e4e0b65bbe72c48fbc diff --git a/colorflood/src/window.cpp b/colorflood/src/window.cpp index e0b64ea..7ade0a3 100644 --- a/colorflood/src/window.cpp +++ b/colorflood/src/window.cpp @@ -16,10 +16,12 @@ #include #include #include +#include #include "window.hpp" #include "colorbuttons.hpp" #include "field.hpp" #include "fullscreenexitbutton.hpp" +#include "colorscheme.hpp" Window::Window () : QWidget() @@ -64,26 +66,88 @@ Window::Window () setLayout(hl); - QSettings settings; + /* menu bar */ + QMenuBar *bar = new QMenuBar(this); - if (settings.value("fullscreen", true).toBool()) - showFullScreen(); + QObject::connect(bar->addAction(tr("Fullscreen mode")), + SIGNAL(triggered()), + this, + SLOT(fullScreenMode())); - new FullScreenExitButton(this); -} + QObject::connect(bar->addAction( + ColorScheme::getSchemeName( + ColorScheme::getNextColorScheme())), + SIGNAL(triggered()), + this, + SLOT(colorScheme())); -Window::~Window () -{ - bool isFullscreen = windowState() & Qt::WindowFullScreen; + less = bar->addAction(tr("Less cells")); + + QObject::connect(less, + SIGNAL(triggered()), + this, + SLOT(lessCells())); + + more = bar->addAction(tr("More cells")); - QSettings settings; - settings.setValue("fullscreen", isFullscreen); + QObject::connect(more, + SIGNAL(triggered()), + this, + SLOT(moreCells())); + + if (!field->getSize()) + less->setEnabled(false); + else if (field->getSize() == Field::NUM_SIZES - 1) + more->setEnabled(false); + + new FullScreenExitButton(this); + showFullScreen(); } void Window::updateTurns (int turns) { /*: number of turns */ - turnsLabel->setText(tr("Turns: %1/%2") + turnsLabel->setText(tr("Turns: %1/%2") .arg(turns) .arg(field->getNumTurnsOfSize(field->getSize()))); } + +void Window::fullScreenMode () +{ + showFullScreen(); +} + +void Window::lessCells () +{ + int s = field->getSize() - 1; + + field->setSize(s); + more->setEnabled(true); + + if (!s) + less->setEnabled(false); +} + +void Window::moreCells () +{ + int s = field->getSize() + 1; + + field->setSize(s); + less->setEnabled(true); + + if (s == Field::NUM_SIZES - 1) + more->setEnabled(false); +} + +void Window::colorScheme () +{ + QAction *action = static_cast(QObject::sender()); + + ColorScheme::setScheme(ColorScheme::getNextColorScheme()); + + field->update(); + colorButtons->update(); + + action->setText(ColorScheme::getSchemeName( + ColorScheme::getNextColorScheme())); +}