From 0f2acaf1cb6be5290f64842667e60b6675b467c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 31 Mar 2014 12:19:20 +0200 Subject: Cocoa: Update unified toolbar area on toolbar hide Add setContentBorderAreaEnabled() which us used to enable or disable an area. Used together with registerContentBorderArea() this allows changing the border area geometry and enabled status independently. Add section to the QToolBar show/hide event handler which calls setContentBorderAreaEnabled(). Make sure QToolBar and QToolBarLayout uses the same identifier - the QToolBar object pointer. Rename enableContentBorderArea -> setContentBorderEnabled. The "ContentBorder" is now the entire unified toolbar area while "ContentBorderArea"s are the sub-areas covered by toolbars. Change-Id: I339f381a50856e048ae40e7ffadd6a8a510c4994 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qtoolbar.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/widgets/widgets/qtoolbar.cpp') diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 53b77c34da..3fd615c3c7 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -1040,6 +1040,21 @@ static bool waitForPopup(QToolBar *tb, QWidget *popup) return false; } +#ifdef Q_OS_OSX +static void enableMacToolBar(QToolBar *toolbar, bool enable) +{ + QPlatformNativeInterface *nativeInterface = QApplication::platformNativeInterface(); + QPlatformNativeInterface::NativeResourceForIntegrationFunction function = + nativeInterface->nativeResourceFunctionForIntegration("setContentBorderAreaEnabled"); + if (!function) + return; // Not Cocoa platform plugin. + + typedef void (*SetContentBorderAreaEnabledFunction)(QWindow *window, void *identifier, bool enabled); + (reinterpret_cast(function))(toolbar->window()->windowHandle(), toolbar, enable); +} +#endif + + /*! \reimp */ bool QToolBar::event(QEvent *event) { @@ -1062,6 +1077,9 @@ bool QToolBar::event(QEvent *event) // fallthrough intended case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); +#ifdef Q_OS_OSX + enableMacToolBar(this, event->type() == QEvent::Show); +#endif emit visibilityChanged(event->type() == QEvent::Show); break; case QEvent::ParentChange: -- cgit v1.2.3