diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-04-18 19:04:13 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-05-23 18:09:28 +0000 |
commit | 595c1ae9e7be14162acdfcbc573f31ef6661e718 (patch) | |
tree | 437422a3cfd7d0499510f5b375e030ee6ae4e2d2 /src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h | |
parent | bd74b624d53ce076a8b6a90a66da0a19da1ec17c (diff) |
Cocoa Menus: Add support for menu items in window-less apps
Since we moved the menu items validation and target/action to
QNSView (thus relying on the responder chain), we need to take
care of case when the applications that doesn't have any window
open. By adding similar methods to QCocoaApplicationDelegate,
the last responder, we ensure the menu items will be validated
and will trigger properly. This is particularly necessary for
dock menu items, which live separately from any top-level widget.
Dock menu added to Menurama which won't quit when its last window
is closed. This way we can test that dock menu items will trigger
in the absence of any window.
Change-Id: I56d864eb9da1f8dd5adb2a3b6c3dd5304c723117
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h index 3073cb6b44..0816730c54 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. @@ -90,14 +90,18 @@ #include <qglobal.h> #include <private/qcore_mac_p.h> -@class QT_MANGLE_NAMESPACE(QCocoaMenuLoader); +Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaNSMenuItem)); @interface QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) : NSObject <NSApplicationDelegate> +@property (nonatomic, retain) NSMenu *dockMenu; + (instancetype)sharedDelegate; -- (void)setDockMenu:(NSMenu *)newMenu; - (void)setReflectionDelegate:(NSObject<NSApplicationDelegate> *)oldDelegate; - (void)removeAppleEventHandlers; - (bool)inLaunch; @end +@interface QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) (MenuAPI) +- (void)qt_itemFired:(QT_MANGLE_NAMESPACE(QCocoaNSMenuItem) *)item; +@end + QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate); |