src/hbcore/gui/hbscreen.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
child 6 c3690ec91ef8
--- a/src/hbcore/gui/hbscreen.cpp	Thu May 27 13:10:59 2010 +0300
+++ b/src/hbcore/gui/hbscreen.cpp	Fri Jun 11 13:58:22 2010 +0300
@@ -46,8 +46,8 @@
   \internal
 */
 
-HbScreen::HbScreen() : 
-    HbWidget(), 
+HbScreen::HbScreen() :
+    HbWidget(),
     mStack(0),
     mTb(0),
     mDock(0),
@@ -57,14 +57,14 @@
 {
 }
 
-void HbScreen::setStackWidget(HbContentWidget *stack) 
+void HbScreen::setStackWidget(HbContentWidget *stack)
 {
     if (mStack != stack) {
         if (mStack) {
             HbStyle::setItemName(mTb, QString());
             HbStyle::setItemName(mDock, QString());
         }
-        mStack = stack; 
+        mStack = stack;
     }
 }
 
@@ -75,10 +75,10 @@
             disconnect(&HbToolBarPrivate::d_ptr(mTb)->core, 0, this, 0);
             HbStyle::setItemName(mTb, QString());
         }
-        mTb = tb; 
+        mTb = tb;
         if (mTb) {
-            setToolBarOrientation(mTb->orientation()); 
-            if (mDelayedConstructionHandled){
+            setToolBarOrientation(mTb->orientation());
+            if (mDelayedConstructionHandled) {
                 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(orientationChanged()), this, SLOT(toolBarOrientationChanged()));
                 connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged()));
             }
@@ -95,7 +95,7 @@
             disconnect(&HbDockWidgetPrivate::d_ptr(mDock)->core, 0, this, 0);
             HbStyle::setItemName(mDock, QString());
         }
-        mDock = dock; 
+        mDock = dock;
         if (mDock && mDelayedConstructionHandled) {
             connect(&HbDockWidgetPrivate::d_ptr(mDock)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged()));
         }
@@ -117,13 +117,12 @@
     //avoid unnecessary complications in setName function.
     if ((mTb->isVisible() || forced) && mTb->actions().count()) {
         HbStyle::setItemName(mTb, "toolbar");
-    }
-    else {
+    } else {
         HbStyle::setItemName(mTb, QString());
     }
 }
 
-void HbScreen::polish(HbStyleParameters& params)
+void HbScreen::polish(HbStyleParameters &params)
 {
     if (!mScreenPolished) {
         mScreenOrientation = mainWindow()->orientation();
@@ -131,10 +130,10 @@
     }
 
     if (mStack) {
-        HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget());
+        HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget());
         if (currentView && currentView->isContentFullScreen()) {
             setName(mStack, "mainfull");
-        } else { 
+        } else {
             setName(mStack, "main");
         }
     }
@@ -145,7 +144,7 @@
     }
 
     if (mDock) {
-        setName(mDock,"dock");
+        setName(mDock, "dock");
     }
 
     mScreenPolished = true;
@@ -158,17 +157,18 @@
         layout()->activate();
     }
     HbMainWindow *w = mainWindow();
-    HbMainWindowPrivate::d_ptr(w)->postIdleEvent(HbMainWindowPrivate::IdleOrientationEvent);   
+    HbMainWindowPrivate::d_ptr(w)->postIdleEvent(HbMainWindowPrivate::IdleOrientationEvent);
 }
 
 void HbScreen::delayedConstruction()
 {
-    if (mDelayedConstructionHandled)
+    if (mDelayedConstructionHandled) {
         return;
+    }
     mDelayedConstructionHandled = true;
     if (mTb) {
-        connect( &HbToolBarPrivate::d_ptr ( mTb )->core, SIGNAL(orientationChanged()), this, SLOT(toolBarOrientationChanged()));
-        connect( &HbToolBarPrivate::d_ptr ( mTb )->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged()));
+        connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(orientationChanged()), this, SLOT(toolBarOrientationChanged()));
+        connect(&HbToolBarPrivate::d_ptr(mTb)->core, SIGNAL(visibilityChanged()), this, SLOT(decoratorVisibilityChanged()));
         HbToolBarPrivate::d_ptr(mTb)->delayedConstruction();
     }
     if (mDock) {
@@ -176,7 +176,7 @@
     }
 }
 
-void HbScreen::setGeometry (const QRectF & rect)
+void HbScreen::setGeometry(const QRectF &rect)
 {
     prepareGeometryChange();
     HbWidget::setGeometry(rect);
@@ -197,11 +197,12 @@
 {
     bool contentUnderTitleBar = false;
     if (mStack) {
-        HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget());
-        if (currentView && (currentView->viewFlags() 
-                            & (HbView::ViewTitleBarMinimized | HbView::ViewTitleBarFloating 
-                            | HbView::ViewTitleBarHidden))) {
-            contentUnderTitleBar = true;
+        HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget());
+        if (currentView && !(currentView->viewFlags() & HbView::ViewDisableRelayout)) {
+            if (currentView->viewFlags() & (HbView::ViewTitleBarMinimized
+                                            | HbView::ViewTitleBarFloating | HbView::ViewTitleBarHidden)) {
+                contentUnderTitleBar = true;
+            }
         }
     }
     return contentUnderTitleBar;
@@ -211,10 +212,12 @@
 {
     bool contentUnderStatusBar = false;
     if (mStack) {
-        HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget());
-        if (currentView && (currentView->viewFlags() 
-                            & (HbView::ViewStatusBarFloating | HbView::ViewStatusBarHidden))) {
-            contentUnderStatusBar = true;
+        HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget());
+        if (currentView && !(currentView->viewFlags() & HbView::ViewDisableRelayout)) {
+            if (currentView->viewFlags() & (HbView::ViewStatusBarFloating
+                                            | HbView::ViewStatusBarHidden)) {
+                contentUnderStatusBar = true;
+            }
         }
     }
     return contentUnderStatusBar;
@@ -224,7 +227,7 @@
 {
     bool titleBarMinimizable = false;
     if (mStack) {
-        HbView *currentView = qobject_cast<HbView*>(mStack->currentWidget());
+        HbView *currentView = qobject_cast<HbView *>(mStack->currentWidget());
         if (currentView && (currentView->viewFlags() & (HbView::ViewTitleBarMinimizable))) {
             titleBarMinimizable = true;
         }
@@ -249,7 +252,7 @@
 void HbScreen::setToolBarOrientation(Qt::Orientation orientation)
 {
     if (orientation != mToolBarOrientation) {
-        if (mTb){
+        if (mTb) {
             HbToolBarPrivate::d_ptr(mTb)->mDoLayout = false;
             repolish();
         }
@@ -259,6 +262,12 @@
 
 void HbScreen::decoratorVisibilityChanged()
 {
+    HbMainWindow *window = mainWindow();
+    // Do not repolish if orientation is about to change
+    if (window && HbMainWindowPrivate::d_ptr(window)->mOrientationChangeOngoing
+            && mScreenOrientation != HbMainWindowPrivate::d_ptr(window)->mOrientation) {
+        return;
+    }
     if (mTb) {
         HbToolBarPrivate::d_ptr(mTb)->mDoLayout = false;
     }
@@ -266,7 +275,7 @@
     QCoreApplication::sendPostedEvents(this, QEvent::Polish);
 }
 
-void HbScreen::currentViewChanged(HbView* view)
+void HbScreen::currentViewChanged(HbView *view)
 {
     Q_UNUSED(view);
     repolish();
@@ -275,7 +284,7 @@
 bool HbScreen::event(QEvent *e)
 {
     if (e->type() == HbEvent::DeviceProfileChanged) {
-        // supress polishEvent() [which is called in HbWidget::event()] into repolish()
+        // suppress polishEvent() [which is called in HbWidget::event()] into repolish()
         repolish();
         return QGraphicsWidget::event(e);
     } else {