diff options
author | Fabien Freling <fabien.freling@nokia.com> | 2010-10-08 16:37:25 (GMT) |
---|---|---|
committer | Fabien Freling <fabien.freling@nokia.com> | 2010-10-08 16:37:59 (GMT) |
commit | 1966b88611bb45d18d586847eeb3597d6e022eb7 (patch) | |
tree | 0bba3169a8bc44761686fd967f1cb25e4beca97a /src/gui/painting/qwindowsurface_raster.cpp | |
parent | 392ecc76cdbcef37ee492400a1b783106a37ad36 (diff) | |
download | Qt-1966b88611bb45d18d586847eeb3597d6e022eb7.zip Qt-1966b88611bb45d18d586847eeb3597d6e022eb7.tar.gz Qt-1966b88611bb45d18d586847eeb3597d6e022eb7.tar.bz2 |
Experimental support of the unified toolbar with
the raster engine on Mac OS X.
Task-number: QTBUG-12615
Reviewed-by: Samuel Rødal
Diffstat (limited to 'src/gui/painting/qwindowsurface_raster.cpp')
-rw-r--r-- | src/gui/painting/qwindowsurface_raster.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 6a2cb1e..99f8597 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -64,6 +64,9 @@ #ifdef Q_WS_MAC #include <private/qt_cocoa_helpers_mac_p.h> +#include <QMainWindow> +#include <private/qmainwindowlayout_p.h> +#include <QToolBar> #endif QT_BEGIN_NAMESPACE @@ -82,8 +85,8 @@ public: uint inSetGeometry : 1; }; -QRasterWindowSurface::QRasterWindowSurface(QWidget *window) - : QWindowSurface(window), d_ptr(new QRasterWindowSurfacePrivate) +QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurface) + : QWindowSurface(window, setDefaultSurface), d_ptr(new QRasterWindowSurfacePrivate) { #ifdef Q_WS_X11 d_ptr->gc = XCreateGC(X11->display, window->handle(), 0, 0); @@ -248,6 +251,23 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi #ifdef Q_WS_MAC + // Unified toolbar hack. + QMainWindow* mWindow = qobject_cast<QMainWindow*>(widget->window()); + if (mWindow) { + QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout()); + QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList; + + for (int i = 0; i < toolbarList.size(); ++i) { + QToolBar* toolbar = toolbarList.at(i); + if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) { + QWidget* tbWidget = (QWidget*) toolbar; + if (tbWidget->d_func()->unifiedSurface) { + tbWidget->d_func()->unifiedSurface->flush(tbWidget, rgn, offset); + } + } + } + } + Q_UNUSED(offset); // Get a context for the widget. #ifndef QT_MAC_USE_COCOA @@ -318,6 +338,23 @@ void QRasterWindowSurface::setGeometry(const QRect &rect) prepareBuffer(QNativeImage::systemFormat(), window()); } d->inSetGeometry = false; +#ifdef Q_WS_MAC + QMainWindow* mWindow = qobject_cast<QMainWindow*>(window()); + if (mWindow) { + QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout()); + QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList; + + for (int i = 0; i < toolbarList.size(); ++i) { + QToolBar* toolbar = toolbarList.at(i); + if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) { + QWidget* tbWidget = (QWidget*) toolbar; + if (tbWidget->d_func()->unifiedSurface) { + tbWidget->d_func()->unifiedSurface->setGeometry(rect); + } + } + } + } +#endif // Q_WS_MAC } // from qwindowsurface.cpp |