+impuzzle (0.5-1maemo0) unstable; urgency=low
+
+ * Implemented: New initial view
+ * Implemented: About dialog
+
+ -- Timo Härkönen <timop.harkonen@gmail.com> Sat, 24 Apr 2010 20:44:00 +0200
+
impuzzle (0.4-2maemo0) unstable; urgency=low
* Fixes: Saving not enabled after game is restored
--- /dev/null
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "aboutdialog.h"
+#include "defines.h"
+
+#include <QTextEdit>
+#include <QVBoxLayout>
+
+AboutDialog::AboutDialog(QWidget *parent) :
+ QDialog(parent)
+{
+ setModal(true);
+
+ setWindowTitle(tr("About ImPuzzle"));
+
+ textEdit_ = new QTextEdit;
+
+ QString txt = "ImPuzzle - A set your pieces straight game<br />"
+ "Copyright (C) 2009 Timo Härkönen<br />"
+ "<br />"
+ "This program is free software: you can redistribute it and/or modify<br />"
+ "it under the terms of the GNU General Public License as published by<br />"
+ "the Free Software Foundation, either version 3 of the License, or<br />"
+ "(at your option) any later version.<br />"
+ "<br />"
+ "This program is distributed in the hope that it will be useful,<br />"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of<br />"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br />"
+ "<a href=\"http://www.gnu.org/licenses/gpl.txt\">GNU General Public License</a> for more details.<br />";
+
+ //textEdit_->setText(txt);
+ textEdit_->setHtml(txt);
+
+ mainLayout_ = new QVBoxLayout;
+ mainLayout_->addWidget(textEdit_);
+
+ setLayout(mainLayout_);
+}
--- /dev/null
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ABOUTDIALOG_H
+#define ABOUTDIALOG_H
+
+#include <QDialog>
+
+class QTextEdit;
+class QVBoxLayout;
+
+class AboutDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ AboutDialog(QWidget *parent = 0);
+
+private:
+ QTextEdit *textEdit_;
+ QVBoxLayout *mainLayout_;
+};
+#endif
#define RESTORE_FILE "impuzzle.dat"
#define HOME_DIRECTORY ".impuzzle"
+#define IMPUZZLE_VERSION "0.5"
+
#endif // DEFINES_H
GameView::GameView(QWidget *parent) :
QGraphicsView(parent)
{
+ setBackgroundBrush(Qt::black);
qsrand(QDateTime::currentDateTime().toTime_t());
scene_ = new QGraphicsScene;
hiddenIndex_ = -1;
setScene(scene_);
introItem_ = new IntroItem;
- introItem_->setText("Select new game from menu to play");
+ introItem_->setText("- ImPuzzle -");
verticalStep_ = 0;
horizontalStep_ = 0;
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "introitem.h"
#include "defines.h"
+#include "mainwindow.h"
#include <QPainter>
#include <QFontMetricsF>
Q_UNUSED(widget)
painter->save();
+ painter->setRenderHint(QPainter::Antialiasing, true);
+ painter->setPen(Qt::NoPen);
+
+ const int dots = 96;
+
+ int hstep = boundingRect().width() / dots;
+ int vstep = boundingRect().height() / dots;
+
+ QColor colors[3] = {QColor(255, 255, 255), QColor(0, 0, 0), QColor(127, 127, 127)};
+
+ for(int i = 0; i < dots; ++i) {
+ for(int j = 0; j < dots; ++j) {
+ painter->setBrush(QBrush(colors[qrand() % 2]));
+ painter->drawRect(QRect(QPoint(i * hstep, j * vstep),
+ QPoint((i+1) * hstep, (j+1) * vstep)));
+ }
+ }
painter->setBrush(Qt::NoBrush);
painter->setPen(Qt::black);
+ QFont font = painter->font();
+ font.setPointSize(72);
+ font.setBold(true);
+ painter->setFont(font);
+
// Get font metrics
QFontMetricsF fontMetricsF(painter->font());
QRectF textRectF = fontMetricsF.boundingRect(text_);
- int horizontalIntend = (IMAGE_WIDTH - textRectF.width()) / 2;
- int verticalIntend = (IMAGE_HEIGHT - textRectF.height()) / 2;
+ int horizontalIntend = (boundingRect().width() - textRectF.width()) / 2 - 10;
+ int verticalIntend = (boundingRect().height() - textRectF.height()) / 2 - 10;
+
+ // Draw rect behind the text
+ painter->setBrush(QBrush(QColor(0,0,0,192)));
+ painter->setPen(Qt::NoPen);
+ painter->drawRect(boundingRect()
+ .adjusted(0, verticalIntend, 5, -verticalIntend));
+ painter->setPen(Qt::black);
+ painter->setBrush(Qt::NoBrush);
// Draw text aligned to the center of boundingRect
+ QPen pen = painter->pen();
+ pen.setCosmetic(true);
+ pen.setColor(QColor(255,20,0,192));
+
+ painter->setPen(pen);
painter->drawText(boundingRect()
.adjusted(horizontalIntend, verticalIntend,-horizontalIntend, -verticalIntend),
text_);
+ pen.setColor(QColor(Qt::white));
+ painter->setPen(pen);
+ font.setPointSize(12);
+ painter->setFont(font);
+
+ QString txt = QString("Version %1").arg(IMPUZZLE_VERSION);
+
+ QFontMetricsF fm(painter->font());
+ QRectF trect = fm.boundingRect(txt);
+
+ QTextOption textOption;
+ textOption.setAlignment(Qt::AlignRight);
+
+ painter->drawText(boundingRect().adjusted(0, verticalIntend * 2 - trect.height(), -trect.width(), 0),
+ txt, textOption);
+
painter->restore();
}
update();
}
}
+
+void IntroItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_UNUSED(event);
+
+ MainWindow::instance()->newGameClicked();
+}
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef INTROITEM_H
#define INTROITEM_H
QString text() const;
void setText(const QString &txt);
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+
private:
QString text_;
};
{
QApplication app(argc, argv);
- MainWindow mw;
- mw.show();
+ MainWindow::instance()->show();
return app.exec();
}
#include "gameview.h"
#include "settings.h"
#include "settingsdialog.h"
+#include "aboutdialog.h"
#include "puzzleitem.h"
#include <QAction>
#include "imageimporter.h"
+MainWindow *MainWindow::instance_ = 0;
+
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
connect(GameView::instance(), SIGNAL(gameRestored()), this, SLOT(enableSaving()));
}
+MainWindow *MainWindow::instance()
+{
+ if(!instance_) {
+ instance_ = new MainWindow;
+ }
+
+ return instance_;
+}
+
void MainWindow::createMenu()
{
menu_ = menuBar()->addMenu("");
menu_->addAction(newGameAction_);
menu_->addAction(saveAction_);
+ menu_->addAction(aboutAction_);
menu_->addAction(importAction_);
}
connect(importAction_, SIGNAL(triggered()), this, SLOT(importClicked()));
importAction_->setDisabled(true);
- settingsAction_ = new QAction(tr("Settings"), this);
- connect(settingsAction_, SIGNAL(triggered()), this, SLOT(settingsClicked()));
+ aboutAction_ = new QAction(tr("About ImPuzzle"), this);
+ connect(aboutAction_, SIGNAL(triggered()), this, SLOT(aboutClicked()));
saveAction_ = new QAction(tr("Save and quit"), this);
connect(saveAction_, SIGNAL(triggered()), GameView::instance(), SLOT(saveGame()));
enableSaving();
}
-void MainWindow::settingsClicked()
+void MainWindow::aboutClicked()
{
-
+ AboutDialog *dialog = new AboutDialog(this);
+ dialog->exec();
+ dialog->deleteLater();
}
void MainWindow::gameEnded()
Q_OBJECT
public:
- MainWindow(QWidget *parent = 0);
+ static MainWindow *instance();
-private slots:
+public slots:
void newGameClicked();
+
+private slots:
void importClicked();
- void settingsClicked();
+ void aboutClicked();
void gameEnded();
void enableSaving();
private:
+ MainWindow(QWidget *parent = 0);
void createActions();
void createMenu();
+ static MainWindow *instance_;
QAction *newGameAction_;
QAction *importAction_;
- QAction *settingsAction_;
+ QAction *aboutAction_;
QAction *saveAction_;
QMenu *menu_;
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "settings.h"
#include "defines.h"
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef SETTINGS_H
#define SETTINGS_H
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include "settingsdialog.h"
#include "settings.h"
#include "defines.h"
+/*
+ Image Puzzle - A set your pieces straight game
+ Copyright (C) 2009 Timo Härkönen
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
defines.h \
introitem.h \
settings.h \
- settingsdialog.h
+ settingsdialog.h \
+ aboutdialog.h
SOURCES += gameview.cpp \
main.cpp \
puzzleitem.cpp \
introitem.cpp \
settings.cpp \
- settingsdialog.cpp
+ settingsdialog.cpp \
+ aboutdialog.cpp
RESOURCES += resources.qrc