MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QFeedbackEffect Class Reference

The QFeedbackEffect class is the abstract base class for feedback effects. More...

 #include <QFeedbackEffect>

Inherits: QObject.

Inherited by: QFeedbackFileEffect and QFeedbackHapticsEffect.

This class was introduced in Qt Mobility 1.1.

Public Types

enum Duration { Infinite }
enum ErrorType { UnknownError, DeviceBusy }
enum State { Stopped, Paused, Running, Loading }
enum ThemeEffect { ThemeBasic, ThemeSensitive, ThemeBasicButton, ThemeSensitiveButton, ..., ThemeUser }

Properties

  • 1 property inherited from QObject

Public Functions

QFeedbackEffect ( QObject * parent = 0 )
virtual int duration () const = 0
virtual State state () const = 0
  • 29 public functions inherited from QObject

Public Slots

void pause ()
void start ()
void stop ()
  • 1 public slot inherited from QObject

Signals

void error ( QFeedbackEffect::ErrorType error ) const
void stateChanged ()

Static Public Members

bool playThemeEffect ( ThemeEffect effect )
bool supportsThemeEffect ()
  • 4 static public members inherited from QObject

Protected Functions

virtual void setState ( State state ) = 0
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 public variable inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QFeedbackEffect class is the abstract base class for feedback effects.

It represents an effect to provide feedback to a person (i.e., an effect that affect human senses). The technology available today usually only provides haptic effects, which deal with the sense of touch, and audio effects. The QFeedbackHapticsEffect and QFeedbackFileEffect are implementations of haptic effects and can be used to control a mobile device's vibrator. In addition, the QFeedbackFileEffect can also be used to play audio feedback.

Feedback effects have a duration, which is measured in milliseconds. Subclasses reimplement duration() to inform how long the effect lasts. The duration is the total time the effect will last, and thus includes any envelope modifiers (attack and fade).

At any given time, a feedback effect is in one of four states: Loading, Stopped, Running, or Paused. See the State enum documentation for further details. Subclasses must reimplement state() to report which state an effect is in, and setState() to receive state change requests. The start(), pause(), and stop() slots calls setState() with the corresponding new State. Changes in state are reported through the stateChanged() signal and may happen asynchronously some time after the state change request.

A system often has a set of standard feedback effects for user interface interaction (e.g., button clicks). The ThemeEffect describes the standard effects that QFeedbackEffect supports. It is named so because the effects often depend on the theme of the user interface. You can play these effects using the playThemeEffect() function.

 QFeedbackEffect::playThemeEffect(QFeedbackEffect::ThemeBasicButton);

The playThemeEffect() function returns true if the effect was played successfully. An effect may not be played if the system does not support it or if an error occurred.

Member Type Documentation

enum QFeedbackEffect::Duration

This enum describes the possible effect predefined duration types. Generally a specific milliseconds value can be supplied instead of one of these values.

Constant Value Description
QFeedbackEffect::Infinite -1 Infinite effect duration

enum QFeedbackEffect::ErrorType

This enum describes the possible errors happening on the effect.

Constant Value Description
QFeedbackEffect::UnknownError 0 An unknown error occurred.
QFeedbackEffect::DeviceBusy 1 The feedback could not start because the device is busy.

See also error().

enum QFeedbackEffect::State

This enum describes the state of the effect. An effect will be in one of these states.

Constant Value Description
QFeedbackEffect::Stopped 0 The effect is not running. This is the initial state. The state changes to either Loading when loading an effect or to Running when the effect is started by calling start(). When an effect has finished playing, it will enter the Stopped state again.
QFeedbackEffect::Paused 1 The effect is paused. Calling start() will resume it.
QFeedbackEffect::Running 2 The effect is running. You can control the current state by calling the stop() or pause() functions.
QFeedbackEffect::Loading 3 The effect is loading. That can happen when loading is done asynchronously. When the effect has loaded, the state will change to either Running (if start() has been called) or Stopped.

See also state().

enum QFeedbackEffect::ThemeEffect

This enum describes all possible theme effect types. In general, "sensitive" versions of effects are useful if it is less important that the effect is noticed, or when a lot of the effects are going to be played close together. Theme effects might be tactile, or audio or visual.

Not all platforms and devices have distinct effects for each type.

Constant Value Description
QFeedbackEffect::ThemeBasic 0 Generic feedback.
QFeedbackEffect::ThemeSensitive 1 Generic sensitive feedback.
QFeedbackEffect::ThemeBasicButton 2 Feedback for interacting with a button (e.g. pressing).
QFeedbackEffect::ThemeSensitiveButton 3 Sensitive feedback for interacting with a button (e.g. auto repeat).
QFeedbackEffect::ThemeBasicKeypad 4 Feedback for interacting with a keypad button.
QFeedbackEffect::ThemeSensitiveKeypad 5 Sensitive feedback for interacting with a keypad button.
QFeedbackEffect::ThemeBasicSlider 6 Feedback for moving a slider.
QFeedbackEffect::ThemeSensitiveSlider 7 Sensitive feedback for moving a slider.
QFeedbackEffect::ThemeBasicItem 8 Feedback when interacting with a list or grid item.
QFeedbackEffect::ThemeSensitiveItem 9 Sensitive feedback when interacting with a list or grid item.
QFeedbackEffect::ThemeItemScroll 10 Feedback when scrolling a list or grid item view.
QFeedbackEffect::ThemeItemPick 11 Feedback when selecting an item to move in a list or grid view.
QFeedbackEffect::ThemeItemDrop 12 Feedback when dropping an item in a list or grid view.
QFeedbackEffect::ThemeItemMoveOver 13 Feedback when moving an item in a list or grid view.
QFeedbackEffect::ThemeBounceEffect 14 Feedback for a bounce effect.
QFeedbackEffect::ThemeCheckBox 15 Feedback for selecting a checkbox.
QFeedbackEffect::ThemeMultipleCheckBox 16 Feedback for selecting checkboxes of multiple items.
QFeedbackEffect::ThemeEditor 17 Feedback for interacting with an editor.
QFeedbackEffect::ThemeTextSelection 18 Feedback for selecting text.
QFeedbackEffect::ThemeBlankSelection 19 Feedback for a blank selection.
QFeedbackEffect::ThemeLineSelection 20 Feedback for selecting a line.
QFeedbackEffect::ThemeEmptyLineSelection 21 Feedback for selecting an empty line.
QFeedbackEffect::ThemePopUp 22 Generic feedback for interacting with a popup.
QFeedbackEffect::ThemePopupOpen 23 Generic feedback when a popup opens.
QFeedbackEffect::ThemePopupClose 24 Generic feedback when a popup closes.
QFeedbackEffect::ThemeFlick 25 Generic feedback when starting a flick gesture.
QFeedbackEffect::ThemeStopFlick 26 Generic feedback when stopping a flick.
QFeedbackEffect::ThemeMultiPointTouchActivate 27 Generic feedback when a touch gesture with more than one point is started.
QFeedbackEffect::ThemeRotateStep 28 Feedback when rotating using a gesture.
QFeedbackEffect::ThemeLongPress 29 Feedback for a long press (or tap and hold) gesture.
QFeedbackEffect::ThemePositiveTacticon 30 Generic feedback for notification of a successful operation.
QFeedbackEffect::ThemeNeutralTacticon 31 Generic feedback for notification.
QFeedbackEffect::ThemeNegativeTacticon 32 Generic feedback for notification of a failed operation.
QFeedbackEffect::NumberOfThemeEffects 33 The number of built-in effects.
QFeedbackEffect::ThemeUser 65535 The starting point for any user defined effects, where supported.

Property Documentation

duration : const int

This property holds duration of the feedback effect, in milliseconds.

In some cases the duration will be unknown, which will be reported as 0. If the duration is infinite, QFeedbackEffect::Infinite will be returned. Some subclasses may have more than one type of duration (for example, QFeedbackHapticsEffect), and this property will return the total duration of the effect.

Access functions:

virtual int duration () const = 0

state : const State

This property holds state of the feedback effect.

This returns the state of the feedback effect. The State enumeration reports the possible states.

Access functions:

virtual State state () const = 0

Notifier signal:

void stateChanged ()

Member Function Documentation

QFeedbackEffect::QFeedbackEffect ( QObject * parent = 0 )

Constructs the QFeedbackEffect base class, and passes parent to QObject's constructor. This is called by the classes that inherit from this class.

void QFeedbackEffect::error ( QFeedbackEffect::ErrorType error ) const [signal]

This signal is emitted by subclasses if an error occurred during playback of an effect. The ErrorType enum describes the errors that can be reported.

This function was introduced in Qt Mobility 1.1.

void QFeedbackEffect::pause () [slot]

Pauses a playing effect. If an error occurs the error() signal will be emitted. Not all systems support pausing an effect during playback.

This function was introduced in Qt Mobility 1.1.

bool QFeedbackEffect::playThemeEffect ( ThemeEffect effect ) [static]

This function plays effect instantly and returns true if the effect could be played; otherwise, returns false.

void QFeedbackEffect::setState ( State state ) [pure virtual protected]

Requests the effect to change its State to change to the specified state.

Subclasses reimplement this function to handle state change requests for the effect.

This function was introduced in Qt Mobility 1.1.

See also state().

void QFeedbackEffect::start () [slot]

Starts playing the effect. If an error occurs the error() signal will be emitted.

This function was introduced in Qt Mobility 1.1.

See also stop().

void QFeedbackEffect::stateChanged () [signal]

This signal is emitted by subclasses when the State of the effect changes.

This function was introduced in Qt Mobility 1.1.

See also state().

void QFeedbackEffect::stop () [slot]

Stops a playing effect. If an error occurs the error() signal will be emitted.

This function was introduced in Qt Mobility 1.1.

See also start(), pause(), and setState().

bool QFeedbackEffect::supportsThemeEffect () [static]

Returns true if playing themed feedback is available.