| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
#ifndef QFEEDBACKEFFECT_H |
| 41 |
#define QFEEDBACKEFFECT_H |
| 42 |
|
| 43 |
#include "qfeedbackglobal.h" |
| 44 |
|
| 45 |
#include <QtCore/QObject> |
| 46 |
#include <QtCore/QStringList> |
| 47 |
#include <QtCore/QUrl> |
| 48 |
|
| 49 |
QT_BEGIN_HEADER |
| 50 |
QT_BEGIN_NAMESPACE |
| 51 |
|
| 52 |
class QFeedbackActuator; |
| 53 |
class QFeedbackFileEffectPrivate; |
| 54 |
class QFeedbackHapticsEffectPrivate; |
| 55 |
|
| 56 |
class Q_FEEDBACK_EXPORT QFeedbackEffect : public QObject |
| 57 |
{ |
| 58 |
Q_OBJECT |
| 59 |
Q_ENUMS(Effect) |
| 60 |
Q_ENUMS(Duration) |
| 61 |
Q_ENUMS(State) |
| 62 |
Q_ENUMS(ErrorType) |
| 63 |
|
| 64 |
Q_PROPERTY(int duration READ duration) |
| 65 |
Q_PROPERTY(State state READ state NOTIFY stateChanged) |
| 66 |
|
| 67 |
public: |
| 68 |
|
| 69 |
enum Effect { |
| 70 |
Undefined = -1, Press, Release, PressWeak, ReleaseWeak, PressStrong, ReleaseStrong, DragStart, |
| 71 |
DragDropInZone, DragDropOutOfZone, DragCrossBoundary, Appear, Disappear, Move, |
| 72 |
NumberOfEffects, |
| 73 |
UserEffect = 65535 |
| 74 |
}; |
| 75 |
|
| 76 |
enum Duration { |
| 77 |
Infinite = -1 |
| 78 |
}; |
| 79 |
|
| 80 |
enum State { |
| 81 |
Stopped, |
| 82 |
Paused, |
| 83 |
Running, |
| 84 |
Loading |
| 85 |
}; |
| 86 |
|
| 87 |
enum ErrorType { |
| 88 |
UnknownError, |
| 89 |
DeviceBusy |
| 90 |
}; |
| 91 |
|
| 92 |
explicit QFeedbackEffect(QObject *parent = Q_NULLPTR); |
| 93 |
|
| 94 |
virtual State state() const = 0; |
| 95 |
virtual int duration() const = 0; |
| 96 |
|
| 97 |
|
| 98 |
static bool supportsThemeEffect(); |
| 99 |
static bool playThemeEffect(Effect effect); |
| 100 |
|
| 101 |
public Q_SLOTS: |
| 102 |
void start(); |
| 103 |
void stop(); |
| 104 |
void pause(); |
| 105 |
|
| 106 |
protected: |
| 107 |
virtual void setState(State) = 0; |
| 108 |
|
| 109 |
Q_SIGNALS: |
| 110 |
void error(QFeedbackEffect::ErrorType) const; |
| 111 |
void stateChanged(); |
| 112 |
|
| 113 |
private: |
| 114 |
friend class QFeedbackInterface; |
| 115 |
}; |
| 116 |
|
| 117 |
class Q_FEEDBACK_EXPORT QFeedbackHapticsEffect : public QFeedbackEffect |
| 118 |
{ |
| 119 |
Q_OBJECT |
| 120 |
|
| 121 |
Q_PROPERTY(int duration READ duration WRITE setDuration) |
| 122 |
Q_PROPERTY(qreal intensity READ intensity WRITE setIntensity) |
| 123 |
Q_PROPERTY(int attackTime READ attackTime WRITE setAttackTime) |
| 124 |
Q_PROPERTY(qreal attackIntensity READ attackIntensity WRITE setAttackIntensity) |
| 125 |
Q_PROPERTY(int fadeTime READ fadeTime WRITE setFadeTime) |
| 126 |
Q_PROPERTY(qreal fadeIntensity READ fadeIntensity WRITE setFadeIntensity) |
| 127 |
Q_PROPERTY(int period READ period WRITE setPeriod) |
| 128 |
Q_PROPERTY(QFeedbackActuator* actuator READ actuator WRITE setActuator) |
| 129 |
|
| 130 |
public: |
| 131 |
explicit QFeedbackHapticsEffect(QObject *parent = Q_NULLPTR); |
| 132 |
~QFeedbackHapticsEffect(); |
| 133 |
|
| 134 |
void setDuration(int msecs); |
| 135 |
int duration() const; |
| 136 |
|
| 137 |
void setIntensity(qreal intensity); |
| 138 |
qreal intensity() const; |
| 139 |
|
| 140 |
|
| 141 |
void setAttackTime(int msecs); |
| 142 |
int attackTime() const; |
| 143 |
|
| 144 |
void setAttackIntensity(qreal intensity); |
| 145 |
qreal attackIntensity() const; |
| 146 |
|
| 147 |
void setFadeTime(int msecs); |
| 148 |
int fadeTime() const; |
| 149 |
|
| 150 |
void setFadeIntensity(qreal intensity); |
| 151 |
qreal fadeIntensity() const; |
| 152 |
|
| 153 |
void setPeriod(int msecs); |
| 154 |
int period() const; |
| 155 |
|
| 156 |
void setActuator(QFeedbackActuator *actuator); |
| 157 |
QFeedbackActuator* actuator() const; |
| 158 |
|
| 159 |
|
| 160 |
virtual State state() const; |
| 161 |
|
| 162 |
protected: |
| 163 |
virtual void setState(State); |
| 164 |
|
| 165 |
private: |
| 166 |
Q_DISABLE_COPY(QFeedbackHapticsEffect) |
| 167 |
friend class QFeedbackHapticsEffectPrivate; |
| 168 |
QScopedPointer<QFeedbackHapticsEffectPrivate> priv; |
| 169 |
}; |
| 170 |
|
| 171 |
class Q_FEEDBACK_EXPORT QFeedbackFileEffect : public QFeedbackEffect |
| 172 |
{ |
| 173 |
Q_OBJECT |
| 174 |
|
| 175 |
Q_PROPERTY(bool loaded READ isLoaded WRITE setLoaded) |
| 176 |
Q_PROPERTY(QUrl source READ source WRITE setSource) |
| 177 |
|
| 178 |
public: |
| 179 |
explicit QFeedbackFileEffect(QObject *parent = Q_NULLPTR); |
| 180 |
~QFeedbackFileEffect(); |
| 181 |
|
| 182 |
int duration() const; |
| 183 |
|
| 184 |
bool isLoaded() const; |
| 185 |
|
| 186 |
void load(); |
| 187 |
void unload(); |
| 188 |
void setLoaded(bool); |
| 189 |
|
| 190 |
QUrl source() const; |
| 191 |
void setSource(const QUrl &); |
| 192 |
|
| 193 |
static QStringList supportedMimeTypes(); |
| 194 |
|
| 195 |
|
| 196 |
virtual State state() const; |
| 197 |
|
| 198 |
protected: |
| 199 |
virtual void setState(State); |
| 200 |
|
| 201 |
private: |
| 202 |
Q_DISABLE_COPY(QFeedbackFileEffect) |
| 203 |
friend class QFeedbackFileEffectPrivate; |
| 204 |
QScopedPointer<QFeedbackFileEffectPrivate> priv; |
| 205 |
}; |
| 206 |
|
| 207 |
QT_END_NAMESPACE |
| 208 |
QT_END_HEADER |
| 209 |
|
| 210 |
#endif |