summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-10-22 18:36:24 +0200
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-10-23 11:28:49 +0000
commitb50ee28eb52fa23c05a9599e02e9671f7ab42d10 (patch)
treebc72a3331fcc19ef2b2baf5cd2e9a5f6648f5904 /src/widgets
parent07475c662eb73c833da2d461b8ef2702ca1e2cfb (diff)
QWidgetAction: Don't deactivate the current window on Mac
We check the name of the window class the widget's QNSView changes window and set a flag when the that window is a native Cocoa menu window. Later, only those views not inside a native menu can become first responder, ensuring Qt won't deactivate the main window. We're allowed to reject becoming the first responder mainly because Cocoa itself doesn't support sending key event to menu views and, therefore, it doesn't change what's already possible. This patch also sets the widget action visible, which needs to be done right after reparenting it to the container widget. Besides that, it also contains a few small code cleaning changes related to Cocoa's support of QWidgetAction. Change-Id: Ia2170bdc5e1f40bfa2f1091c05e9e99397c47187 Task-number: QTBUG-44015 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qmenu.cpp2
-rw-r--r--src/widgets/widgets/qmenu_mac.mm1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 6e37f91197..5453d9d64f 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1265,7 +1265,7 @@ void QMenuPrivate::_q_platformMenuAboutToShow()
#ifdef Q_OS_OSX
if (platformMenu)
Q_FOREACH (QAction *action, q->actions())
- if (QWidget *widget = widgetItems.value(const_cast<QAction *>(action)))
+ if (QWidget *widget = widgetItems.value(action))
if (widget->parent() == q) {
QPlatformMenuItem *menuItem = platformMenu->menuItemForTag(reinterpret_cast<quintptr>(action));
moveWidgetToPlatformItem(widget, menuItem);
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index a42879fc73..8b29011178 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -115,6 +115,7 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
QObject::connect(platformMenu, SIGNAL(destroyed()), container, SLOT(deleteLater()));
container->resize(widget->sizeHint());
widget->setParent(container);
+ widget->setVisible(true);
NSView *containerView = container->nativeView();
QWindow *containerWindow = container->windowHandle();