diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-05-13 17:53:39 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-06 15:48:23 +0200 |
commit | f02dde3d74ec69d2bafa25053ff85e514d950b0e (patch) | |
tree | 51f3ab15414e3d7642f3d2ecd59b2deb92298eb9 /src/widgets | |
parent | 04739ce4b401bdfe766e64deac1bb382ddd954cc (diff) |
Simplify QMainWindow::setUnifiedTitleAndToolBarOnMac
Task-number: QTBUG-83252
Change-Id: Ib6f7dcfe21407603d4cfd5d33f6615d8623db940
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 7fabb4ae7c..9379fb04ef 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -67,9 +67,7 @@ #include "qtoolbar_p.h" #endif #include "qwidgetanimator_p.h" -#ifdef Q_OS_MACOS -#include <qpa/qplatformnativeinterface.h> -#endif +#include <QtGui/qpa/qplatformwindow.h> QT_BEGIN_NAMESPACE @@ -1351,28 +1349,23 @@ bool QMainWindow::event(QEvent *event) \since 5.2 */ -void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) +void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool enabled) { #ifdef Q_OS_MACOS + if (!isWindow()) + return; + Q_D(QMainWindow); - if (isWindow()) { - d->useUnifiedToolBar = set; - createWinId(); - - QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); - if (!nativeInterface) - return; // Not Cocoa platform plugin. - QPlatformNativeInterface::NativeResourceForIntegrationFunction function = - nativeInterface->nativeResourceFunctionForIntegration("setContentBorderEnabled"); - if (!function) - return; // Not Cocoa platform plugin. - - typedef void (*SetContentBorderEnabledFunction)(QWindow *window, bool enable); - (reinterpret_cast<SetContentBorderEnabledFunction>(function))(window()->windowHandle(), set); - update(); - } + d->useUnifiedToolBar = enabled; + createWinId(); + + using namespace QPlatformInterface::Private; + if (auto *platformWindow = dynamic_cast<QCocoaWindow*>(window()->windowHandle()->handle())) + platformWindow->setContentBorderEnabled(enabled); + + update(); #else - Q_UNUSED(set) + Q_UNUSED(enabled) #endif } |