142 } |
142 } |
143 } |
143 } |
144 return effectTarget; |
144 return effectTarget; |
145 } |
145 } |
146 |
146 |
147 void HbContentWidget::showTargetView() |
147 /*! |
148 { |
148 Callback for 'hide' effect. |
149 targetView->setVisible(true); |
149 */ |
150 } |
|
151 |
|
152 void HbContentWidget::hideEffectFinished(HbEffect::EffectStatus status) |
150 void HbContentWidget::hideEffectFinished(HbEffect::EffectStatus status) |
153 { |
151 { |
154 // Get rid of the old view and make sure the new one is ok in both |
152 // Make sure the old view is hidden. The effect does this too due to |
155 // cases. These need to be done also when the effect is canceled |
153 // HideRegItemBeforeClearingEffect so no matter which comes first (clearing |
156 // otherwise we might end up with a previous view left visible in |
154 // of the effect or this notification), the item is hidden properly before |
157 // the parallel case, etc. |
155 // resetting the transform etc. and thus there is no flicker. |
158 hidingView->setVisible(false); |
156 hidingView->setVisible(false); |
|
157 // Start the "show" phase if not yet started. |
159 if (viewSwitchFlags & Hb::ViewSwitchSequential) { |
158 if (viewSwitchFlags & Hb::ViewSwitchSequential) { |
160 // Don't show targetView yet, make the call async to reduce |
159 // Do not show targetView yet, leave it to the effect in order to |
161 // flickering on certain platforms (e.g. Linux). This is not a |
160 // prevent flickering. |
162 // perfect solution, though. |
|
163 QMetaObject::invokeMethod(this, "showTargetView", Qt::QueuedConnection); |
|
164 if (status.reason != Hb::EffectCancelled) { |
161 if (status.reason != Hb::EffectCancelled) { |
165 runViewSwitchEffectShow(); |
162 runViewSwitchEffectShow(); |
166 } |
163 } else { |
167 } |
164 targetView->setVisible(true); |
168 if (status.reason == Hb::EffectCancelled) { |
165 viewSwitchEffectsFinished(status); |
169 viewSwitchRunning = false; |
166 } |
170 } |
167 } |
171 } |
168 } |
172 |
169 |
|
170 /*! |
|
171 Callback for 'show' effect. |
|
172 */ |
173 void HbContentWidget::viewSwitchEffectsFinished(HbEffect::EffectStatus status) |
173 void HbContentWidget::viewSwitchEffectsFinished(HbEffect::EffectStatus status) |
174 { |
174 { |
175 Q_UNUSED(status); |
175 Q_UNUSED(status); |
|
176 // Do not bother with item visibility here, the effect should manage it |
|
177 // properly because the ShowItemOnFirstUpdate flag was set. |
176 viewSwitchRunning = false; |
178 viewSwitchRunning = false; |
177 if (HbMainWindowPrivate::d_ptr(mainWindow)->mDelayedConstructionHandled) |
179 if (HbMainWindowPrivate::d_ptr(mainWindow)->mDelayedConstructionHandled) { |
178 HbMainWindowPrivate::d_ptr(mainWindow)->_q_viewReady(); |
180 HbMainWindowPrivate::d_ptr(mainWindow)->_q_viewReady(); |
|
181 } |
179 } |
182 } |
180 |
183 |
181 /*! |
184 /*! |
182 Starts the "hide" effect (the first phase of a view switch animation). |
185 Starts the "hide" effect (the first phase of a view switch animation). |
183 */ |
186 */ |
190 |
193 |
191 // Make the new view the current one right away. This must be done asap to prevent |
194 // Make the new view the current one right away. This must be done asap to prevent |
192 // messed up state in mainwindow, the stack widget, etc. due to events coming during |
195 // messed up state in mainwindow, the stack widget, etc. due to events coming during |
193 // the view switch animation. |
196 // the view switch animation. |
194 // 2nd param (hideOld): We still want to see the old view (normally setCurrentWidget would hide it). |
197 // 2nd param (hideOld): We still want to see the old view (normally setCurrentWidget would hide it). |
195 // 3rd param (showNew): The new view is not yet needed in the sequential case. |
198 // 3rd param (showNew): The new view is not yet needed (the effect will take care of making it visible). |
196 setCurrentWidget(targetView, false, !(flags & Hb::ViewSwitchSequential)); |
199 setCurrentWidget(targetView, false, false); |
197 |
200 |
198 hidingView = viewToHide; |
201 hidingView = viewToHide; |
199 viewSwitchFlags = flags; |
202 viewSwitchFlags = flags; |
200 |
203 |
201 QGraphicsWidget *effectTarget = getEffectTarget(viewToHide, flags); |
204 QGraphicsWidget *effectTarget = getEffectTarget(viewToHide, flags); |
202 if (effectTarget) { |
205 if (effectTarget) { |
203 QString event = getEffectEvent("hide", flags, viewToHide, targetView); |
206 QString event = getEffectEvent("hide", flags, viewToHide, targetView); |
204 // The effect must not be persistent so pass 'true' as 3rd param (hideWhenFinished) to start(). |
207 HbEffectInternal::EffectFlags effectFlags = |
205 HbEffectInternal::start(viewToHide, effectTarget, true, "HB_view", event, this, "hideEffectFinished"); |
208 HbEffectInternal::ClearEffectWhenFinished // the effect must not be persistent |
|
209 | HbEffectInternal::HideRegItemBeforeClearingEffect; // to prevent unlikely, but possible flicker |
|
210 HbEffectInternal::start(viewToHide, effectTarget, effectFlags, |
|
211 "HB_view", event, this, "hideEffectFinished"); |
206 if (!(flags & Hb::ViewSwitchSequential)) { |
212 if (!(flags & Hb::ViewSwitchSequential)) { |
207 runViewSwitchEffectShow(); |
213 runViewSwitchEffectShow(); |
208 } |
214 } |
209 } |
215 } |
210 } |
216 } |
216 void HbContentWidget::runViewSwitchEffectShow() |
222 void HbContentWidget::runViewSwitchEffectShow() |
217 { |
223 { |
218 QGraphicsWidget *effectTarget = getEffectTarget(targetView, viewSwitchFlags); |
224 QGraphicsWidget *effectTarget = getEffectTarget(targetView, viewSwitchFlags); |
219 if (effectTarget) { |
225 if (effectTarget) { |
220 QString event = getEffectEvent("show", viewSwitchFlags, hidingView, targetView); |
226 QString event = getEffectEvent("show", viewSwitchFlags, hidingView, targetView); |
221 HbEffectInternal::start(targetView, effectTarget, true, "HB_view", event, this, "viewSwitchEffectsFinished"); |
227 HbEffectInternal::EffectFlags effectFlags = |
|
228 HbEffectInternal::ClearEffectWhenFinished |
|
229 | HbEffectInternal::ShowItemOnFirstUpdate; // because targetView is not yet visible |
|
230 HbEffectInternal::start(targetView, effectTarget, effectFlags, |
|
231 "HB_view", event, this, "viewSwitchEffectsFinished"); |
222 } |
232 } |
223 } |
233 } |
224 |
234 |
225 void HbContentWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) |
235 void HbContentWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) |
226 { |
236 { |