summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
diff options
context:
space:
mode:
authorMichael Goddard <michael.goddard@nokia.com>2010-11-04 12:31:49 +1000
committerMichael Goddard <michael.goddard@nokia.com>2010-11-04 14:32:41 +1000
commita8c807466666db59e921085fb90b1ef533b538ba (patch)
treed8632a8103efd858034dc7c653d7af3dd884564b /tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
parent0e6ca9bde7f563c5d78e6ec9c515955207e38d21 (diff)
Reenable the check for haptics effect state changing to stop when done.
It is possible to do this now. Backends will need to be updated. Change-Id: I5e6efe23d9cf407bb07c13f5a5cb3dea08a3838c Task-number: QTMOBILITY-687
Diffstat (limited to 'tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp')
-rw-r--r--tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp b/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
index 167389151c..cef3bf2623 100644
--- a/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
+++ b/tests/auto/qfeedbackplugin/testplugin/qfeedbacktestplugin.cpp
@@ -54,8 +54,6 @@ Q_EXPORT_PLUGIN2(feedback_testplugin, QFeedbackTestPlugin)
QFeedbackTestPlugin::QFeedbackTestPlugin() : QObject(qApp), mHapticState(QFeedbackEffect::Stopped), mFileState(QFeedbackEffect::Stopped)
{
actuators_ << createFeedbackActuator(this, 0) << createFeedbackActuator(this, 1);
- mHapticTimer.setSingleShot(true);
- connect(&mHapticTimer, SIGNAL(timeout()), this, SLOT(timerExpired()));
}
QFeedbackTestPlugin::~QFeedbackTestPlugin()
@@ -115,11 +113,27 @@ bool QFeedbackTestPlugin::isActuatorCapabilitySupported(const QFeedbackActuator
return false;
}
+QTimer* QFeedbackTestPlugin::ensureTimer(const QFeedbackHapticsEffect* effect)
+{
+ // Yes, this is slow
+ QTimer *t = mHapticEffects.key(effect);
+ if (!t) {
+ t = new QTimer();
+ t->setSingleShot(true);
+ t->setInterval(effect->duration());
+ connect(t, SIGNAL(timeout()), this, SLOT(timerExpired()));
+ mHapticEffects.insert(t, effect);
+ }
+ return t;
+}
+
void QFeedbackTestPlugin::updateEffectProperty(const QFeedbackHapticsEffect *effect, EffectProperty ep)
{
- if (ep == QFeedbackHapticsInterface::Duration)
- mHapticTimer.setInterval(effect->duration());
+ if (ep == QFeedbackHapticsInterface::Duration) {
+ QTimer* t = ensureTimer(effect);
+ t->setInterval(effect->duration());
+ }
}
void QFeedbackTestPlugin::setEffectState(const QFeedbackHapticsEffect *effect, QFeedbackEffect::State state)
@@ -127,13 +141,14 @@ void QFeedbackTestPlugin::setEffectState(const QFeedbackHapticsEffect *effect, Q
Q_UNUSED(effect)
if (mHapticState != state) {
mHapticState = state;
+ QTimer* t = ensureTimer(effect);
if (mHapticState == QFeedbackEffect::Running) {
- mHapticTimer.start();
+ t->start();
} else if (mHapticState == QFeedbackEffect::Stopped) {
- mHapticTimer.stop();
+ t->stop();
} else if (mHapticState == QFeedbackEffect::Paused) {
// In theory should set the duration to the remainder...
- mHapticTimer.stop();
+ t->stop();
}
}
}
@@ -147,6 +162,11 @@ QFeedbackEffect::State QFeedbackTestPlugin::effectState(const QFeedbackHapticsEf
void QFeedbackTestPlugin::timerExpired()
{
mHapticState = QFeedbackEffect::Stopped;
+ // Emit the stateChanged signal
+ const QFeedbackHapticsEffect* effect = mHapticEffects.value(static_cast<QTimer*>(sender()));
+ if (effect) {
+ QMetaObject::invokeMethod(const_cast<QFeedbackHapticsEffect*>(effect), "stateChanged");
+ }
}