Cocoa integration - menus and Qt::Tool windows
If an app has only Qt::Tool window(s) at start, menu is not updated, since Qt::Tool is also a Qt::Popup (included) and we have a special logic for Qt::Popup in QCocoaMenuBar::updateMenuBarImmediately. Using QCocoaApplicationDelegate (ivar 'inLaunch') we can avoid this problem. Change-Id: Ie1c4ef241cd19fa0af93c54de2b36e6e932cb77c Task-number: QTBUG-32539 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
This commit is contained in:
parent
51af196ba0
commit
5e9f7b9579
@ -100,6 +100,7 @@
|
|||||||
- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
|
- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
|
||||||
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
|
||||||
- (void) removeAppleEventHandlers;
|
- (void) removeAppleEventHandlers;
|
||||||
|
- (bool) inLaunch;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate);
|
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate);
|
||||||
|
@ -284,6 +284,11 @@ QT_END_NAMESPACE
|
|||||||
[eventManager removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL];
|
[eventManager removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (bool) inLaunch
|
||||||
|
{
|
||||||
|
return inLaunch;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
Q_UNUSED(aNotification);
|
Q_UNUSED(aNotification);
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "qcocoamenuloader.h"
|
#include "qcocoamenuloader.h"
|
||||||
#include "qcocoaapplication.h" // for custom application category
|
#include "qcocoaapplication.h" // for custom application category
|
||||||
#include "qcocoaautoreleasepool.h"
|
#include "qcocoaautoreleasepool.h"
|
||||||
|
#include "qcocoaapplicationdelegate.h"
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
@ -265,8 +266,21 @@ void QCocoaMenuBar::updateMenuBarImmediately()
|
|||||||
QCocoaWindow *cw = findWindowForMenubar();
|
QCocoaWindow *cw = findWindowForMenubar();
|
||||||
|
|
||||||
QWindow *win = cw ? cw->window() : 0;
|
QWindow *win = cw ? cw->window() : 0;
|
||||||
if (win && (win->flags() & Qt::Popup) == Qt::Popup)
|
if (win && (win->flags() & Qt::Popup) == Qt::Popup) {
|
||||||
return; // context menus, comboboxes, etc. don't need to update the menubar
|
// context menus, comboboxes, etc. don't need to update the menubar,
|
||||||
|
// but if an application has only Qt::Tool window(s) on start,
|
||||||
|
// we still have to update the menubar.
|
||||||
|
if ((win->flags() & Qt::WindowType_Mask) != Qt::Tool)
|
||||||
|
return;
|
||||||
|
typedef QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) AppDelegate;
|
||||||
|
NSApplication *app = [NSApplication sharedApplication];
|
||||||
|
if (![app.delegate isKindOfClass:[AppDelegate class]])
|
||||||
|
return;
|
||||||
|
// We apply this logic _only_ during the startup.
|
||||||
|
AppDelegate *appDelegate = app.delegate;
|
||||||
|
if (!appDelegate.inLaunch)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (cw && cw->menubar())
|
if (cw && cw->menubar())
|
||||||
mb = cw->menubar();
|
mb = cw->menubar();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user