From 25eb8258fa1ce55991bc96819ba83847592a0d74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Wed, 29 Jun 2011 18:02:22 +0300 Subject: [PATCH] Vibration on/off now in the menu. Defaults to off. Untested for now. --- mainwindow.cpp | 8 ++++++++ mainwindow.h | 2 ++ seascene.cpp | 6 ++++++ seascene.h | 3 +++ ship.cpp | 23 ++++++++++++++--------- ship.h | 4 ++++ 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 2357756..a6da0f7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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); } + diff --git a/mainwindow.h b/mainwindow.h index 2a4babc..3d4d5fa 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -46,6 +46,7 @@ public slots: void nextLevel(); + private: SeaScene * pScene_; @@ -53,6 +54,7 @@ QGraphicsView * pView_; QAction* pPauseAction_; + }; #endif // MAINWINDOW_H diff --git a/seascene.cpp b/seascene.cpp index b5d19af..0940694 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -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); +} diff --git a/seascene.h b/seascene.h index 70334e3..af923db 100644 --- a/seascene.h +++ b/seascene.h @@ -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. diff --git a/ship.cpp b/ship.cpp index 7ab50ff..adcc202 100644 --- a/ship.cpp +++ b/ship.cpp @@ -32,7 +32,7 @@ Ship::Ship(QList 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 arguments; - - arguments.append("PatternChatAndEmail"); + QList 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 --- 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 shipImages_; + bool vibrationActive_; + }; -- 1.7.9.5