src/hbcore/gui/hbmainwindow.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
       
    26 #include "hbmainwindow.h"
       
    27 #include "hbmainwindow_p.h"
       
    28 
    26 #include <QGraphicsView>
    29 #include <QGraphicsView>
    27 #include <QGraphicsWidget>
    30 #include <QGraphicsWidget>
    28 #include <QGraphicsItem>
    31 #include <QGraphicsItem>
    29 #include <QGraphicsScene>
    32 #include <QGraphicsScene>
    30 
    33 
    33 #include "hbdeviceprofile_p.h"
    36 #include "hbdeviceprofile_p.h"
    34 #include "hbindicatorgroup_p.h"
    37 #include "hbindicatorgroup_p.h"
    35 #include "hbinstance.h"
    38 #include "hbinstance.h"
    36 #include "hbinstance_p.h"
    39 #include "hbinstance_p.h"
    37 #include "hbgraphicsscene.h"
    40 #include "hbgraphicsscene.h"
    38 #include "hbmainwindow.h"
       
    39 #include "hbmainwindow_p.h"
       
    40 #include "hbnamespace.h"
    41 #include "hbnamespace.h"
    41 #include "hbnamespace_p.h"
    42 #include "hbnamespace_p.h"
    42 #include "hbtitlebar_p.h"
    43 #include "hbtitlebar_p.h"
    43 #include "hbstatusbar_p.h"
    44 #include "hbstatusbar_p.h"
    44 #include "hbstyle.h"
    45 #include "hbstyle.h"
   206  */
   207  */
   207 
   208 
   208 class HbRootItem : public HbWidget
   209 class HbRootItem : public HbWidget
   209 {
   210 {
   210 public:
   211 public:
   211     explicit  HbRootItem( QGraphicsItem *parent = 0 );
   212     explicit  HbRootItem(QGraphicsItem *parent = 0);
   212     ~HbRootItem() {}
   213     ~HbRootItem() {}
   213 private:
   214 private:
   214     bool event(QEvent *event);
   215     bool event(QEvent *event);
   215 };
   216 };
   216 
   217 
   217 /*!
   218 /*!
   218     Constructs an HbMainWindow object with \a parent.
   219     Constructs an HbMainWindow object with \a parent.
   219     
   220 
   220     \a windowFlags can be used for specifying special functionality to HbMainWindow.
   221     \a windowFlags can be used for specifying special functionality to HbMainWindow.
   221     
   222 
   222     \sa Hb::WindowFlag
   223     \sa Hb::WindowFlag
   223 */
   224 */
   224 HbMainWindow::HbMainWindow(QWidget *parent, Hb::WindowFlags windowFlags):
   225 HbMainWindow::HbMainWindow(QWidget *parent, Hb::WindowFlags windowFlags):
   225         QGraphicsView(parent), d_ptr(new HbMainWindowPrivate)
   226     QGraphicsView(parent), d_ptr(new HbMainWindowPrivate)
   226 {
   227 {
   227     Q_D(HbMainWindow);
   228     Q_D(HbMainWindow);
   228     d->q_ptr = this;
   229     d->q_ptr = this;
   229 
   230 
   230     // No need for any default (e.g. blank white) background for this window.
   231     // No need for any default (e.g. blank white) background for this window.
   262     } else if (HbMainWindowOrientation::instance()->isEnabled()) {
   263     } else if (HbMainWindowOrientation::instance()->isEnabled()) {
   263         d->mOrientation = HbMainWindowOrientation::instance()->sensorOrientation();
   264         d->mOrientation = HbMainWindowOrientation::instance()->sensorOrientation();
   264         d->mAutomaticOrientationSwitch = true;
   265         d->mAutomaticOrientationSwitch = true;
   265     } else {
   266     } else {
   266         d->mOrientation = d->mDefaultOrientation;
   267         d->mOrientation = d->mDefaultOrientation;
   267         d->mAutomaticOrientationSwitch = false; 
   268         d->mAutomaticOrientationSwitch = false;
   268     }
   269     }
   269 
   270 
   270 #if defined(Q_WS_S60) || defined(HB_Q_WS_MAEMO)
   271 #if defined(Q_WS_S60) || defined(HB_Q_WS_MAEMO)
   271     setWindowState(Qt::WindowFullScreen);
   272     setWindowState(Qt::WindowFullScreen);
   272 #endif//Q_WS_S60
   273 #endif//Q_WS_S60
   279     d->mScene = new HbGraphicsScene(this);
   280     d->mScene = new HbGraphicsScene(this);
   280 
   281 
   281     // workaround for problems with BSP tree implementation in Qt
   282     // workaround for problems with BSP tree implementation in Qt
   282     d->mScene->setItemIndexMethod(QGraphicsScene::NoIndex);
   283     d->mScene->setItemIndexMethod(QGraphicsScene::NoIndex);
   283 
   284 
   284     d->mScene->setSceneRect(0, 0, pSize.width(), pSize.height()); 
   285     d->mScene->setSceneRect(0, 0, pSize.width(), pSize.height());
   285     setScene(d->mScene);
   286     setScene(d->mScene);
   286 
   287 
   287     // add root item
   288     // add root item
   288     d->mRootItem = new HbRootItem;
   289     d->mRootItem = new HbRootItem;
   289     d->mRootItem->setZValue(HbPrivate::RootItemZValue);
   290     d->mRootItem->setZValue(HbPrivate::RootItemZValue);
   303     d->mViewStackWidget = new HbContentWidget(this, d->mClippingItem);
   304     d->mViewStackWidget = new HbContentWidget(this, d->mClippingItem);
   304     d->mEffectItem = d->mViewStackWidget;
   305     d->mEffectItem = d->mViewStackWidget;
   305     d->mClippingItem->setStackWidget(d->mViewStackWidget);
   306     d->mClippingItem->setStackWidget(d->mViewStackWidget);
   306     connect(d->mViewStackWidget, SIGNAL(currentChanged(int)),
   307     connect(d->mViewStackWidget, SIGNAL(currentChanged(int)),
   307             this, SLOT(_q_viewChanged()));
   308             this, SLOT(_q_viewChanged()));
   308     connect(d->mViewStackWidget, SIGNAL(widgetRemoved(QGraphicsWidget*)),
   309     connect(d->mViewStackWidget, SIGNAL(widgetRemoved(QGraphicsWidget *)),
   309             this, SLOT(_q_viewRemoved(QGraphicsWidget*)));
   310             this, SLOT(_q_viewRemoved(QGraphicsWidget *)));
   310 
   311 
   311     // create Titlebar (container for indicators, titlepane and secondary softkey
   312     // create Titlebar (container for indicators, titlepane and secondary softkey
   312     d->mTitleBar = new HbTitleBar(this, d->mClippingItem);
   313     d->mTitleBar = new HbTitleBar(this, d->mClippingItem);
   313     d->mTitleBar->setZValue(HbPrivate::TitleBarZValue);
   314     d->mTitleBar->setZValue(HbPrivate::TitleBarZValue);
   314 
   315 
   317     d->mStatusBar->setZValue(HbPrivate::StatusBarZValue);
   318     d->mStatusBar->setZValue(HbPrivate::StatusBarZValue);
   318 
   319 
   319     // At this point the mainwindow is considered more or less fully constructed.
   320     // At this point the mainwindow is considered more or less fully constructed.
   320     HbInstancePrivate::d_ptr()->addWindow(this);
   321     HbInstancePrivate::d_ptr()->addWindow(this);
   321 
   322 
   322     QRectF rect(0,0,pSize.width(),pSize.height());
   323     QRectF rect(0, 0, pSize.width(), pSize.height());
   323     resize(pSize);
   324     resize(pSize);
   324 	d->mLayoutRect = rect;
   325     d->mLayoutRect = rect;
   325     d->mRootItem->setGeometry(rect);
   326     d->mRootItem->setGeometry(rect);
   326     d->mClippingItem->setGeometry(rect);
   327     d->mClippingItem->setGeometry(rect);
   327     setSceneRect(0, 0, pSize.width(), pSize.height());
   328     setSceneRect(0, 0, pSize.width(), pSize.height());
   328     setTransformationAnchor(QGraphicsView::AnchorViewCenter);
   329     setTransformationAnchor(QGraphicsView::AnchorViewCenter);
   329 
   330 
   372 
   373 
   373     HbInstancePrivate::d_ptr()->removeWindow(this);
   374     HbInstancePrivate::d_ptr()->removeWindow(this);
   374     delete d_ptr;
   375     delete d_ptr;
   375 
   376 
   376     // to workaround problem when creating/destroying multiple hbmainwindow's in unit tests (win env)
   377     // to workaround problem when creating/destroying multiple hbmainwindow's in unit tests (win env)
   377     #ifdef Q_OS_WIN
   378 #ifdef Q_OS_WIN
   378         destroy();
   379     destroy();
   379     #endif
   380 #endif
   380 }
   381 }
   381 
   382 
   382 /*!
   383 /*!
   383     Adds a \a widget to the HbMainWindow object. Passing 0 in
   384     Adds a \a widget to the HbMainWindow object. Passing 0 in
   384     \a widget creates an empty HbView.
   385     \a widget creates an empty HbView.
   385 
   386 
   386     The \a widget can be either a HbView or QGraphicsWidget. If it is
   387     The \a widget can be either a HbView or QGraphicsWidget. If it is
   387     the QGraphicsWidget then HbMainWindow will create a HbView and set
   388     a QGraphicsWidget (or any subclass that is not HbView) then
   388     \a widget as the new HbView's content widget.
   389     HbMainWindow will create a HbView and set \a widget as the new
       
   390     HbView's content widget.
       
   391 
       
   392     When \a widget is a HbView, use HbView::setWidget() to set the content
       
   393     widget for the view. Note that you should never attach child items directly
       
   394     to the HbView instance, even though HbView is also a HbWidget. Instead, create
       
   395     a content widget, set it to the view via HbView::setWidget(), and attach children
       
   396     to that.
       
   397 
       
   398     Use setCurrentView() to switch between the added views. (only one of them is visible at a time)
       
   399     The view-specific decorators (toolbar, Options menu, title in the titlebar) and of course
       
   400     the visibility of the view's content widgets will be updated and managed automatically by the framework
       
   401     when switching views.
       
   402 
       
   403     For a detailed description of views see the HbView class.
       
   404     
       
   405     Note that using view switching (i.e. several HbView instances, setCurrentView(), etc.) in
       
   406     Hb applications is not mandatory, it is purely optional. For applications that are not really
       
   407     view based (e.g. because they only have one screen of content or because they have more "fluid" UI where
       
   408     the traditional view separation does not make that much sense) it may sometimes be better (and may provide more freedom)
       
   409     to have just one view and manage the content entirely via the content widget of that one view.
       
   410     (one can still use HbStackedLayout and manual visibility management of child widgets to achieve a traditional view-like look,
       
   411     even when the Hb view management is not used)
       
   412 
       
   413     After calling addView() the caller does not need to care about
       
   414     destroying \a widget, the framework will take care of that by
       
   415     reparenting \a widget if needed.
   389 
   416 
   390     A HbMainWindow should only have one of each view and adding a view
   417     A HbMainWindow should only have one of each view and adding a view
   391     it already has will not cause the same view to be in the
   418     it already has will not cause the same view to be in the
   392     HbMainWindow twice.
   419     HbMainWindow twice.
   393 
   420 
   394     After calling addView() the caller does not need to care about
       
   395     destroying \a widget, the framework will take care of that by
       
   396     reparenting \a widget if needed.
       
   397 
       
   398     \return the new view
   421     \return the new view
   399 
   422 
   400     \sa insertView removeView
   423     \sa insertView() removeView() setCurrentView()
       
   424     \sa HbView HbStackedLayout
   401 */
   425 */
   402 HbView *HbMainWindow::addView(QGraphicsWidget *widget)
   426 HbView *HbMainWindow::addView(QGraphicsWidget *widget)
   403 {
   427 {
   404     Q_D(HbMainWindow);
   428     Q_D(HbMainWindow);
   405     HbView *view = 0;
   429     HbView *view = 0;
   441     \return the new view.
   465     \return the new view.
   442 
   466 
   443     \sa addView removeView
   467     \sa addView removeView
   444 */
   468 */
   445 HbView *HbMainWindow::insertView(int index, QGraphicsWidget *widget)
   469 HbView *HbMainWindow::insertView(int index, QGraphicsWidget *widget)
   446 {    
   470 {
   447     Q_D(HbMainWindow);
   471     Q_D(HbMainWindow);
   448     HbView *view = 0;
   472     HbView *view = 0;
   449     if (!widget) {
   473     if (!widget) {
   450         view = new HbView(d->mViewStackWidget);
   474         view = new HbView(d->mViewStackWidget);
   451     } else {
   475     } else {
   490     HbView *view = qobject_cast<HbView *>(widget);
   514     HbView *view = qobject_cast<HbView *>(widget);
   491     if (view) {
   515     if (view) {
   492         d->mViewStackWidget->removeWidget(view);
   516         d->mViewStackWidget->removeWidget(view);
   493     } else {
   517     } else {
   494         // Check if it is a widget inside a view and delete that view
   518         // Check if it is a widget inside a view and delete that view
   495         for (int n=0; n<d->mViewStackWidget->count(); n++) {
   519         for (int n = 0; n < d->mViewStackWidget->count(); n++) {
   496             HbView *tempView = qobject_cast<HbView*>(d->mViewStackWidget->widgetAt(n));
   520             HbView *tempView = qobject_cast<HbView *>(d->mViewStackWidget->widgetAt(n));
   497             if (tempView->widget() == widget) {
   521             if (tempView->widget() == widget) {
   498                 d->mViewStackWidget->removeWidget(tempView);
   522                 d->mViewStackWidget->removeWidget(tempView);
   499                 // Take a widget out from the view, before deleting it.
   523                 // Take a widget out from the view, before deleting it.
   500                 tempView->takeWidget();
   524                 tempView->takeWidget();
   501                 delete tempView;
   525                 delete tempView;
   573  */
   597  */
   574 QList<HbView *> HbMainWindow::views() const
   598 QList<HbView *> HbMainWindow::views() const
   575 {
   599 {
   576     Q_D(const HbMainWindow);
   600     Q_D(const HbMainWindow);
   577     HbContentWidget *stackWidget = d->mViewStackWidget;
   601     HbContentWidget *stackWidget = d->mViewStackWidget;
   578     
   602 
   579     const int n = stackWidget->count();
   603     const int n = stackWidget->count();
   580     QList<HbView *> result;
   604     QList<HbView *> result;
   581     for ( int i=0; i<n; ++i ) {
   605     for (int i = 0; i < n; ++i) {
   582         HbView *view = qobject_cast<HbView *>(stackWidget->widgetAt(i));
   606         HbView *view = qobject_cast<HbView *>(stackWidget->widgetAt(i));
   583         Q_ASSERT_X(view, "HbMainWindow::views()", "HbView was expected");
   607         Q_ASSERT_X(view, "HbMainWindow::views()", "HbView was expected");
   584         result.append(view);
   608         result.append(view);
   585     }
   609     }
   586     
   610 
   587     return result;
   611     return result;
   588 }
   612 }
   589 
   613 
   590 
   614 
   591 /*!
   615 /*!
   628 {
   652 {
   629     Q_D(HbMainWindow);
   653     Q_D(HbMainWindow);
   630     if (!d->mAutomaticOrientationSwitch) {
   654     if (!d->mAutomaticOrientationSwitch) {
   631         d->mAutomaticOrientationSwitch = true;
   655         d->mAutomaticOrientationSwitch = true;
   632         d->mUserOrientationSwitch = false;
   656         d->mUserOrientationSwitch = false;
   633         if(HbMainWindowOrientation::instance()->isEnabled())
   657         if (HbMainWindowOrientation::instance()->isEnabled()) {
   634             d->setTransformedOrientation(HbMainWindowOrientation::instance()->sensorOrientation(), animate);
   658             d->setTransformedOrientation(HbMainWindowOrientation::instance()->sensorOrientation(), animate);
       
   659         }
   635     }
   660     }
   636 }
   661 }
   637 
   662 
   638 /*!
   663 /*!
   639     Returns empty drawable window.
   664     Returns empty drawable window.
   686 #endif
   711 #endif
   687 }
   712 }
   688 
   713 
   689 /*!
   714 /*!
   690     Returns the rectangle which is used for layouting HbMainWindow contents. Updates on orientation change and is up to date
   715     Returns the rectangle which is used for layouting HbMainWindow contents. Updates on orientation change and is up to date
   691     after HbMainWindow orientationChanged() signal. Note that this is not the same thing as QGraphicsView (HbMainWindow) geometry. 
   716     after HbMainWindow orientationChanged() signal. Note that this is not the same thing as QGraphicsView (HbMainWindow) geometry.
   692     HbMainWindow geometry does not update on orientation change since the contents are only transformed with a rotate transform.
   717     HbMainWindow geometry does not update on orientation change since the contents are only transformed with a rotate transform.
   693     
   718 
   694 */
   719 */
   695 QRectF HbMainWindow::layoutRect() const
   720 QRectF HbMainWindow::layoutRect() const
   696 {
   721 {
   697     Q_D(const HbMainWindow);
   722     Q_D(const HbMainWindow);
   698 	return d->mLayoutRect;
   723     return d->mLayoutRect;
   699 }
   724 }
   700 
   725 
   701 /*!
   726 /*!
   702   Sets the \a name for the background image for the given \a orientation.  If
   727   Sets the \a name for the background image for the given \a orientation.  If
   703   the default image from the theme is suitable then there is no need to call
   728   the default image from the theme is suitable then there is no need to call
   755 }
   780 }
   756 
   781 
   757 /*!
   782 /*!
   758   Sets the animations enabled when the orientation is changed automatically.
   783   Sets the animations enabled when the orientation is changed automatically.
   759   By default animations are enabled.
   784   By default animations are enabled.
   760   
   785 
   761   \sa automaticOrientationEffectEnabled()
   786   \sa automaticOrientationEffectEnabled()
   762  */
   787  */
   763 
   788 
   764 void HbMainWindow::setAutomaticOrientationEffectEnabled(bool enabled)
   789 void HbMainWindow::setAutomaticOrientationEffectEnabled(bool enabled)
   765 {
   790 {
   766     Q_D(HbMainWindow);
   791     Q_D(HbMainWindow);
   767     d->mAutomaticOrientationChangeAnimation = enabled;
   792     d->mAutomaticOrientationChangeAnimation = enabled;
   768 }
   793 }
   769 
   794 
   770 /*!
   795 /*!
   771   Returns boolean value to signify whether animations enabled/disabled during 
   796   Returns boolean value to signify whether animations enabled/disabled during
   772   automatic orientation change. By default animations are enabled.
   797   automatic orientation change. By default animations are enabled.
   773 
   798 
   774   \sa setAutomaticOrientationEffectEnabled()
   799   \sa setAutomaticOrientationEffectEnabled()
   775  */
   800  */
   776 bool HbMainWindow::automaticOrientationEffectEnabled() const
   801 bool HbMainWindow::automaticOrientationEffectEnabled() const
   787     QGraphicsView::changeEvent(event);
   812     QGraphicsView::changeEvent(event);
   788     if (event->type() == QEvent::LayoutDirectionChange) {
   813     if (event->type() == QEvent::LayoutDirectionChange) {
   789         // Notify layout direction change to the icon framework
   814         // Notify layout direction change to the icon framework
   790         HbLayoutDirectionNotifier::instance()->notifyLayoutDirectionChange();
   815         HbLayoutDirectionNotifier::instance()->notifyLayoutDirectionChange();
   791 
   816 
   792         broadcastEvent( HbEvent::WindowLayoutDirectionChanged );
   817         broadcastEvent(HbEvent::WindowLayoutDirectionChanged);
   793 
   818 
   794         foreach (QGraphicsItem *item, items()) {
   819         foreach(QGraphicsItem * item, items()) {
   795             if (item->isWidget() && !item->parentItem() ) {
   820             if (item->isWidget() && !item->parentItem()) {
   796                 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
   821                 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
   797                 if (!widget->testAttribute(Qt::WA_SetLayoutDirection)){
   822                 if (!widget->testAttribute(Qt::WA_SetLayoutDirection)) {
   798                     widget->setLayoutDirection(layoutDirection());
   823                     widget->setLayoutDirection(layoutDirection());
   799                     widget->setAttribute(Qt::WA_SetLayoutDirection, false);
   824                     widget->setAttribute(Qt::WA_SetLayoutDirection, false);
   800                 }
   825                 }
   801             }
   826             }
   802         }
   827         }
   818 void HbMainWindow::keyPressEvent(QKeyEvent *event)
   843 void HbMainWindow::keyPressEvent(QKeyEvent *event)
   819 {
   844 {
   820     // pass the soft key press into the soft key decorator class
   845     // pass the soft key press into the soft key decorator class
   821     HbAction *action = 0;
   846     HbAction *action = 0;
   822 
   847 
   823     switch(event->key()) {
   848     switch (event->key()) {
   824 
   849 
   825 #ifdef Q_OS_SYMBIAN
   850 #ifdef Q_OS_SYMBIAN
   826     case Qt::Key_Context1:
   851     case Qt::Key_Context1:
   827 #else
   852 #else
   828     case Hb::Key_SoftKeyPrimary:
   853     case Hb::Key_SoftKeyPrimary:
   874 */
   899 */
   875 void HbMainWindow::resizeEvent(QResizeEvent *event)
   900 void HbMainWindow::resizeEvent(QResizeEvent *event)
   876 {
   901 {
   877     Q_D(HbMainWindow);
   902     Q_D(HbMainWindow);
   878 
   903 
   879     if ( !HbMainWindowPrivate::dragToResizeEnabled ) {
   904     if (!HbMainWindowPrivate::dragToResizeEnabled) {
   880         // determine the default orientation width < height -> portrait
   905         // determine the default orientation width < height -> portrait
   881         if (event->size().width() < event->size().height())
   906         if (event->size().width() < event->size().height()) {
   882             d->mDefaultOrientation = Qt::Vertical;
   907             d->mDefaultOrientation = Qt::Vertical;
   883         else
   908         } else {
   884             d->mDefaultOrientation = Qt::Horizontal;
   909             d->mDefaultOrientation = Qt::Horizontal;
       
   910         }
   885         d->mForceSetOrientation = true;
   911         d->mForceSetOrientation = true;
   886         d->setTransformedOrientation(d->mOrientation, false);
   912         d->setTransformedOrientation(d->mOrientation, false);
   887         d->mForceSetOrientation = false;
   913         d->mForceSetOrientation = false;
   888     } else {
   914     } else {
   889         // RnD feature for resizing the window by dragging
   915         // RnD feature for resizing the window by dragging
   890         QSize newSize(event->size());
   916         QSize newSize(event->size());
   891         setSceneRect(0,0,newSize.width(),newSize.height());
   917         setSceneRect(0, 0, newSize.width(), newSize.height());
   892         d->mClippingItem->resize(newSize);
   918         d->mClippingItem->resize(newSize);
   893         if (d->mBgItem) {
   919         if (d->mBgItem) {
   894             d->mBgItem->resize(newSize);
   920             d->mBgItem->resize(newSize);
   895         }
   921         }
   896     }
   922     }
   897 }
   923 }
   898 
   924 
   899 /*!
   925 /*!
   900     Reimplemented from QObject::customEvent().
   926     Reimplemented from QObject::customEvent().
   901 */
   927 */
   902 void HbMainWindow::customEvent( QEvent *event )
   928 void HbMainWindow::customEvent(QEvent *event)
   903 {
   929 {
   904     Q_D(HbMainWindow);
   930     Q_D(HbMainWindow);
   905     if (event->type() == HbMainWindowPrivate::IdleEvent) { // called asyncronously after the application start-up
   931     if (event->type() == HbMainWindowPrivate::IdleEvent) { // called asyncronously after the application start-up
   906         if (!d->mIdleEventHandled) {
   932         if (!d->mIdleEventHandled) {
   907             d->mIdleEventHandled = true;
   933             d->mIdleEventHandled = true;
   908             if ( HbFeatureManager::instance()->featureStatus( HbFeatureManager::TheTestUtility ) ) {
   934             if (HbFeatureManager::instance()->featureStatus(HbFeatureManager::TheTestUtility)) {
   909                 // create the test utility
   935                 // create the test utility
   910                 if ( !d->mTheTestUtility ) {
   936                 if (!d->mTheTestUtility) {
   911                     d->mTheTestUtility = new HbTheTestUtility(this);
   937                     d->mTheTestUtility = new HbTheTestUtility(this);
   912                 }
   938                 }
   913             }
   939             }
   914             // get rid of the splash screen widget (it is not visible to the user anyway at this point)
   940             // get rid of the splash screen widget (it is not visible to the user anyway at this point)
   915             HbSplashScreen::destroy();
   941             HbSplashScreen::destroy();
   922 #endif
   948 #endif
   923         }
   949         }
   924         // Notify that mainwindow is (most probably) ready.
   950         // Notify that mainwindow is (most probably) ready.
   925         // The signal must be emitted always, even when there was no need to do anything.
   951         // The signal must be emitted always, even when there was no need to do anything.
   926         emit d->idleEventDispatched();
   952         emit d->idleEventDispatched();
   927     } else if(event->type() == HbMainWindowPrivate::IdleOrientationEvent) { // complete the orientation change effect chain
   953     } else if (event->type() == HbMainWindowPrivate::IdleOrientationEvent) { // complete the orientation change effect chain
   928         if (d->mEffectItem && d->mOrientationChangeOngoing) {
   954         if (d->mEffectItem && d->mOrientationChangeOngoing) {
   929             HbEffect::start(d->mEffectItem, "rootItemFinalPhase", this, "rootItemFinalPhaseDone");
   955             HbEffect::start(d->mEffectItem, "rootItemFinalPhase", this, "rootItemFinalPhaseDone");
   930         }
   956         }
   931     } else if (event->type() == HbMainWindowPrivate::IdleOrientationFinalEvent) {
   957     } else if (event->type() == HbMainWindowPrivate::IdleOrientationFinalEvent) {
   932         if (d->mAnimateOrientationSwitch) {
   958         if (d->mAnimateOrientationSwitch) {
   933             HbEffect::start(d->mTitleBar, "titlebar", "appear_orient");
   959             HbEffect::start(d->mTitleBar, "titlebar", "appear_orient");
   934             HbEffect::start(d->mStatusBar, "statusbar", "appear_orient");
   960             HbEffect::start(d->mStatusBar, "statusbar", "appear_orient");
   935             if (d->mCurrentToolbar) {         
   961             if (d->mCurrentToolbar) {
   936                 HbToolBarPrivate *toolBarD = HbToolBarPrivate::d_ptr(d->mCurrentToolbar);
   962                 HbToolBarPrivate *toolBarD = HbToolBarPrivate::d_ptr(d->mCurrentToolbar);
   937                 toolBarD->startAppearOrientEffect();
   963                 toolBarD->startAppearOrientEffect();
   938             }
   964             } else {
   939             d->mOrientationChangeOngoing = false;
   965                 foreach(HbView * view, views()) {
       
   966                     view->toolBar()->resetTransform();
       
   967                     view->toolBar()->setOpacity(1);
       
   968                     view->toolBar()->show();
       
   969                     HbToolBarPrivate::d_ptr(view->toolBar())->mOrientationEffectsRunning = false;
       
   970                 }
       
   971             }
       
   972             d->updateOrientationChangeStatus();
   940             if (d->mAutomaticOrientationSwitch && HbMainWindowOrientation::instance()->isEnabled()) {
   973             if (d->mAutomaticOrientationSwitch && HbMainWindowOrientation::instance()->isEnabled()) {
   941                 d->setTransformedOrientation(HbMainWindowOrientation::instance()->sensorOrientation(), d->mAnimateOrientationSwitch);
   974                 d->setTransformedOrientation(HbMainWindowOrientation::instance()->sensorOrientation(), d->mAnimateOrientationSwitch);
   942             }
   975             } else if (d->mRequestedOrientation != d->mOrientation) {
   943             else if (d->mRequestedOrientation != d->mOrientation) {
       
   944                 d->setTransformedOrientation(d->mRequestedOrientation, d->mAnimateOrientationSwitch);
   976                 d->setTransformedOrientation(d->mRequestedOrientation, d->mAnimateOrientationSwitch);
   945             }
   977             }
   946         } else {
   978         } else {
   947             // cancel() with clearEffect cannot be used because the effects may have already been canceled.
   979             // cancel() with clearEffect cannot be used because the effects may have already been canceled.
   948             if (d->mTitleBar) {
   980             if (d->mTitleBar) {
  1008 
  1040 
  1009     Visible widgets will receive the event synchronously and invisble widgets
  1041     Visible widgets will receive the event synchronously and invisble widgets
  1010     asynchronously.
  1042     asynchronously.
  1011 
  1043 
  1012     If the receiving widget has abstract items as child items, these will be informed
  1044     If the receiving widget has abstract items as child items, these will be informed
  1013     after the widget has received the event. 
  1045     after the widget has received the event.
  1014 */
  1046 */
  1015 void HbMainWindow::broadcastEvent( int eventType )
  1047 void HbMainWindow::broadcastEvent(int eventType)
  1016 {
  1048 {
  1017     Q_D(HbMainWindow);
  1049     Q_D(HbMainWindow);
  1018     d->broadcastEvent( eventType );
  1050     d->broadcastEvent(eventType);
  1019 }
  1051 }
  1020 
  1052 
  1021 HbRootItem::HbRootItem(QGraphicsItem *parent)
  1053 HbRootItem::HbRootItem(QGraphicsItem *parent)
  1022     : HbWidget(parent)
  1054     : HbWidget(parent)
  1023 {
  1055 {