src/hbcore/gui/hbview.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
    36 #include "hbtitlebar_p.h"
    36 #include "hbtitlebar_p.h"
    37 #include "hbstatusbar_p.h"
    37 #include "hbstatusbar_p.h"
    38 #include "hbscreen_p.h"
    38 #include "hbscreen_p.h"
    39 #include "hbviewactionmanager_p.h"
    39 #include "hbviewactionmanager_p.h"
    40 #include "hbglobal_p.h"
    40 #include "hbglobal_p.h"
       
    41 #include "hbevent.h"
    41 #include <QPointer>
    42 #include <QPointer>
    42 
    43 
    43 /*!
    44 /*!
    44     @stable
    45     @stable
    45     @hbcore
    46     @hbcore
   738     }
   739     }
   739     Q_D(HbView);
   740     Q_D(HbView);
   740     HbView::HbViewFlags originalFlags(d->mViewFlags);
   741     HbView::HbViewFlags originalFlags(d->mViewFlags);
   741     d->mViewFlags = flags;
   742     d->mViewFlags = flags;
   742     if (mainWindow()) {
   743     if (mainWindow()) {
   743 
   744         bool isCurrentView(mainWindow()->currentView() == this);
   744         // Statusbar-animation
   745         if (isCurrentView) {
   745         bool statusBarAnimating = false;
   746             // Statusbar-animation
   746         HbStatusBar *statusBar = HbMainWindowPrivate::d_ptr(mainWindow())->mStatusBar;
   747             bool statusBarAnimating = false;
   747         if ((d->mViewFlags & HbView::ViewStatusBarHidden) && !(originalFlags & HbView::ViewStatusBarHidden)) {
   748             HbStatusBar *statusBar = HbMainWindowPrivate::d_ptr(mainWindow())->mStatusBar;
       
   749             if ((d->mViewFlags & HbView::ViewStatusBarHidden) && !(originalFlags & HbView::ViewStatusBarHidden)) {
   748 #ifdef HB_EFFECTS
   750 #ifdef HB_EFFECTS
   749             HbEffect::start(statusBar, "statusbar", "disappear", this, "statusBarEffectFinished");
   751             HbEffect::start(statusBar, "statusbar", "disappear", this, "statusBarEffectFinished");
   750 #endif // HB_EFFECTS
   752 #endif // HB_EFFECTS
   751             statusBarAnimating = true;
   753             statusBarAnimating = true;
   752         } else if (!(d->mViewFlags & HbView::ViewStatusBarHidden) && (originalFlags & HbView::ViewStatusBarHidden)) {
   754         } else if (!(d->mViewFlags & HbView::ViewStatusBarHidden) && (originalFlags & HbView::ViewStatusBarHidden)) {
   753 #ifdef HB_EFFECTS
   755 #ifdef HB_EFFECTS
   754             statusBar->setVisible(true);
   756             statusBar->setVisible(true);
   755             HbEffect::start(statusBar, "statusbar", "appear", this, "statusBarEffectFinished");
   757             HbEffect::start(statusBar, "statusbar", "appear", this, "statusBarEffectFinished");
   756 #endif // HB_EFFECTS
   758 #endif // HB_EFFECTS
   757             statusBarAnimating = true;
   759             statusBarAnimating = true;
   758         }
   760             }
   759 
   761 
   760         // Titlebar-animation
   762             // Titlebar-animation
   761         bool titleBarAnimating = false;
   763             bool titleBarAnimating = false;
   762         HbTitleBar *titleBar = HbMainWindowPrivate::d_ptr(mainWindow())->mTitleBar;
   764             HbTitleBar *titleBar = HbMainWindowPrivate::d_ptr(mainWindow())->mTitleBar;
   763         if ((d->mViewFlags & HbView::ViewTitleBarHidden) && !(originalFlags & HbView::ViewTitleBarHidden)) {
   765             if ((d->mViewFlags & HbView::ViewTitleBarHidden) && !(originalFlags & HbView::ViewTitleBarHidden)) {
   764 #ifdef HB_EFFECTS
   766 #ifdef HB_EFFECTS
   765             HbEffect::start(titleBar, "titlebar", "disappear", this, "titleBarEffectFinished");
   767                 HbEffect::start(titleBar, "titlebar", "disappear", this, "titleBarEffectFinished");
   766 #endif // HB_EFFECTS
   768 #endif // HB_EFFECTS
   767             titleBarAnimating = true;
   769                 titleBarAnimating = true;
   768         } else if (!(d->mViewFlags & HbView::ViewTitleBarHidden) && (originalFlags & HbView::ViewTitleBarHidden)) {
   770             } else if (!(d->mViewFlags & HbView::ViewTitleBarHidden) && (originalFlags & HbView::ViewTitleBarHidden)) {
   769 #ifdef HB_EFFECTS
   771 #ifdef HB_EFFECTS
   770             titleBar->setVisible(true);
   772                 titleBar->setVisible(true);
   771             HbEffect::start(titleBar, "titlebar", "appear", this, "titleBarEffectFinished");
   773                 HbEffect::start(titleBar, "titlebar", "appear", this, "titleBarEffectFinished");
   772 #endif // HB_EFFECTS
   774 #endif // HB_EFFECTS
   773             titleBarAnimating = true;
   775                 titleBarAnimating = true;
   774         }
       
   775 
       
   776         if (!statusBarAnimating && !titleBarAnimating) {
       
   777             statusBar->setVisible(!(d->mViewFlags & HbView::ViewStatusBarHidden));
       
   778             statusBar->propertiesChanged();
       
   779         }
       
   780         if (!titleBarAnimating && !statusBarAnimating) {
       
   781             titleBar->setVisible(!(d->mViewFlags & HbView::ViewTitleBarHidden));
       
   782             if (d->mNavigationActionSet) {
       
   783                 titleBar->setNavigationAction(d->mNavigationAction);
       
   784             } else {
       
   785                 titleBar->setDefaultNavigationAction();
       
   786             }
   776             }
   787             titleBar->propertiesChanged();
   777 
       
   778             if (!statusBarAnimating && !titleBarAnimating) {
       
   779                 statusBar->setVisible(!(d->mViewFlags & HbView::ViewStatusBarHidden));
       
   780                 statusBar->propertiesChanged();
       
   781             }
       
   782             if (!titleBarAnimating && !statusBarAnimating) {
       
   783                 titleBar->setVisible(!(d->mViewFlags & HbView::ViewTitleBarHidden));
       
   784                 if (d->mNavigationActionSet) {
       
   785                     titleBar->setNavigationAction(d->mNavigationAction);
       
   786                 } else {
       
   787                     titleBar->setDefaultNavigationAction();
       
   788                 }
       
   789                 titleBar->propertiesChanged();
       
   790             }
   788         }
   791         }
   789         if (d->toolBar) {
   792         if (d->toolBar) {
   790             d->toolBar->updatePrimitives();
   793             d->toolBar->updatePrimitives();
   791         }
   794         }
   792 
   795 
   810 
   813 
   811         // Repolish the screen if needed
   814         // Repolish the screen if needed
   812         int visibilityFlags = HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating
   815         int visibilityFlags = HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating
   813                               | HbView::ViewTitleBarMinimizable | HbView::ViewStatusBarHidden | HbView::ViewStatusBarFloating
   816                               | HbView::ViewTitleBarMinimizable | HbView::ViewStatusBarHidden | HbView::ViewStatusBarFloating
   814                               | HbView::ViewTitleBarHidden | HbView::ViewDisableRelayout;
   817                               | HbView::ViewTitleBarHidden | HbView::ViewDisableRelayout;
   815         if ((d->mViewFlags & visibilityFlags) != (originalFlags & visibilityFlags)) {
   818         if (isCurrentView && (d->mViewFlags & visibilityFlags) != (originalFlags & visibilityFlags)) {
   816             HbMainWindowPrivate::d_ptr(mainWindow())->mClippingItem->decoratorVisibilityChanged();
   819             HbMainWindowPrivate::d_ptr(mainWindow())->mClippingItem->decoratorVisibilityChanged();
   817         }
   820         }
   818     }
   821     }
   819 }
   822 }
   820 
   823 
   909 /*!
   912 /*!
   910     \reimp
   913     \reimp
   911  */
   914  */
   912 void HbView::changeEvent(QEvent *event)
   915 void HbView::changeEvent(QEvent *event)
   913 {
   916 {
       
   917     Q_D(const HbView);
   914 
   918 
   915     // We're listening for layout direction changes, because the screen needs to be
   919     // We're listening for layout direction changes, because the screen needs to be
   916     // repolished, if the layout direction changes and the titlebar is minimizable.
   920     // repolished, if the layout direction changes and the titlebar is minimizable.
   917     // We have to listen to the event here(and not in the titlebar), cause the layout
   921     // We have to listen to the event here(and not in the titlebar), cause the layout
   918     // direction change event is delivered to the titlebar (cause it does not mirror)
   922     // direction change event is delivered to the titlebar (cause it does not mirror)
   921             && (viewFlags() & ViewTitleBarMinimizable)) {
   925             && (viewFlags() & ViewTitleBarMinimizable)) {
   922         HbMainWindow *mw = mainWindow();
   926         HbMainWindow *mw = mainWindow();
   923         if (mw && mw->currentView() == this) {
   927         if (mw && mw->currentView() == this) {
   924             HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged();
   928             HbMainWindowPrivate::d_ptr(mw)->mClippingItem->decoratorVisibilityChanged();
   925         }
   929         }
       
   930     } else if(event->type() == HbEvent::ThemeChanged) {
       
   931         HbMainWindow *mw = mainWindow();
       
   932         if (d->toolBar && mw && mw->currentView() != this) {
       
   933             d->toolBar->changeEvent(event);
       
   934         }
   926     }
   935     }
   927 
   936 
   928     HbWidget::changeEvent(event);
   937     HbWidget::changeEvent(event);
   929 }
   938 }
   930 
   939