About box integrated to view/scene
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 25 Jul 2011 18:57:39 +0000 (21:57 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Mon, 25 Jul 2011 18:57:39 +0000 (21:57 +0300)
seascene.cpp
seascene.h

index d714baf..655a903 100644 (file)
@@ -42,6 +42,9 @@ const QString octopusImageFilename_= ":/pix/tursas.png";
 SeaScene::SeaScene(QObject *parent) :
     QGraphicsScene(parent)
 {
+
+    setItemPointersNull();
+
     paused_ = false;
     screenLitKeeper_.keepScreenLit(true);
 
@@ -98,8 +101,12 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
 
     clear();
 
+    setItemPointersNull();
+
     createMenuItems();
 
+    createAboutBoxItems();
+
     //empty the list of moving items
 
     movingItems_.clear();
@@ -386,7 +393,18 @@ void SeaScene::handleScreenTapped()
         return;
     }
 
-    //If the game is paused, chacl if menu item was selected
+    //If the game is paused and about box is shown, close it and show the pause text and menu again
+
+    if(pAboutBoxItem_)
+    {
+        if(pAboutBoxItem_->isVisible())
+        {
+            pAboutBoxItem_->hide();
+            pPausetextItem_->show();
+        }
+    }
+
+    //If the game is paused, check if menu item was selected
 
     QList<QGraphicsItem *> items = selectedItems();
 
@@ -546,16 +564,8 @@ void SeaScene::prepareForMenu(QGraphicsItem * pItem)
 
 void SeaScene::about()
 {
-    QMessageBox::about(NULL, tr("About %1").arg(QApplication::applicationName()),
-                       tr("Version %1"
-                          "<p>Copyright 2011 Heli Hyv&auml;ttinen"
-                          "<p>License: General Public License v2"
-                          "<p>Bug Reports: https://bugs.maemo.org/ "
-                          "enter_bug.cgi?product=Ghosts%20Overboard"
-                          ).arg(QApplication::applicationVersion()));
-
-
-
+    pPausetextItem_->hide();
+    pAboutBoxItem_->show();
 }
 
 
@@ -651,3 +661,34 @@ void::SeaScene::softContinue()
 
     pause(pPauseAction_->isChecked());
 }
+
+void SeaScene::createAboutBoxItems()
+{
+    pAboutBoxItem_ = new QGraphicsTextItem;
+    addItem(pAboutBoxItem_);
+    pAboutBoxItem_->setPos(25,50);
+    pAboutBoxItem_->setZValue(1000);
+    pAboutBoxItem_->hide();
+
+    pAboutBoxItem_->setHtml(tr("<font color = darkorange size = \"7\">"
+                          "%1 <br> <font size = \"5\"> Version %2"
+                          "<p><font size = \"4\"> Copyright 2011 Heli Hyv&auml;ttinen"
+                          "<p><font size = \"4\"> License: General Public License v2"
+                          "<p><font size = \"3\"> Bug Reports: <br> https://bugs.maemo.org/ "
+                          "enter_bug.cgi?product=Ghosts%20Overboard"
+                          ).arg(QApplication::applicationName(),QApplication::applicationVersion()));
+
+}
+
+void SeaScene::setItemPointersNull()
+{
+    pPausetextItem_ = NULL;
+    pRestartLevelItem_ = NULL;
+    pRestartGameItem_ = NULL;
+    pSettingsItem_ = NULL;
+    pAboutItem_ = NULL;
+    pQuitItem_ = NULL ;
+    pMinimizeItem_ = NULL;
+
+    pAboutBoxItem_ = NULL;
+}
index 4fbbd3d..256c614 100644 (file)
@@ -82,6 +82,10 @@ public slots:
 
     void softContinue();
 
+    void createAboutBoxItems();
+
+    void setItemPointersNull();
+
 
 
 protected:
@@ -122,6 +126,8 @@ protected:
     QGraphicsTextItem * pQuitItem_;
     QGraphicsTextItem * pMinimizeItem_;
 
+    QGraphicsTextItem * pAboutBoxItem_;
+
     QList<Level> levelList_;
 
     int currentLevel_;