summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2010-07-15 10:40:14 +1000
committerChris Adams <christopher.adams@nokia.com>2010-07-15 11:28:32 +1000
commit3d0bdc89b3faa544ee019e6cdec648856deef426 (patch)
tree20bb38b440b1024a6d6841ddd2e6bb8e12342bac /doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp
parent1956c8d4de27c4200d8568c55ba2f60fbef5c59a (diff)
Add new feedback example, and expand documentation for feedback module
The new example is a simple example which contains four buttons, each of which plays a simple haptic effect. Also add some doc snippets for feedback
Diffstat (limited to 'doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp')
-rw-r--r--doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp b/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp
index 257011312b..e26412fb4c 100644
--- a/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp
+++ b/doc/src/snippets/qtfeedbackdocsample/qtfeedbackdocsample.cpp
@@ -43,6 +43,7 @@
#include <qfeedbackactuator.h>
#include <qfeedbackeffect.h>
+#include <QDebug>
QTM_USE_NAMESPACE
@@ -50,8 +51,56 @@ void completeExample();
void completeExample()
{
- //TODO..
-//! [Complete example]
- // Coming soon...
-//! [Complete example]
+//! [Play the system theme button click effect]
+ QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeBasicButton);
+//! [Play the system theme button click effect]
+
+//! [Play the system theme bounce effect]
+ QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeBounceEffect);
+//! [Play the system theme bounce effect]
+
+//! [Define a custom haptic effect]
+ QFeedbackHapticsEffect rumble;
+ rumble.setAttackIntensity(0.0);
+ rumble.setAttackTime(250);
+ rumble.setIntensity(1.0);
+ rumble.setDuration(100);
+ rumble.setFadeTime(250);
+ rumble.setFadeIntensity(0.0);
+//! [Define a custom haptic effect]
+
+//! [Start playing a custom haptic effect]
+ rumble.start();
+//! [Start playing a custom haptic effect]
+
+//! [Pause a custom haptic effect]
+ rumble.pause();
+//! [Pause a custom haptic effect]
+
+//! [Stop playing a custom haptic effect]
+ rumble.stop();
+//! [Stop playing a custom haptic effect]
+
+//! [Query the state of a custom haptic effect]
+ if (rumble.state() == QFeedbackEffect::Stopped)
+ qDebug() << "The device has stopped rumbling!";
+//! [Query the state of a custom haptic effect]
+
+//! [Set the actuator which should play the custom effect]
+ QFeedbackActuator actuator; // default system actuator
+ QList<QFeedbackActuator> actuators = QFeedbackActuator::actuators();
+ foreach (const QFeedbackActuator& temp, actuators) {
+ if (temp.name() == "ExampleActuatorName") {
+ actuator = temp;
+ }
+ }
+ rumble.setActuator(actuator);
+//! [Set the actuator which should play the custom effect]
+
+//! [Play a haptic effect from a file]
+ QFeedbackFileEffect hapticTune;
+ hapticTune.setFileName("mySavedRumble.ifr");
+ hapticTune.load();
+ hapticTune.start();
+//! [Play a haptic effect from a file]
}