diff options
author | Daniel d'Andrada <daniel.dandrada@nokia.com> | 2010-03-16 16:53:48 +0200 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@nokia.com> | 2010-03-16 17:01:27 +0200 |
commit | 6242b607b7126dccc7fb6eaadd55d2893e0b136b (patch) | |
tree | 9356efe62850e878e315f6eba61dc18430de6444 | |
parent | d0f5270ad7ecc432fa8069e8ab7c051738be6970 (diff) |
Changes: DuiWindow no longer gets in-scene status bar
RevBy: TrustMe
Details: Now only DuiApplicationWindow have the in-scene status bar.
DuiWindow will still be resized and put below the sepatate status bar
top level window like before.
This is because several clients rely on a bare bones DuiWindow which does
not have a scene or a scene manager. Having an in-scene status bar also
brings along with it a scene manager and a scene.
-rw-r--r-- | src/widgets/duiapplicationwindow.cpp | 94 | ||||
-rw-r--r-- | src/widgets/duiapplicationwindow_p.h | 4 | ||||
-rw-r--r-- | src/widgets/duiwindow.cpp | 66 | ||||
-rw-r--r-- | src/widgets/duiwindow.h | 2 | ||||
-rw-r--r-- | src/widgets/duiwindow_p.h | 7 |
5 files changed, 70 insertions, 103 deletions
diff --git a/src/widgets/duiapplicationwindow.cpp b/src/widgets/duiapplicationwindow.cpp index 8d3de832..536c74d0 100644 --- a/src/widgets/duiapplicationwindow.cpp +++ b/src/widgets/duiapplicationwindow.cpp @@ -40,12 +40,19 @@ #include "duiscenemanager.h" #include "duiapplication_p.h" #include "duiscene.h" +#include "duistatusbar.h" #include <QList> #include <QEvent> #include <QRectF> #include <QActionEvent> +#ifdef Q_WS_X11 +# include <QX11Info> +# include <X11/Xatom.h> +# include <X11/Xlib.h> +#endif + DuiApplicationWindowPrivate::DuiApplicationWindowPrivate() : DuiWindowPrivate() , page(NULL) @@ -55,6 +62,8 @@ DuiApplicationWindowPrivate::DuiApplicationWindowPrivate() , homeButtonPanel(new DuiHomeButtonPanel) , escapeButtonPanel(new DuiEscapeButtonPanel) , menu(new DuiApplicationMenu) + , statusBar(new DuiStatusBar) + , showingStatusBar(false) { } @@ -72,6 +81,11 @@ DuiApplicationWindowPrivate::~DuiApplicationWindowPrivate() homeButtonPanel = 0; delete escapeButtonPanel; escapeButtonPanel = 0; + + if (statusBar) { + delete statusBar; + statusBar = 0; + } } void DuiApplicationWindowPrivate::init() @@ -86,6 +100,10 @@ void DuiApplicationWindowPrivate::init() q->connect(q, SIGNAL(orientationChanged(Dui::Orientation)), q, SLOT(_q_placeToolBar(Dui::Orientation))); +#ifdef Q_WS_X11 + addDuiStatusBarOverlayProperty(); +#endif + #ifdef HAVE_N900 q->connect(homeButtonPanel, SIGNAL(buttonClicked()), q, SLOT(_q_exitAppView())); #else @@ -103,6 +121,11 @@ void DuiApplicationWindowPrivate::init() q->connect(menu, SIGNAL(disappeared()), q, SLOT(_q_menuDisappeared())); + if (!DuiApplication::fullScreen()) { + statusBar->appearNow(q); + showingStatusBar = true; + } + navigationBar->appearNow(q); homeButtonPanel->appearNow(q); escapeButtonPanel->appearNow(q); @@ -119,6 +142,21 @@ void DuiApplicationWindowPrivate::init() initAutoHideComponentsTimer(); } +#ifdef Q_WS_X11 +void DuiWindowPrivate::addDuiStatusBarOverlayProperty() +{ + Q_Q(DuiWindow); + + Atom atomDuiStatusBarOverlay = XInternAtom(QX11Info::display(), "_DUI_STATUSBAR_OVERLAY", False); + long propertyData = 1; + + XChangeProperty(QX11Info::display(), q->winId(), + atomDuiStatusBarOverlay, XA_CARDINAL /* type */, + 32 /* format, in bits */, PropModeReplace, + (unsigned char *) &propertyData, 1 /* number of elements */); +} +#endif + void DuiApplicationWindowPrivate::initAutoHideComponentsTimer() { // TODO: Get the interval from CSS or some system wide @@ -128,6 +166,19 @@ void DuiApplicationWindowPrivate::initAutoHideComponentsTimer() autoHideComponentsTimer.setSingleShot(true); } +void DuiApplicationWindowPrivate::windowStateChangeEvent(QWindowStateChangeEvent *event) +{ + Q_Q(DuiApplicationWindow); + Q_ASSERT(statusBar != 0); + + if (q->isFullScreen() && !event->oldState().testFlag(Qt::WindowFullScreen)) { + q->sceneManager()->hideWindowNow(statusBar); + + } else if (!q->isFullScreen() && event->oldState().testFlag(Qt::WindowFullScreen)) { + q->sceneManager()->showWindowNow(statusBar); + } +} + void DuiApplicationWindowPrivate::_q_connectEscapeButton(DuiEscapeButtonPanelModel::EscapeMode mode) { Q_Q(DuiApplicationWindow); @@ -245,7 +296,7 @@ void DuiApplicationWindowPrivate::updatePageAutoMarginsForComponents(const Dui:: qreal statusBarHeight; - if (statusBar) { + if (showingStatusBar) { statusBarHeight = statusBar->effectiveSizeHint(Qt::PreferredSize).height(); } else { statusBarHeight = 0; @@ -451,23 +502,27 @@ void DuiApplicationWindowPrivate::updateDockWidgetVisibility() void DuiApplicationWindowPrivate::sceneWindowAppearEvent(DuiSceneWindowEvent *event) { + Q_Q(DuiApplicationWindow); DuiSceneWindow *sceneWindow = event->sceneWindow(); if (sceneWindow->windowType() == DuiSceneWindow::ApplicationPage) { applicationPageAppearEvent(event); } else if (sceneWindow->windowType() == DuiSceneWindow::StatusBar) { - statusBarAppearEvent(event); + showingStatusBar = true; + updatePageAutoMarginsForComponents(q->orientation()); } } void DuiApplicationWindowPrivate::sceneWindowDisappearEvent(DuiSceneWindowEvent *event) { + Q_Q(DuiApplicationWindow); DuiSceneWindow *sceneWindow = event->sceneWindow(); if (sceneWindow->windowType() == DuiSceneWindow::ApplicationPage) { applicationPageDisappearEvent(event); } else if (sceneWindow->windowType() == DuiSceneWindow::StatusBar) { - statusBarDisappearEvent(event); + showingStatusBar = false; + updatePageAutoMarginsForComponents(q->orientation()); } } @@ -505,27 +560,6 @@ void DuiApplicationWindowPrivate::applicationPageDisappearEvent(DuiSceneWindowEv disconnectPage(pageFromEvent); } -void DuiApplicationWindowPrivate::statusBarAppearEvent(DuiSceneWindowEvent *event) -{ - Q_Q(DuiApplicationWindow); - Q_ASSERT(statusBar == 0); - - statusBar = event->sceneWindow(); - - updatePageAutoMarginsForComponents(q->orientation()); -} - -void DuiApplicationWindowPrivate::statusBarDisappearEvent(DuiSceneWindowEvent *event) -{ - Q_Q(DuiApplicationWindow); - Q_ASSERT(statusBar == event->sceneWindow()); - Q_UNUSED(event); - - statusBar = 0; - - updatePageAutoMarginsForComponents(q->orientation()); -} - // TODO: Remove that now useless method override after API freeze period void DuiApplicationWindow::onDisplayChangeEvent(DuiOnDisplayChangeEvent *event) { @@ -618,11 +652,17 @@ bool DuiApplicationWindow::event(QEvent *event) d->_q_actionUpdated(actionEvent); return true; } - default: { - return DuiWindow::event(event); + + case QEvent::WindowStateChange: + d->windowStateChangeEvent(static_cast<QWindowStateChangeEvent *>(event)); + break; + + default: + // Do nothing break; - } } + + return DuiWindow::event(event); } // We have to send this root message because the window itself is managing diff --git a/src/widgets/duiapplicationwindow_p.h b/src/widgets/duiapplicationwindow_p.h index 3cc21207..3902b59c 100644 --- a/src/widgets/duiapplicationwindow_p.h +++ b/src/widgets/duiapplicationwindow_p.h @@ -58,6 +58,7 @@ public: DuiEscapeButtonPanel *escapeButtonPanel; DuiApplicationMenu *menu; QPointer<DuiSceneWindow> statusBar; + bool showingStatusBar; QTimer autoHideComponentsTimer; QList<DuiSceneWindow *> componentsOnAutoHide; @@ -96,8 +97,7 @@ public: void applicationPageAppearEvent(DuiSceneWindowEvent *ev); void applicationPageDisappearEvent(DuiSceneWindowEvent *ev); - void statusBarAppearEvent(DuiSceneWindowEvent *ev); - void statusBarDisappearEvent(DuiSceneWindowEvent *ev); + void windowStateChangeEvent(QWindowStateChangeEvent *event); private: void init(); diff --git a/src/widgets/duiwindow.cpp b/src/widgets/duiwindow.cpp index 959bdefc..0a73e9b4 100644 --- a/src/widgets/duiwindow.cpp +++ b/src/widgets/duiwindow.cpp @@ -24,7 +24,6 @@ #endif #include <QTimeLine> -#include <QTimer> #include <QSettings> #include "duiapplication.h" @@ -38,7 +37,6 @@ #include "duicomponentdata.h" #include "duiorientationchangeevent.h" #include <duiondisplaychangeevent.h> -#include <duistatusbar.h> #include <DuiDebug> #include <DuiGConfItem> #include <DuiScene> @@ -48,7 +46,6 @@ #ifdef Q_WS_X11 # include <QX11Info> -# include <X11/Xatom.h> # include <X11/Xlib.h> // Avoid conflict with QEvent::KeyPress usage in DuiWindow::Event # undef KeyPress @@ -63,8 +60,7 @@ DuiWindowPrivate::DuiWindowPrivate() : orientationAngleLocked(false), orientationLocked(false), onDisplay(false), - onDisplaySet(false), - statusBar(0) + onDisplaySet(false) { DuiWindow *window = DuiApplication::activeWindow(); @@ -76,7 +72,6 @@ DuiWindowPrivate::DuiWindowPrivate() : DuiWindowPrivate::~DuiWindowPrivate() { - delete statusBar; } void DuiWindowPrivate::init() @@ -127,18 +122,10 @@ void DuiWindowPrivate::init() #ifdef Q_WS_X11 appendVisibilityChangeMask(); - addDuiStatusBarOverlayProperty(); #endif q->setTranslucentBackground(false); - statusBar = new DuiStatusBar; - if (!DuiApplication::fullScreen()) { - // Let DuiWindow and his descendants (like DuiApplicationWindow) - // finish their initializations before making the status bar appear. - QTimer::singleShot(0, q, SLOT(_q_makeStatusBarAppear())); - } - if (DuiApplication::fullScreen()) q->showFullScreen(); @@ -163,19 +150,6 @@ void DuiWindowPrivate::appendVisibilityChangeMask() XChangeWindowAttributes(QX11Info::display(), q->winId(), CWEventMask, &newAttributes); } - -void DuiWindowPrivate::addDuiStatusBarOverlayProperty() -{ - Q_Q(DuiWindow); - - Atom atomDuiStatusBarOverlay = XInternAtom(QX11Info::display(), "_DUI_STATUSBAR_OVERLAY", False); - long propertyData = 1; - - XChangeProperty(QX11Info::display(), q->winId(), - atomDuiStatusBarOverlay, XA_CARDINAL /* type */, - 32 /* format, in bits */, PropModeReplace, - (unsigned char *) &propertyData, 1 /* number of elements */); -} #endif void DuiWindowPrivate::handleApplicationLayoutDirectionChangeEvent(QGraphicsItem *item) @@ -243,27 +217,6 @@ void DuiWindowPrivate::notifyWidgetsAboutOrientationChange() } } -void DuiWindowPrivate::windowStateChangeEvent(QWindowStateChangeEvent *event) -{ - Q_Q(DuiWindow); - Q_ASSERT(statusBar != 0); - - // TODO: Remove this check when DuiStatusBar is fleshed out - // to be the actual status bar instead of just a place holder. - if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock)) { - // That window is the status bar itself. - // No sense in adding DuiStatusBar to the scene then. - return; - } - - if (q->isFullScreen() && !event->oldState().testFlag(Qt::WindowFullScreen)) { - q->sceneManager()->hideWindow(statusBar); - - } else if (!q->isFullScreen() && event->oldState().testFlag(Qt::WindowFullScreen)) { - q->sceneManager()->showWindow(statusBar); - } -} - void DuiWindowPrivate::doEnterDisplayEvent() { Q_Q(DuiWindow); @@ -310,21 +263,6 @@ void DuiWindowPrivate::propagateDuiOnDisplayChangeEventToScene(DuiOnDisplayChang } -void DuiWindowPrivate::_q_makeStatusBarAppear() -{ - Q_Q(DuiWindow); - - // TODO: Remove this check when DuiStatusBar is fleshed out - // to be the actual status bar instead of just a place holder. - if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock)) { - // That window is the status bar itself. - // No sense in adding DuiStatusBar to the scene then. - return; - } - - q->sceneManager()->showWindow(statusBar); -} - DuiWindow::DuiWindow(DuiWindowPrivate &dd, QWidget *parent) : QGraphicsView(parent), d_ptr(&dd) @@ -791,8 +729,6 @@ bool DuiWindow::event(QEvent *event) } else if (event->type() == DuiOnDisplayChangeEvent::eventNumber()) { onDisplayChangeEvent(static_cast<DuiOnDisplayChangeEvent *>(event)); return true; - } else if (event->type() == QEvent::WindowStateChange) { - d->windowStateChangeEvent(static_cast<QWindowStateChangeEvent *>(event)); } return QGraphicsView::event(event); diff --git a/src/widgets/duiwindow.h b/src/widgets/duiwindow.h index 184b1165..a1e16bb8 100644 --- a/src/widgets/duiwindow.h +++ b/src/widgets/duiwindow.h @@ -386,8 +386,6 @@ private: Q_DISABLE_COPY(DuiWindow) Q_DECLARE_PRIVATE(DuiWindow) - Q_PRIVATE_SLOT(d_func(), void _q_makeStatusBarAppear()) - #ifdef UNIT_TEST // to call orientationAngleChanged() friend class Ut_DuiWindow; diff --git a/src/widgets/duiwindow_p.h b/src/widgets/duiwindow_p.h index ee8e4da2..ae5fd7df 100644 --- a/src/widgets/duiwindow_p.h +++ b/src/widgets/duiwindow_p.h @@ -21,7 +21,6 @@ #define DUIWINDOW_P_H #include <QTimeLine> -#include <QPointer> #include "duiwindow.h" #include <duiscenemanager.h> @@ -59,8 +58,6 @@ public: bool orientationAngleLocked; bool orientationLocked; - void windowStateChangeEvent(QWindowStateChangeEvent *event); - void doEnterDisplayEvent(); void doExitDisplayEvent(); @@ -69,10 +66,6 @@ public: bool onDisplay; bool onDisplaySet; - QPointer<DuiStatusBar> statusBar; - - void _q_makeStatusBarAppear(); - protected: DuiWindow *q_ptr; private: |