40 switch effects and other features. |
40 switch effects and other features. |
41 |
41 |
42 \internal |
42 \internal |
43 */ |
43 */ |
44 |
44 |
45 HbContentWidget::HbContentWidget(HbMainWindow *mainWindow,QGraphicsItem *parent /*= 0*/): |
45 HbContentWidget::HbContentWidget(HbMainWindow *mainWindow, QGraphicsItem *parent /*= 0*/): |
46 HbStackedWidget(parent), |
46 HbStackedWidget(parent), |
47 mViewSwitchRunning(false), |
47 mViewSwitchRunning(false), |
48 mTargetView(0), |
48 mTargetView(0), |
49 mHidingView(0), |
49 mHidingView(0), |
50 mMainWindow(mainWindow) |
50 mMainWindow(mainWindow) |
51 { |
51 { |
|
52 // Do not defer this, it causes invalidation and updating. |
|
53 setFocusPolicy(Qt::StrongFocus); |
52 } |
54 } |
53 |
55 |
54 QSizeF HbContentWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
56 QSizeF HbContentWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
55 { |
57 { |
56 Q_UNUSED(constraint); |
58 Q_UNUSED(constraint); |
57 |
59 |
58 QSizeF size; |
60 QSizeF size; |
59 |
61 |
60 switch (which) { |
62 switch (which) { |
61 case Qt::MinimumSize: |
63 case Qt::MinimumSize: |
62 size = QSizeF(0, 0); |
64 size = QSizeF(0, 0); |
63 break; |
65 break; |
64 |
66 |
65 case Qt::PreferredSize: |
67 case Qt::PreferredSize: { |
66 { |
|
67 HbDeviceProfile profile(HbDeviceProfile::profile(this)); |
68 HbDeviceProfile profile(HbDeviceProfile::profile(this)); |
68 size = profile.logicalSize(); |
69 size = profile.logicalSize(); |
69 if (!size.isValid()) { |
70 if (!size.isValid()) { |
70 size = QSizeF(1000, 1000); |
71 size = QSizeF(1000, 1000); |
71 } |
72 } |
198 // messed up state in mainwindow, the stack widget, etc. due to events coming during |
194 // messed up state in mainwindow, the stack widget, etc. due to events coming during |
199 // the view switch animation. |
195 // the view switch animation. |
200 // 2nd param (hideOld): We still want to see the old view (normally setCurrentWidget would hide it). |
196 // 2nd param (hideOld): We still want to see the old view (normally setCurrentWidget would hide it). |
201 // 3rd param (showNew): The new view is not yet needed (the effect will take care of making it visible). |
197 // 3rd param (showNew): The new view is not yet needed (the effect will take care of making it visible). |
202 setCurrentWidget(mTargetView, false, false); |
198 setCurrentWidget(mTargetView, false, false); |
203 |
199 |
204 mHidingView = viewToHide; |
200 mHidingView = viewToHide; |
205 mViewSwitchFlags = flags; |
201 mViewSwitchFlags = flags; |
206 |
202 |
207 QGraphicsWidget *effectTarget = getEffectTarget(viewToHide, flags); |
203 QGraphicsWidget *effectTarget = getEffectTarget(viewToHide, flags); |
208 if (effectTarget) { |
204 if (effectTarget) { |
209 mMainWindow->setInteractive(false); // disable input while the effects are running |
205 mMainWindow->setInteractive(false); // disable input while the effects are running |
210 QString event = getEffectEvent("hide", flags, viewToHide, mTargetView); |
206 QString event = getEffectEvent("hide", flags, viewToHide, mTargetView); |
211 HbEffectInternal::EffectFlags effectFlags = |
207 HbEffectInternal::EffectFlags effectFlags = |
212 HbEffectInternal::ClearEffectWhenFinished // the effect must not be persistent |
208 HbEffectInternal::ClearEffectWhenFinished // the effect must not be persistent |
213 | HbEffectInternal::HideRegItemBeforeClearingEffect; // to prevent unlikely, but possible flicker |
209 | HbEffectInternal::HideRegItemBeforeClearingEffect; // to prevent unlikely, but possible flicker |
214 HbEffectInternal::start(viewToHide, effectTarget, effectFlags, |
210 HbEffectInternal::start(viewToHide, effectTarget, effectFlags, |
215 "HB_view", event, this, "hideEffectFinished"); |
211 "HB_view", event, this, "hideEffectFinished"); |
216 if (!(flags & Hb::ViewSwitchSequential)) { |
212 if (!(flags & Hb::ViewSwitchSequential)) { |