Vibration on/off now in the menu.
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Wed, 29 Jun 2011 15:02:22 +0000 (18:02 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Wed, 29 Jun 2011 15:03:29 +0000 (18:03 +0300)
Defaults to off.
Untested for now.

mainwindow.cpp
mainwindow.h
seascene.cpp
seascene.h
ship.cpp
ship.h

index 2357756..a6da0f7 100644 (file)
@@ -66,6 +66,13 @@ MainWindow::MainWindow(QWidget *parent)
     menuBar()->addAction(pAboutAction);
 
 
+    QAction * pVibrateAction = new QAction(tr("Vibration effects"),this);
+    pVibrateAction->setCheckable(true);
+    addAction(pVibrateAction);
+    connect(pVibrateAction,SIGNAL(triggered(bool)),this,SLOT(setVibrationEffects(bool)));
+    menuBar()->addAction(pVibrateAction);
+
+
     //the boundaries of the scene are set to match the size of the view window, which is not
     //available in the constructor --> timer needed
     QTimer::singleShot(100,this,SLOT(initializeBoundaries()));
@@ -203,3 +210,4 @@ bool MainWindow::event(QEvent *event)
     return QMainWindow::event(event);
 
  }
+
index 2a4babc..3d4d5fa 100644 (file)
@@ -46,6 +46,7 @@ public slots:
     void nextLevel();
 
 
+
 private:
 
 SeaScene * pScene_;
@@ -53,6 +54,7 @@ QGraphicsView * pView_;
 QAction* pPauseAction_;
 
 
+
 };
 
 #endif // MAINWINDOW_H
index b5d19af..0940694 100644 (file)
@@ -165,6 +165,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses)
     addItem(pShip);
     connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) );
     connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int)));
+    connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool)));
     pShip->startMoving();
     movingItems_.append(pShip);
     connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving()));
@@ -308,3 +309,8 @@ void SeaScene::pause(bool paused)
             screenLitKeeper_.keepScreenLit(false);
         }
 }
+
+void SeaScene::vibrationActivate(bool on)
+{
+    emit vibrationActivated(on);
+}
index 70334e3..af923db 100644 (file)
@@ -15,6 +15,7 @@ signals:
     void allGhostsPicked();
     void pauseOn();
     void pauseOff();
+    void vibrationActivated(bool on);
 
 public slots:
 
@@ -34,6 +35,8 @@ public slots:
 
     void pause (bool paused);
 
+    void vibrationActivate(bool);
+
 protected:
 
     /*! Gives a pointer to a random position if a free one is found. Otherwise returns NULL.
index 7ab50ff..adcc202 100644 (file)
--- a/ship.cpp
+++ b/ship.cpp
@@ -32,7 +32,7 @@ Ship::Ship(QList<QPixmap> pixmapList, QGraphicsItem *parent) :
 {
     shipImages_ = pixmapList;
     ghostsAboard_ = 0;
-
+    vibrationActive_ = false;
 }
 
 bool Ship::handleCollisions()
@@ -93,18 +93,23 @@ void Ship::dropAllGhosts()
 
     //vibrate
 
+    if (vibrationActive_)
+    {
+        QDBusMessage message = QDBusMessage::createMethodCall("com.nokia.mce","/com/nokia/mce/request","com.nokia.mce.request","req_vibrator_pattern_activate");
 
-    QDBusMessage message = QDBusMessage::createMethodCall("com.nokia.mce","/com/nokia/mce/request","com.nokia.mce.request","req_vibrator_pattern_activate");
-
-    QList<QVariant> arguments;
-
-    arguments.append("PatternChatAndEmail");
+        QList<QVariant> arguments;
 
-    message.setArguments(arguments);
+        arguments.append("PatternChatAndEmail");
 
-    message = QDBusConnection::systemBus().call(message);
+        message.setArguments(arguments);
 
-    qDebug() << message;
+        message = QDBusConnection::systemBus().call(message);
 
+    //qDebug() << message;
+    }
 }
 
+void Ship::setVibrationActivate(bool on)
+{
+    vibrationActive_ = on;
+}
diff --git a/ship.h b/ship.h
index 3cb73de..f07bced 100644 (file)
--- a/ship.h
+++ b/ship.h
@@ -46,6 +46,8 @@ public slots:
 
     void dropAllGhosts();
 
+    void setVibrationActivate(bool on);
+
 protected:
 
 protected:
@@ -57,6 +59,8 @@ protected:
 
     QList<QPixmap> shipImages_;
 
+    bool vibrationActive_;
+
 
 };