diff -r 923ff622b8b9 -r 4633027730f5 src/hbcore/gui/hbmainwindow.cpp --- a/src/hbcore/gui/hbmainwindow.cpp Tue Jul 06 14:36:53 2010 +0300 +++ b/src/hbcore/gui/hbmainwindow.cpp Wed Aug 18 10:05:37 2010 +0300 @@ -30,9 +30,10 @@ #include #include #include - +#include #include "hbaction.h" #include "hbbackgrounditem_p.h" +#include "hbscreenshotitem_p.h" #include "hbdeviceprofile_p.h" #include "hbindicatorgroup_p.h" #include "hbinstance.h" @@ -63,6 +64,7 @@ #include "hboogmwatcher_p.h" #include "hbwindowobscured_p.h" #include "hbsleepmodelistener_p.h" +#include "hbforegroundwatcher_p.h" #ifdef Q_OS_SYMBIAN #include @@ -287,6 +289,7 @@ // No need for any default (e.g. blank white) background for this window. setAttribute(Qt::WA_NoSystemBackground); + viewport()->setAttribute(Qt::WA_NoSystemBackground); setOptimizationFlag(QGraphicsView::DontSavePainterState); // Continue with basic initialization. Note: Prefer doing everything that is @@ -326,9 +329,9 @@ d->mAutomaticOrientationSwitch = false; } -#if defined(Q_WS_S60) || defined(HB_Q_WS_MAEMO) +#if defined(Q_OS_SYMBIAN) || defined(HB_Q_WS_MAEMO) setWindowState(Qt::WindowFullScreen); -#endif//Q_WS_S60 +#endif setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -355,6 +358,8 @@ // add clipping item d->mClippingItem = new HbScreen; + //makes sure clipiingItem layout is activated before any of its childitems. + QApplication::postEvent(d->mClippingItem, new QEvent(QEvent::LayoutRequest)); d->mClippingItem->setParentItem(d->mRootItem); d->mClippingItem->setZValue(HbPrivate::ContentZValue); @@ -398,6 +403,9 @@ // Make sure the sleep mode listener instance is created. HbSleepModeListener::instance(); + // Have also the foregroundwatcher up and running. + HbForegroundWatcher::instance(); + HbWindowObscured::installWindowEventFilter(); #ifdef HB_GESTURE_FW @@ -631,6 +639,9 @@ // Switching to null view or to the one that is current will do nothing. if (view && oldView != view) { emit aboutToChangeView(oldView, view); + if (isObscured()) { + animate = false; + } if (oldView && animate) { if (flags & Hb::ViewSwitchFullScreen) { flags |= Hb::ViewSwitchSequential; @@ -939,6 +950,21 @@ event->accept(); break; +#ifdef __WINSCW__ + // Support for testing orientation change on the winscw emulator: When enabled, + // pressing '9' will toggle (and force) the orientation. + case Qt::Key_9: + if (QFile::exists("c:/resource/hb_ori_simu")) { + if (orientation() == Qt::Horizontal) { + setOrientation(Qt::Vertical); + } else { + setOrientation(Qt::Horizontal); + } + } + QGraphicsView::keyPressEvent(event); + break; +#endif + default: QGraphicsView::keyPressEvent(event); break; @@ -982,6 +1008,9 @@ if (d->mBgItem) { d->mBgItem->resize(newSize); } + if (d->mScreenshotItem) { + d->mScreenshotItem->resize(newSize); + } } } @@ -1080,8 +1109,13 @@ // Enable surface transparency if QWidget did not do it already. This is a // workaround for having non-transparent surfaces filled automatically with // black color. The showEvent is a suitable place because the native control - // is already created at this point, but it is not too late either. + // is already created at this point, but it is not too late either. Note + // that while this is meant to be a workaround, the system transition + // effects may actually rely on (and require) this behavior. if (!testAttribute(Qt::WA_TranslucentBackground)) { + // The Qt::WA_TranslucentBackground attribute cannot be used here + // because that can only be enabled, disabling does not seem to be + // supported. RWindow *const window = static_cast(effectiveWinId()->DrawableWindow()); window->SetSurfaceTransparency(true); } @@ -1096,7 +1130,7 @@ } /*! - Reimplemented from QAbstractScrollArea::scrollContentsBy(). + \reimp */ void HbMainWindow::scrollContentsBy(int dx, int dy) { @@ -1131,7 +1165,7 @@ } /* - // reimplemented from QWidget + \reimp */ bool HbMainWindow::event(QEvent *event) { @@ -1143,6 +1177,26 @@ return QGraphicsView::event(event); } +/* + \reimp +*/ +void HbMainWindow::drawBackground(QPainter *painter, const QRectF &rect) +{ + QGraphicsView::drawBackground(painter, rect); + // The background item's paint() does not get called automatically so call + // it directly and optimize it by setting a proper clipping rectangle. + Q_D(HbMainWindow); + if (d->mBgItem) { + // No need to save/restore the painter state here. + if (d->mBgItem->imageMode() != Hb::DoNotDrawBackground && + (!qFuzzyCompare(rect.height(), d->mBgItem->boundingRect().height()) || + !qFuzzyCompare(rect.width(), d->mBgItem->boundingRect().width()))) { + painter->setClipRect(rect, Qt::ReplaceClip); + } + d->mBgItem->paint(painter, 0, 0); + } +} + HbRootItem::HbRootItem(QGraphicsItem *parent) : HbWidget(parent) {