src/hbcore/gui/hbcontentwidget.cpp
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 7 923ff622b8b9
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
9:730c025d4b77 15:f378acbc9cfb
    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         }
    77         size = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
    78         size = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
    78         break;
    79         break;
    79     }
    80     }
    80 
    81 
    81     return size;
    82     return size;
    82 }
       
    83 
       
    84 void HbContentWidget::delayedConstruction()
       
    85 {
       
    86     setFocusPolicy(Qt::StrongFocus);
       
    87 }
    83 }
    88 
    84 
    89 void HbContentWidget::setTargetView(HbView *view)
    85 void HbContentWidget::setTargetView(HbView *view)
    90 {
    86 {
    91     mTargetView = view;
    87     mTargetView = view;
   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)) {