diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-03-31 12:19:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-09 20:53:06 +0200 |
commit | 0f2acaf1cb6be5290f64842667e60b6675b467c4 (patch) | |
tree | 50392234431c5147fa0492fd1ccfb0a27ba10ad4 /src/widgets/widgets | |
parent | b2a6c9ec3ef37f571aca2ce1c48d346d4f09a305 (diff) |
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 <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbar.cpp | 18 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbarlayout.cpp | 4 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 1d0268a244..90cfb1d7cb 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1513,12 +1513,12 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); QPlatformNativeInterface::NativeResourceForIntegrationFunction function = - nativeInterface->nativeResourceFunctionForIntegration("enableContentBorderArea"); + nativeInterface->nativeResourceFunctionForIntegration("setContentBorderEnabled"); if (!function) return; // Not Cocoa platform plugin. - typedef void (*EnableContentBorderAreaFunction)(QWindow *window, bool enable); - (reinterpret_cast<EnableContentBorderAreaFunction>(function))(window()->windowHandle(), set); + typedef void (*SetContentBorderEnabledFunction)(QWindow *window, bool enable); + (reinterpret_cast<SetContentBorderEnabledFunction>(function))(window()->windowHandle(), set); } #endif 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<SetContentBorderAreaEnabledFunction>(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: diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 020d180778..efd33da7fc 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -369,9 +369,9 @@ void QToolBarLayout::updateMacBorderMetrics() typedef void (*RegisterContentBorderAreaFunction)(QWindow *window, void *identifier, int upper, int lower); if (mainWindow->toolBarArea(tb) == Qt::TopToolBarArea) { - (reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), this, upper.y(), lower.y()); + (reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), tb, upper.y(), lower.y()); } else { - (reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), this, 0, 0); + (reinterpret_cast<RegisterContentBorderAreaFunction>(function))(tb->window()->windowHandle(), tb, 0, 0); } #endif } |