22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include "hbinstantfeedback.h" |
26 #include "hbinstantfeedback.h" |
27 #include "hbfeedbackplayer.h" |
27 #include "hbfeedbackplayer_p.h" |
28 |
28 |
29 #include <QGraphicsItem> |
29 #include <QGraphicsItem> |
30 #include <QGraphicsView> |
30 #include <QGraphicsView> |
31 #include <QDebug> |
31 #include <QDebug> |
32 |
32 |
44 @beta |
44 @beta |
45 @hbfeedback |
45 @hbfeedback |
46 |
46 |
47 \class HbInstantFeedback |
47 \class HbInstantFeedback |
48 |
48 |
49 \brief Tool class for instant feedback effects. |
49 \brief Class for instant feedback effects. |
50 |
50 |
51 Instant feedbacks are used to initiate fire&forget type of sound and haptic effects defined in the device themes. |
51 Instant feedbacks are used to initiate short, fire&forget type of feedback effects. |
52 Effects are used as a feedback indication to the user when she/he is navigating and interacting |
52 Effects are used as a feedback indication while the user is interacting with the device. |
53 with the device. |
|
54 */ |
53 */ |
55 |
54 |
56 /*! |
55 /*! |
57 \fn void HbInstantFeedback::setInstantEffect(HbFeedback::InstantEffect effect) |
56 \fn void HbInstantFeedback::setInstantEffect(HbFeedback::InstantEffect effect) |
58 |
57 |
59 Sets the instant effect that determines what kind of haptic and sound effects will |
58 Sets the instant effect to be be played when calling HbFeedbackPlayer::playInstantFeedback(). |
60 be played when calling HbFeedbackPlayer::playInstantFeedback() or when user touches the screen |
|
61 over the hit area with the given instant effect. The actual effects are |
|
62 defined in the device themes. |
|
63 */ |
59 */ |
64 |
60 |
65 void HbInstantFeedback::setInstantEffect(HbFeedback::InstantEffect effect) |
61 void HbInstantFeedback::setInstantEffect(HbFeedback::InstantEffect effect) |
66 { |
62 { |
67 d->cEffect = effect; |
63 d->cEffect = effect; |
68 } |
64 } |
69 |
65 |
70 /*! |
66 /*! |
71 \fn void HbFeedback::InstantEffect HbInstantFeedback::instantEffect() const |
67 \fn void HbFeedback::InstantEffect HbInstantFeedback::instantEffect() const |
72 |
68 |
73 Returns the instant effect of the instant feedback object. Instant effect is used to determine what kind of |
69 Returns the instant effect of the instant feedback object. Instant effect represents the feedback |
74 haptic and sound effects will be played when calling HbFeedbackPlayer::playInstantFeedback() or |
70 effect to be played when calling HbFeedbackPlayer::playInstantFeedback(). |
75 when user touches the screen over the hit area with the given instant effect. The actual effects |
|
76 are defined in the device themes. |
|
77 */ |
71 */ |
78 |
72 |
79 HbFeedback::InstantEffect HbInstantFeedback::instantEffect() const |
73 HbFeedback::InstantEffect HbInstantFeedback::instantEffect() const |
80 { |
74 { |
81 return d->cEffect; |
75 return d->cEffect; |
129 { |
122 { |
130 delete d; |
123 delete d; |
131 } |
124 } |
132 |
125 |
133 /*! |
126 /*! |
134 Initiates the instant feedback effect. |
127 Plays the instant feedback effect. |
135 */ |
128 */ |
136 void HbInstantFeedback::play() |
129 void HbInstantFeedback::play() |
137 { |
130 { |
138 HbFeedbackPlayer* player = HbFeedbackPlayer::instance(); |
131 HbFeedbackPlayer* feedbackPlayer = HbFeedbackPlayer::instance(); |
139 if (player) { |
132 if (feedbackPlayer) { |
140 player->playInstantFeedback(d->cEffect); |
133 feedbackPlayer->playInstantFeedback(*this); |
141 } |
134 } |
142 } |
135 } |
143 |
136 |
144 /*! |
137 /*! |
145 Initiates the given instant feedback effect. |
138 Plays the given instant feedback effect. |
146 */ |
139 */ |
147 void HbInstantFeedback::play(HbFeedback::InstantEffect effect) |
140 void HbInstantFeedback::play(HbFeedback::InstantEffect effect) |
148 { |
141 { |
149 HbFeedbackPlayer* player = HbFeedbackPlayer::instance(); |
142 HbFeedbackPlayer* player = HbFeedbackPlayer::instance(); |
150 if (player) { |
143 if (player) { |
162 setInstantEffect(feedback.instantEffect()); |
155 setInstantEffect(feedback.instantEffect()); |
163 return *this; |
156 return *this; |
164 } |
157 } |
165 |
158 |
166 /*! |
159 /*! |
167 Returns true if this feedback has the same configuration as the feedback \a |
160 Returns true if this feedback has the same parameters as the feedback |
168 feedback; otherwise returns false. |
161 \a feedback, otherwise returns false. |
169 */ |
162 */ |
170 bool HbInstantFeedback::operator==(const HbInstantFeedback &feedback) const |
163 bool HbInstantFeedback::operator==(const HbInstantFeedback &feedback) const |
171 { |
164 { |
172 return (rect() == feedback.rect() |
165 return (rect() == feedback.rect() |
173 && window() == feedback.window() |
166 && window() == feedback.window() |
174 && d->cEffect == feedback.instantEffect()); |
167 && d->cEffect == feedback.instantEffect()); |
175 } |
168 } |
176 |
169 |
177 /*! |
170 /*! |
178 Returns true if this feedback has different configuration than the feedback \a |
171 Returns true if this feedback has different parameters than the feedback |
179 feedback; otherwise returns false. |
172 \a feedback, otherwise returns false. |
180 */ |
173 */ |
181 bool HbInstantFeedback::operator!=(const HbInstantFeedback &feedback) const |
174 bool HbInstantFeedback::operator!=(const HbInstantFeedback &feedback) const |
182 { |
175 { |
183 return !(*this == feedback); |
176 return !(*this == feedback); |
184 } |
177 } |