Cocoa QPA Menus: Clean-up QCocoaMenuLoader related code

Now that QCocoaMenuLoader is a singleton, we can access
it the natural way. In all cases, it already needed to
be done in an Objective-C file, so it doesn't change
anything from this point of view.

Furthermore, we decide to remove private accessor APIs
in QCocoaApplication and QCocoaApplicationDelegate which
are now redundant.

Change-Id: I4190ed2e2536b778482c513727e279c9318acb7e
Reviewed-by: James Turner <james.turner@kdab.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Gabriel de Dietrich 2016-07-22 15:28:25 -07:00
parent c4b4eba188
commit a9603ef7d4
7 changed files with 6 additions and 41 deletions

View File

@ -95,7 +95,6 @@
@interface NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration))
- (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu;
- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader);
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel;
- (void)QT_MANGLE_NAMESPACE(qt_sendPostedMessage):(NSEvent *)event;

View File

@ -88,11 +88,6 @@ QT_USE_NAMESPACE
[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] setDockMenu:newMenu];
}
- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)
{
return [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader];
}
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel
{
Q_UNUSED(fontPanel);

View File

@ -100,8 +100,6 @@
}
+ (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
- (void)setDockMenu:(NSMenu *)newMenu;
- (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader)*)menuLoader;
- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void) removeAppleEventHandlers;

View File

@ -168,23 +168,12 @@ QT_END_NAMESPACE
return [[dockMenu retain] autorelease];
}
- (void)setMenuLoader:(QCocoaMenuLoader *)menuLoader
{
Q_UNUSED(menuLoader);
qWarning("-[QCocoaApplicationDelegate setMenuLoader:] is deprecated and is currently a no-op.");
}
- (QCocoaMenuLoader *)menuLoader
{
return [QT_MANGLE_NAMESPACE(QCocoaMenuLoader) sharedMenuLoader];
}
- (BOOL) canQuit
{
[[NSApp mainMenu] cancelTracking];
bool handle_quit = true;
NSMenuItem *quitMenuItem = [[[QCocoaApplicationDelegate sharedDelegate] menuLoader] quitMenuItem];
NSMenuItem *quitMenuItem = [[QT_MANGLE_NAMESPACE(QCocoaMenuLoader) sharedMenuLoader] quitMenuItem];
if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty()
&& [quitMenuItem isEnabled]) {
int visible = 0;

View File

@ -74,11 +74,6 @@ NSString *qt_mac_removePrivateUnicode(NSString* string)
return string;
}
static inline QCocoaMenuLoader *getMenuLoader()
{
return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
}
QT_END_NAMESPACE
@interface QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) : NSObject <NSMenuDelegate> {
@ -408,7 +403,7 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
}
bool wasMerged = cocoaItem->isMerged();
NSMenu *oldMenu = wasMerged ? [getMenuLoader() applicationMenu] : m_nativeMenu;
NSMenu *oldMenu = wasMerged ? [[QCocoaMenuLoader sharedMenuLoader] applicationMenu] : m_nativeMenu;
NSMenuItem *oldItem = [oldMenu itemWithTag:(NSInteger) cocoaItem];
if (cocoaItem->sync() != oldItem) {

View File

@ -52,11 +52,6 @@ QT_BEGIN_NAMESPACE
static QList<QCocoaMenuBar*> static_menubars;
static inline QCocoaMenuLoader *getMenuLoader()
{
return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
}
QCocoaMenuBar::QCocoaMenuBar() :
m_window(0)
{
@ -330,7 +325,7 @@ void QCocoaMenuBar::updateMenuBarImmediately()
menu->syncModalState(disableForModal);
}
QCocoaMenuLoader *loader = getMenuLoader();
QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
[loader ensureAppMenuInMenu:mb->nsMenu()];
NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:0] retain];

View File

@ -53,12 +53,6 @@
QT_BEGIN_NAMESPACE
static inline QCocoaMenuLoader *getMenuLoader()
{
return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
}
static quint32 constructModifierMask(quint32 accel_key)
{
quint32 ret = 0;
@ -221,7 +215,7 @@ NSMenuItem *QCocoaMenuItem::sync()
if ((m_role != NoRole && !m_textSynced) || m_merged) {
NSMenuItem *mergeItem = nil;
QCocoaMenuLoader *loader = getMenuLoader();
QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
switch (m_role) {
case ApplicationSpecificRole:
mergeItem = [loader appSpecificMenuItem:reinterpret_cast<NSInteger>(this)];
@ -359,7 +353,7 @@ QT_END_NAMESPACE
QString QCocoaMenuItem::mergeText()
{
QCocoaMenuLoader *loader = getMenuLoader();
QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
if (m_native == [loader aboutMenuItem]) {
return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName());
} else if (m_native== [loader aboutQtMenuItem]) {
@ -379,7 +373,7 @@ QString QCocoaMenuItem::mergeText()
QKeySequence QCocoaMenuItem::mergeAccel()
{
QCocoaMenuLoader *loader = getMenuLoader();
QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
if (m_native == [loader preferencesMenuItem])
return QKeySequence(QKeySequence::Preferences);
else if (m_native == [loader quitMenuItem])