diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-01-20 12:08:49 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-10 12:49:06 +0100 |
commit | 3d08681169b5194cdc9e61fbf6fac9c4346147d8 (patch) | |
tree | ed8d0c83e7171b94f8ddb75df41df9288633b0bd /src/plugins/platforms/cocoa/qcocoawindow.mm | |
parent | df86721bb4028ae09c5ce7d71a89808b8f2ccdcd (diff) |
Cocoa: Add setNSToolbar(QWindow *, NSToolBar *)
Calling this function associates the given native
toolbar with the QWindow. QWindow will then set
it on the native NSWindow at the appropriate time
during window creation.
Change-Id: I2a50f79b2a0453cc739f8d68e965e37b95998083
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index ce1e856bfc..5524e12061 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -45,6 +45,7 @@ #include "qcocoaeventdispatcher.h" #include "qcocoaglcontext.h" #include "qcocoahelpers.h" +#include "qcocoanativeinterface.h" #include "qnsview.h" #include <QtCore/qfileinfo.h> #include <QtCore/private/qcore_mac_p.h> @@ -1124,6 +1125,11 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) const qreal opacity = qt_window_private(window())->opacity; if (!qFuzzyCompare(opacity, qreal(1.0))) setOpacity(opacity); + + // top-level QWindows may have an attached NSToolBar, call + // update function which will attach to the NSWindow. + if (!parentWindow) + updateNSToolbar(); } void QCocoaWindow::reinsertChildWindow(QCocoaWindow *child) @@ -1387,6 +1393,19 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window) } } +void QCocoaWindow::updateNSToolbar() +{ + if (!m_nsWindow) + return; + + NSToolbar *toolbar = QCocoaIntegration::instance()->toolbar(window()); + + if ([m_nsWindow toolbar] == toolbar) + return; + + [m_nsWindow setToolbar: toolbar]; + [m_nsWindow setShowsToolbarButton:YES]; +} qreal QCocoaWindow::devicePixelRatio() const { |