Added fibration feedback feature.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Jul 2010 07:27:12 +0000 (10:27 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Jul 2010 07:27:12 +0000 (10:27 +0300)
14 files changed:
src/engine/engine.cpp
src/engine/engine.h
src/engine/mce.cpp
src/engine/mce.h
src/engine/mceprivate.cpp
src/engine/mceprivate.h
src/engine/mceprivatestub.cpp
src/engine/mceprivatestub.h
src/ui/indicatorbutton.cpp
src/ui/indicatorbutton.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/zoombuttonpanel.cpp
src/ui/zoombuttonpanel.h

index 2ab3808..96f5512 100644 (file)
@@ -159,6 +159,12 @@ void SituareEngine::disableAutoCentering()
     changeAutoCenteringSetting(false);
 }
 
+void SituareEngine::draggingModeTriggered()
+{
+    if (m_mce)
+        m_mce->vibrationFeedback();
+}
+
 void SituareEngine::enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -644,6 +650,9 @@ void SituareEngine::signalsFromMainWindow()
 
     connect(m_ui, SIGNAL(searchForLocation(QString)),
             this, SLOT(locationSearch(QString)));
+
+    connect(m_ui, SIGNAL(draggingModeTriggered()),
+            this, SLOT(draggingModeTriggered()));
 }
 
 void SituareEngine::signalsFromMapEngine()
@@ -738,4 +747,3 @@ void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
     emit userLocationReady(user);
     emit friendsLocationsReady(friendsList);
 }
-
index 72a0c63..75e88f0 100644 (file)
@@ -274,6 +274,8 @@ private slots:
     */
     void startAutomaticUpdate();
 
+    void draggingModeTriggered();
+
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
index 54b39eb..eb1289f 100644 (file)
@@ -43,3 +43,8 @@ bool MCE::isDisplayOn()
 
     return m_mcePrivate->isDisplayOn();
 }
+
+void MCE::vibrationFeedback()
+{
+    m_mcePrivate->vibrationFeedback();
+}
index d3868a1..d053e81 100644 (file)
@@ -59,6 +59,11 @@ public:
     */
     bool isDisplayOn();
 
+    /**
+    * @brief Vibrates the phone for short time.
+    */
+    void vibrationFeedback();
+
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
index 1cd3141..5befc6c 100644 (file)
@@ -50,6 +50,8 @@ MCEPrivate::MCEPrivate(QObject *parent)
     m_dBusInterface->callWithCallback(MCE_DISPLAY_STATUS_GET, QList<QVariant>(), this,
                                       SLOT(setDisplayState(QString)),
                                       SLOT(displayStateError(QDBusError)));
+
+    m_dBusInterface->call(MCE_ENABLE_VIBRATOR);
 }
 
 void MCEPrivate::displayStateChanged(const QDBusMessage &message)
@@ -89,3 +91,27 @@ void MCEPrivate::setDisplayState(const QString &state)
         }
     }
 }
+
+void MCEPrivate::stopVibration()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_dBusInterface->call(MCE_ACTIVATE_VIBRATOR_PATTERN, "PatternPowerKeyPress");
+}
+
+void MCEPrivate::vibrationFeedback()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_dBusInterface->call(MCE_ACTIVATE_VIBRATOR_PATTERN, "PatternPowerKeyPress");
+
+    const int VIBRATION_TIME = 40;  //Vibration time in milliseconds
+    QTimer::singleShot(VIBRATION_TIME, this, SLOT(stopVibration()));
+}
+
+MCEPrivate::~MCEPrivate()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_dBusInterface->call(MCE_DISABLE_VIBRATOR);
+}
index 095ee5e..cb4faf0 100644 (file)
@@ -41,9 +41,18 @@ public:
     * @brief Constructor.
     *
     * @param parent QObject
+    *
+    * Enables vibration mode.
     */
     MCEPrivate(QObject *parent);
 
+    /**
+    * @brief Destructor.
+    *
+    * Disables vibration mode.
+    */
+    ~MCEPrivate();
+
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
@@ -55,6 +64,13 @@ public:
     */
     bool isDisplayOn();
 
+    /**
+    * @brief Vibrates the phone for short time.
+    *
+    * Uses pre-defined vibration pattern.
+    */
+    void vibrationFeedback();
+
 private slots:
     /**
     * @brief Slot for display state changed.
@@ -77,6 +93,11 @@ private slots:
     */
     void setDisplayState(const QString &state);
 
+    /**
+    * @brief Stops vibration.
+    */
+    void stopVibration();
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
index e6273db..3c0c101 100644 (file)
@@ -36,3 +36,8 @@ bool MCEPrivate::isDisplayOn()
 
     return true;
 }
+
+void MCEPrivate::vibrationFeedback()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
index 25e9b1c..3489213 100644 (file)
@@ -53,6 +53,13 @@ public:
     * @return true if on, false if off.
     */
     bool isDisplayOn();
+
+    /**
+    * @brief Vibrates the phone for short time.
+    *
+    * DOES NOTHING.
+    */
+    void vibrationFeedback();
 };
 
 #endif // MCEPRIVATESTUB_H
index d6b1a9d..92e7ebf 100644 (file)
@@ -173,6 +173,7 @@ void IndicatorButton::setDraggable(bool mode, QPoint eventPosition)
     m_isDraggable = mode;
 
     if(mode) {
+        emit draggingModeTriggered();
         m_forceReleaseTimer->start();
         m_dragPosition = eventPosition;
     } else {
index c994e3b..4dc31f7 100644 (file)
@@ -128,6 +128,11 @@ signals:
      */
     void autoCenteringTriggered(bool enabled);
 
+    /**
+    * @brief Dragging mode triggered.
+    */
+    void draggingModeTriggered();
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
index ee2c85e..f585010 100644 (file)
@@ -188,6 +188,9 @@ void MainWindow::buildIndicatorButton()
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
             m_indicatorButton, SLOT(screenResized(QSize)));
+
+    connect(m_indicatorButton, SIGNAL(draggingModeTriggered()),
+            this, SIGNAL(draggingModeTriggered()));
 }
 
 void MainWindow::buildInformationBox(const QString &message, bool modal)
@@ -390,6 +393,8 @@ void MainWindow::buildZoomButtonPanel()
     connect(m_mapView, SIGNAL(viewResized(QSize)),
             m_zoomButtonPanel, SLOT(screenResized(QSize)));
 
+    connect(m_zoomButtonPanel, SIGNAL(draggingModeTriggered()),
+            this, SIGNAL(draggingModeTriggered()));
 }
 
 void MainWindow::clearCookieJar()
index 1d59362..2189709 100644 (file)
@@ -578,6 +578,11 @@ signals:
     void clearUpdateLocationDialogData();
 
     /**
+    * @brief Dragging mode triggered.
+    */
+    void draggingModeTriggered();
+
+    /**
      * @brief MapView has finished zooming
      */
     void viewZoomFinished();
index 919888e..7aecc58 100644 (file)
@@ -202,6 +202,8 @@ void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition)
     m_isDraggable = mode;
 
     if(mode) {
+        emit draggingModeTriggered();
+
         m_zoomInMode = m_zoomInButton->mode();
         m_zoomOutMode = m_zoomOutButton->mode();
         m_zoomInButton->setMode(QIcon::Disabled);
index 2c44379..ad7ea4f 100644 (file)
@@ -138,6 +138,9 @@ private slots:
      */
     void timerExpired();
 
+signals:
+    void draggingModeTriggered();
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/