aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2013-04-12 21:13:55 -0400
committerJake Petroules <jake.petroules@petroules.com>2013-04-15 14:51:03 +0200
commitb879a02d6d2abad0052535d364a5ead3d87b8b0d (patch)
treea8ca899c8754da9ad7bb3750a23db1111de0cb16
parent5f3ce05b45f31e1175e5c9874965785a9f670bda (diff)
Always create a native toolbar if the given QToolBar is not null.
Previously, if the user tried to create a native toolbar but set on = false we tried to be conservative and not create the NSToolbar just yet (fairly non-obvious). The user might not want to have the toolbar displayed immediately but still obtain the pointer for later use, so we'll support this use case by always returning a toolbar. Change-Id: I94dcd3ae57f0462893b2539623423f2a2d85437a Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
-rw-r--r--src/macextras/qmacunifiedtoolbar.mm14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/macextras/qmacunifiedtoolbar.mm b/src/macextras/qmacunifiedtoolbar.mm
index eb47934..9765a09 100644
--- a/src/macextras/qmacunifiedtoolbar.mm
+++ b/src/macextras/qmacunifiedtoolbar.mm
@@ -221,16 +221,12 @@ QMacUnifiedToolBar* QtMacExtras::setNativeToolBar(QToolBar *toolbar, const QStri
static const char *macToolBarProperty = "_q_mac_native_toolbar";
- // Check if we've already created a Mac equivalent for this toolbar
+ // Check if we've already created a Mac equivalent for this toolbar and create one if not
QVariant toolBarProperty = toolbar->property(macToolBarProperty);
- QMacUnifiedToolBar *macToolBar = NULL;
- if (toolBarProperty.canConvert<QMacUnifiedToolBar*>())
+ QMacUnifiedToolBar *macToolBar;
+ if (toolBarProperty.canConvert<QMacUnifiedToolBar*>()) {
macToolBar = toolBarProperty.value<QMacUnifiedToolBar*>();
-
- // Create one if not, but only if we're turning it on - no point in creating
- // a toolbar for the sole purpose of turning it off immediately
- if (!macToolBar && on)
- {
+ } else {
macToolBar = QMacUnifiedToolBar::fromQToolBar(toolbar, identifier);
macToolBar->setParent(toolbar);
toolbar->setProperty(macToolBarProperty, QVariant::fromValue(macToolBar));
@@ -239,7 +235,7 @@ QMacUnifiedToolBar* QtMacExtras::setNativeToolBar(QToolBar *toolbar, const QStri
toolbar->setVisible(!on);
if (on)
macToolBar->showInWindowForWidget(toolbar->window());
- else if (macToolBar)
+ else
macToolBar->removeFromWindowForWidget(toolbar->window());
return macToolBar;