Added touchscreen enabled flag.
[situare] / src / engine / mceprivate.cpp
index 4a0c9b2..1816e9a 100644 (file)
@@ -37,7 +37,8 @@ static QDBusConnection dBusConnection = QDBusConnection::systemBus();
 
 MCEPrivate::MCEPrivate(QObject *parent)
     : QObject(parent),
-      m_displayOn(true)
+      m_displayOn(true),
+      m_touchscreenVibrationEnabled(false)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -53,7 +54,9 @@ MCEPrivate::MCEPrivate(QObject *parent)
                                       SLOT(setDisplayState(QString)),
                                       SLOT(displayStateError(QDBusError)));
 
-    if (isTouchscreenVibrationEnabled())
+    m_touchscreenVibrationEnabled = isTouchscreenVibrationEnabled();
+
+    if (m_touchscreenVibrationEnabled)
         m_dBusInterface->call(MCE_ENABLE_VIBRATOR);
 }
 
@@ -130,15 +133,18 @@ void MCEPrivate::vibrationFeedback()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_dBusInterface->call(MCE_ACTIVATE_VIBRATOR_PATTERN, "PatternPowerKeyPress");
+    if (m_touchscreenVibrationEnabled) {
+        m_dBusInterface->call(MCE_ACTIVATE_VIBRATOR_PATTERN, "PatternPowerKeyPress");
 
-    const int VIBRATION_TIME = 40;  //Vibration time in milliseconds
-    QTimer::singleShot(VIBRATION_TIME, this, SLOT(stopVibration()));
+        const int VIBRATION_TIME = 40;  //Vibration time in milliseconds
+        QTimer::singleShot(VIBRATION_TIME, this, SLOT(stopVibration()));
+    }
 }
 
 MCEPrivate::~MCEPrivate()
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qWarning() << __PRETTY_FUNCTION__;
 
-    m_dBusInterface->call(MCE_DISABLE_VIBRATOR);
+    if (m_touchscreenVibrationEnabled)
+        m_dBusInterface->call(MCE_DISABLE_VIBRATOR);
 }