39 #include <QGraphicsView> |
39 #include <QGraphicsView> |
40 |
40 |
41 #ifdef HB_FILTER_EFFECTS |
41 #ifdef HB_FILTER_EFFECTS |
42 #include "hbvgeffect_p.h" |
42 #include "hbvgeffect_p.h" |
43 #include "hbvgchainedeffect_p.h" |
43 #include "hbvgchainedeffect_p.h" |
|
44 #include "hbvgmaskeffect_p.h" |
44 #endif |
45 #endif |
|
46 |
|
47 static const char effect_fw_marker[] = "effw_chain"; |
45 |
48 |
46 HbEffectGroup::HbEffectGroup( |
49 HbEffectGroup::HbEffectGroup( |
47 const QString &effectEventType, |
50 const QString &effectEventType, |
48 QGraphicsItem *registrationItem, |
51 QGraphicsItem *registrationItem, |
49 QGraphicsItem *targetItem, |
52 QGraphicsItem *targetItem, |
261 |
267 |
262 HbVgChainedEffect *HbEffectGroup::vgEffect() |
268 HbVgChainedEffect *HbEffectGroup::vgEffect() |
263 { |
269 { |
264 if (!mVgEffect) { |
270 if (!mVgEffect) { |
265 mVgEffect = new HbVgChainedEffect; |
271 mVgEffect = new HbVgChainedEffect; |
|
272 mVgEffect->setObjectName(effect_fw_marker); |
266 } |
273 } |
267 return mVgEffect; |
274 return mVgEffect; |
268 } |
275 } |
269 |
276 |
270 void HbEffectGroup::activateVgEffect() |
277 void HbEffectGroup::activateVgEffect() |
271 { |
278 { |
272 if (!mVgEffectActivated) { |
279 if (!mVgEffectActivated) { |
273 mVgEffectGuard = QPointer<QGraphicsEffect>(); |
280 mVgEffectGuard = QPointer<QGraphicsEffect>(); |
|
281 if (mTargetItem->graphicsEffect()) { |
|
282 // Manually installed effects should not get lost. For example a |
|
283 // pop-up may install a mask effect before or after this |
|
284 // function. To support the 'before' case we have to add all |
|
285 // existing effects to the chain. Supporting the 'after' case is up |
|
286 // to the widget. However we can only support effects that are in a |
|
287 // chain, keeping single effects is not possible due to ownership |
|
288 // issues. |
|
289 HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(mTargetItem->graphicsEffect()); |
|
290 if (c) { |
|
291 QList<HbVgEffect *> effects = c->takeAll(); |
|
292 HbVgChainedEffect *newChain = vgEffect(); |
|
293 // Effects set by another HbEffectGroup instance must be ignored |
|
294 // here, those should go away because they probably would not work |
|
295 // well together anyway. |
|
296 bool chainIsFromEffectFw = c->objectName().compare(QLatin1String(effect_fw_marker)) == 0; |
|
297 foreach (HbVgEffect *effect, effects) { |
|
298 // Special handling for mask effects: These must be preserved always. |
|
299 if (!chainIsFromEffectFw || qobject_cast<HbVgMaskEffect *>(effect) != 0) { |
|
300 newChain->add(effect); |
|
301 } else { |
|
302 delete effect; |
|
303 } |
|
304 } |
|
305 } |
|
306 } |
274 vgEffect()->install(mTargetItem); |
307 vgEffect()->install(mTargetItem); |
275 mVgEffectActivated = true; |
308 mVgEffectActivated = true; |
276 } |
309 } |
277 } |
310 } |
278 |
311 |