diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 4211a23e0f..ad6be762c0 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -75,6 +75,12 @@ #include "qstring.h" +#if defined( __OBJC__) && defined(QT_NAMESPACE) +#define QT_NAMESPACE_ALIAS_OBJC_CLASS(__KLASS__) @compatibility_alias __KLASS__ QT_MANGLE_NAMESPACE(__KLASS__) +#else +#define QT_NAMESPACE_ALIAS_OBJC_CLASS(__KLASS__) +#endif + QT_BEGIN_NAMESPACE /* diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.h b/src/plugins/platforms/cocoa/qcocoaapplication.h index 2376b35501..ffb12ea846 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.h +++ b/src/plugins/platforms/cocoa/qcocoaapplication.h @@ -89,8 +89,10 @@ Cocoa Application Categories */ #include "qglobal.h" +#include "private/qcore_mac_p.h" #import + @class QT_MANGLE_NAMESPACE(QCocoaMenuLoader); @interface NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration)) @@ -106,6 +108,8 @@ } @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSApplication); + QT_BEGIN_NAMESPACE void qt_redirectNSApplicationSendEvent(); diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm index d962ef8f75..c293f4cd52 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm @@ -87,12 +87,12 @@ QT_USE_NAMESPACE - (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu { - [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] setDockMenu:newMenu]; + [[QCocoaApplicationDelegate sharedDelegate] setDockMenu:newMenu]; } - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader) { - return [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader]; + return [[QCocoaApplicationDelegate sharedDelegate] menuLoader]; } - (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel @@ -155,7 +155,7 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE @end -@implementation QT_MANGLE_NAMESPACE(QNSApplication) +@implementation QNSApplication - (void)qt_sendEvent_original:(NSEvent *)event { @@ -189,7 +189,7 @@ QT_BEGIN_NAMESPACE void qt_redirectNSApplicationSendEvent() { - if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) { + if ([NSApp isMemberOfClass:[QNSApplication class]]) { // No need to change implementation since Qt // already controls a subclass of NSApplication return; @@ -202,7 +202,7 @@ void qt_redirectNSApplicationSendEvent() qt_cocoa_change_implementation( [NSApplication class], @selector(sendEvent:), - [QT_MANGLE_NAMESPACE(QNSApplication) class], + [QNSApplication class], @selector(qt_sendEvent_replacement:), @selector(qt_sendEvent_original:)); } diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h index e44b2d1b6d..7f6c4224df 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h @@ -90,6 +90,7 @@ #import #include +#include @class QT_MANGLE_NAMESPACE(QCocoaMenuLoader); @@ -108,3 +109,5 @@ - (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; - (void) removeAppleEventHandlers; @end + +QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate); diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index f676d613bc..7320fc11e6 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -88,14 +88,14 @@ QT_USE_NAMESPACE -static QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *sharedCocoaApplicationDelegate = nil; +static QCocoaApplicationDelegate *sharedCocoaApplicationDelegate = nil; static void cleanupCocoaApplicationDelegate() { [sharedCocoaApplicationDelegate release]; } -@implementation QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) +@implementation QCocoaApplicationDelegate - (id)init { @@ -129,7 +129,7 @@ static void cleanupCocoaApplicationDelegate() return nil; } -+ (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate ++ (QCocoaApplicationDelegate *)sharedDelegate { @synchronized(self) { if (sharedCocoaApplicationDelegate == nil) @@ -151,14 +151,14 @@ static void cleanupCocoaApplicationDelegate() return [[dockMenu retain] autorelease]; } -- (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader +- (void)setMenuLoader:(QCocoaMenuLoader *)menuLoader { [menuLoader retain]; [qtMenuLoader release]; qtMenuLoader = menuLoader; } -- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader +- (QCocoaMenuLoader *)menuLoader { return [[qtMenuLoader retain] autorelease]; } @@ -168,7 +168,7 @@ static void cleanupCocoaApplicationDelegate() [[NSApp mainMenu] cancelTracking]; bool handle_quit = true; - NSMenuItem *quitMenuItem = [[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader] quitMenuItem]; + NSMenuItem *quitMenuItem = [[[QCocoaApplicationDelegate sharedDelegate] menuLoader] quitMenuItem]; if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty() && [quitMenuItem isEnabled]) { int visible = 0; diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index a0dac445be..9d3527ef8d 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -87,7 +87,9 @@ static NSButton *macCreateButton(const char *text, NSView *superview) - (void)finishOffWithCode:(NSInteger)code; @end -@implementation QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); + +@implementation QNSColorPanelDelegate - (id)initWithDialogHelper:(QCocoaColorDialogHelper *)helper { @@ -348,7 +350,7 @@ QCocoaColorDialogHelper::~QCocoaColorDialogHelper() { if (!mDelegate) return; - [reinterpret_cast(mDelegate) release]; + [reinterpret_cast(mDelegate) release]; mDelegate = 0; } @@ -358,7 +360,7 @@ void QCocoaColorDialogHelper::exec() // QEventLoop has been interrupted, and the second-most event loop has not // yet been reactivated (regardless if [NSApp run] is still on the stack)), // showing a native modal dialog will fail. - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast(mDelegate); + QNSColorPanelDelegate *delegate = static_cast(mDelegate); if ([delegate runApplicationModalPanel]) emit accept(); else @@ -378,14 +380,14 @@ void QCocoaColorDialogHelper::hide() { if (!mDelegate) return; - [reinterpret_cast(mDelegate)->mColorPanel close]; + [reinterpret_cast(mDelegate)->mColorPanel close]; } void QCocoaColorDialogHelper::setCurrentColor(const QColor &color) { if (!mDelegate) createNSColorPanelDelegate(); - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast(mDelegate); + QNSColorPanelDelegate *delegate = static_cast(mDelegate); // make sure that if ShowAlphaChannel option is set then also setShowsAlpha // needs to be set, otherwise alpha value is omitted @@ -413,7 +415,7 @@ QColor QCocoaColorDialogHelper::currentColor() const { if (!mDelegate) return QColor(); - return reinterpret_cast(mDelegate)->mQtColor; + return reinterpret_cast(mDelegate)->mQtColor; } void QCocoaColorDialogHelper::createNSColorPanelDelegate() @@ -421,7 +423,7 @@ void QCocoaColorDialogHelper::createNSColorPanelDelegate() if (mDelegate) return; - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) alloc] + QNSColorPanelDelegate *delegate = [[QNSColorPanelDelegate alloc] initWithDialogHelper:this]; mDelegate = delegate; @@ -431,7 +433,7 @@ bool QCocoaColorDialogHelper::showCocoaColorPanel(Qt::WindowModality windowModal { Q_UNUSED(parent); createNSColorPanelDelegate(); - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast(mDelegate); + QNSColorPanelDelegate *delegate = static_cast(mDelegate); [delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)]; if (windowModality == Qt::NonModal) [delegate showModelessPanel]; @@ -444,7 +446,7 @@ bool QCocoaColorDialogHelper::hideCocoaColorPanel() if (!mDelegate){ return false; } else { - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast(mDelegate); + QNSColorPanelDelegate *delegate = static_cast(mDelegate); [delegate closePanel]; return true; } diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 071edb5b60..2bdd921064 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -139,7 +139,9 @@ typedef QSharedPointer SharedPointerFileDialogOptions; @end -@implementation QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate); + +@implementation QNSOpenSavePanelDelegate - (id)initWithAcceptMode: (const QString &)selectFile @@ -564,7 +566,7 @@ QCocoaFileDialogHelper::~QCocoaFileDialogHelper() if (!mDelegate) return; QCocoaAutoReleasePool pool; - [reinterpret_cast(mDelegate) release]; + [reinterpret_cast(mDelegate) release]; mDelegate = 0; } @@ -599,14 +601,14 @@ extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding void QCocoaFileDialogHelper::setDirectory(const QString &directory) { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if (delegate) [delegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:QCFString::toNSString(directory)]]; } QString QCocoaFileDialogHelper::directory() const { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if (delegate) return QCFString::toQString([[delegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C); return QString(); @@ -625,7 +627,7 @@ void QCocoaFileDialogHelper::selectFile(const QString &filename) QStringList QCocoaFileDialogHelper::selectedFiles() const { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if (delegate) return [delegate selectedFiles]; return QStringList(); @@ -633,7 +635,7 @@ QStringList QCocoaFileDialogHelper::selectedFiles() const void QCocoaFileDialogHelper::setFilter() { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if (!delegate) return; const SharedPointerFileDialogOptions &opts = options(); @@ -652,7 +654,7 @@ void QCocoaFileDialogHelper::selectNameFilter(const QString &filter) return; const int index = options()->nameFilters().indexOf(filter); if (index != -1) { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if (!delegate) return; [delegate->mPopUpButton selectItemAtIndex:index]; @@ -662,7 +664,7 @@ void QCocoaFileDialogHelper::selectNameFilter(const QString &filter) QString QCocoaFileDialogHelper::selectedNameFilter() const { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if (!delegate) return QString(); int index = [delegate->mPopUpButton indexOfSelectedItem]; @@ -700,7 +702,7 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate() const QString directory = opts->initialDirectory(); const bool selectDir = selectedFiles.isEmpty(); QString selection(selectDir ? directory : selectedFiles.front()); - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) alloc] + QNSOpenSavePanelDelegate *delegate = [[QNSOpenSavePanelDelegate alloc] initWithAcceptMode: selection options:opts @@ -712,7 +714,7 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate() bool QCocoaFileDialogHelper::showCocoaFilePanel(Qt::WindowModality windowModality, QWindow *parent) { createNSOpenSavePanelDelegate(); - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if (!delegate) return false; if (windowModality == Qt::NonModal) @@ -730,7 +732,7 @@ bool QCocoaFileDialogHelper::hideCocoaFilePanel() // open regarding whether or not to go native: return false; } else { - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); [delegate closePanel]; // Even when we hide it, we are still using a // native dialog, so return true: @@ -745,7 +747,7 @@ void QCocoaFileDialogHelper::exec() // yet been reactivated (regardless if [NSApp run] is still on the stack)), // showing a native modal dialog will fail. QCocoaAutoReleasePool pool; - QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast(mDelegate); + QNSOpenSavePanelDelegate *delegate = static_cast(mDelegate); if ([delegate runApplicationModalPanel]) emit accept(); else diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index e7cf47395b..83bea383d8 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -128,7 +128,9 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) - (void)finishOffWithCode:(NSInteger)code; @end -@implementation QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); + +@implementation QNSFontPanelDelegate - (id)initWithDialogHelper: (QCocoaFontDialogHelper *)helper @@ -363,7 +365,7 @@ QCocoaFontDialogHelper::~QCocoaFontDialogHelper() { if (!mDelegate) return; - [reinterpret_cast(mDelegate) release]; + [reinterpret_cast(mDelegate) release]; mDelegate = 0; } @@ -373,7 +375,7 @@ void QCocoaFontDialogHelper::exec() // QEventLoop has been interrupted, and the second-most event loop has not // yet been reactivated (regardless if [NSApp run] is still on the stack)), // showing a native modal dialog will fail. - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast(mDelegate); + QNSFontPanelDelegate *delegate = static_cast(mDelegate); if ([delegate runApplicationModalPanel]) emit accept(); else @@ -393,7 +395,7 @@ void QCocoaFontDialogHelper::hide() { if (!mDelegate) return; - [reinterpret_cast(mDelegate)->mFontPanel close]; + [reinterpret_cast(mDelegate)->mFontPanel close]; } void QCocoaFontDialogHelper::setCurrentFont(const QFont &font) @@ -421,14 +423,14 @@ void QCocoaFontDialogHelper::setCurrentFont(const QFont &font) createNSFontPanelDelegate(); [mgr setSelectedFont:const_cast(nsFont) isMultiple:NO]; - static_cast(mDelegate)->mQtFont = font; + static_cast(mDelegate)->mQtFont = font; } QFont QCocoaFontDialogHelper::currentFont() const { if (!mDelegate) return QFont(); - return reinterpret_cast(mDelegate)->mQtFont; + return reinterpret_cast(mDelegate)->mQtFont; } void QCocoaFontDialogHelper::createNSFontPanelDelegate() @@ -436,7 +438,7 @@ void QCocoaFontDialogHelper::createNSFontPanelDelegate() if (mDelegate) return; - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) alloc] + QNSFontPanelDelegate *delegate = [[QNSFontPanelDelegate alloc] initWithDialogHelper:this]; mDelegate = delegate; @@ -446,7 +448,7 @@ bool QCocoaFontDialogHelper::showCocoaFontPanel(Qt::WindowModality windowModalit { Q_UNUSED(parent); createNSFontPanelDelegate(); - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast(mDelegate); + QNSFontPanelDelegate *delegate = static_cast(mDelegate); if (windowModality == Qt::NonModal) [delegate showModelessPanel]; // no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel() @@ -458,7 +460,7 @@ bool QCocoaFontDialogHelper::hideCocoaFontPanel() if (!mDelegate){ return false; } else { - QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast(mDelegate); + QNSFontPanelDelegate *delegate = static_cast(mDelegate); [delegate closePanel]; return true; } diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 821e10de52..50d68f8311 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -232,7 +232,7 @@ QCocoaIntegration::QCocoaIntegration() qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false); - NSApplication *cocoaApplication = [QT_MANGLE_NAMESPACE(QNSApplication) sharedApplication]; + NSApplication *cocoaApplication = [QNSApplication sharedApplication]; qt_redirectNSApplicationSendEvent(); if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) { @@ -256,12 +256,12 @@ QCocoaIntegration::QCocoaIntegration() if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { // Set app delegate, link to the current delegate (if any) - QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]; + QCocoaApplicationDelegate *newDelegate = [QCocoaApplicationDelegate sharedDelegate]; [newDelegate setReflectionDelegate:[cocoaApplication delegate]]; [cocoaApplication setDelegate:newDelegate]; // Load the application menu. This menu contains Preferences, Hide, Quit. - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader = [[QT_MANGLE_NAMESPACE(QCocoaMenuLoader) alloc] init]; + QCocoaMenuLoader *qtMenuLoader = [[QCocoaMenuLoader alloc] init]; qt_mac_loadMenuNib(qtMenuLoader); [cocoaApplication setMenu:[qtMenuLoader menu]]; [newDelegate setMenuLoader:qtMenuLoader]; @@ -279,7 +279,7 @@ QCocoaIntegration::~QCocoaIntegration() QCocoaAutoReleasePool pool; if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { // remove the apple event handlers installed by QCocoaApplicationDelegate - QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *delegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]; + QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate]; [delegate removeAppleEventHandlers]; // reset the application delegate [[NSApplication sharedApplication] setDelegate: 0]; diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index c5c5c132bc..0a98819d16 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -73,7 +73,7 @@ NSString *qt_mac_removePrivateUnicode(NSString* string) return string; } -static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() +static inline QCocoaMenuLoader *getMenuLoader() { return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; } @@ -86,7 +86,9 @@ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() @end -@implementation QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); + +@implementation QCocoaMenuDelegate - (id) initWithMenu:(QCocoaMenu*) m { @@ -207,11 +209,11 @@ QCocoaMenu::QCocoaMenu() : m_enabled(true), m_tag(0) { - m_delegate = [[QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) alloc] initWithMenu:this]; + m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this]; m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; m_nativeMenu = [[NSMenu alloc] initWithTitle:@"Untitled"]; [m_nativeMenu setAutoenablesItems:YES]; - m_nativeMenu.delegate = (QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) *) m_delegate; + m_nativeMenu.delegate = (QCocoaMenuDelegate *) m_delegate; [m_nativeItem setSubmenu:m_nativeMenu]; } diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index b112e40549..5165a2095e 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -52,7 +52,7 @@ static QList static_menubars; -static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() +static inline QCocoaMenuLoader *getMenuLoader() { return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; } @@ -196,7 +196,7 @@ void QCocoaMenuBar::updateMenuBarImmediately() m->syncModalState(disableForModal); } - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); [loader ensureAppMenuInMenu:mb->nsMenu()]; NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:0] retain]; diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 1255f75eb7..05f0baa60f 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -52,7 +52,7 @@ #include -static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() +static inline QCocoaMenuLoader *getMenuLoader() { return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)]; } @@ -199,7 +199,7 @@ NSMenuItem *QCocoaMenuItem::sync() if ((m_role != NoRole && !m_textSynced) || m_merged) { NSMenuItem *mergeItem = nil; - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); switch (m_role) { case ApplicationSpecificRole: mergeItem = [loader appSpecificMenuItem:reinterpret_cast(this)]; @@ -324,7 +324,7 @@ QT_END_NAMESPACE QString QCocoaMenuItem::mergeText() { - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); if (m_native == [loader aboutMenuItem]) { return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()); } else if (m_native== [loader aboutQtMenuItem]) { @@ -342,7 +342,7 @@ QString QCocoaMenuItem::mergeText() QKeySequence QCocoaMenuItem::mergeAccel() { - QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + QCocoaMenuLoader *loader = getMenuLoader(); if (m_native == [loader preferencesMenuItem]) return QKeySequence(QKeySequence::Preferences); else if (m_native == [loader quitMenuItem]) diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h index a45ec0fa89..e07da39995 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.h +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h @@ -92,9 +92,11 @@ - (NSArray *)mergeable; @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuLoader); + QT_BEGIN_NAMESPACE -void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader); +void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader); QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm index 62b722d2d2..29fc0fb674 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE and written to QDir::temp() before loading. (Earlier Qt versions used to require having the nib file in the Qt GUI framework.) */ -void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader) +void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader) { // Create qt_menu.nib dir in temp. QDir temp = QDir::temp(); @@ -106,7 +106,7 @@ void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader) QT_END_NAMESPACE -@implementation QT_MANGLE_NAMESPACE(QCocoaMenuLoader) +@implementation QCocoaMenuLoader - (void)awakeFromNib { diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 99f533b33a..83c960d931 100755 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -135,12 +135,16 @@ QT_USE_NAMESPACE -(id)initWithQMenu:(QPlatformMenu*)qmenu; @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSStatusItem); +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSImageView); +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSMenu); + QT_BEGIN_NAMESPACE class QSystemTrayIconSys { public: QSystemTrayIconSys(QCocoaSystemTrayIcon *sys) { - item = [[QT_MANGLE_NAMESPACE(QNSStatusItem) alloc] initWithSysTray:sys]; + item = [[QNSStatusItem alloc] initWithSysTray:sys]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) { [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item]; @@ -156,7 +160,7 @@ public: #endif [item release]; } - QT_MANGLE_NAMESPACE(QNSStatusItem) *item; + QNSStatusItem *item; }; void QCocoaSystemTrayIcon::init() @@ -310,8 +314,8 @@ QT_END_NAMESPACE @implementation NSStatusItem (Qt) @end -@implementation QT_MANGLE_NAMESPACE(QNSImageView) --(id)initWithParent:(QT_MANGLE_NAMESPACE(QNSStatusItem)*)myParent { +@implementation QNSImageView +-(id)initWithParent:(QNSStatusItem*)myParent { self = [super init]; parent = myParent; down = NO; @@ -406,7 +410,7 @@ QT_END_NAMESPACE } @end -@implementation QT_MANGLE_NAMESPACE(QNSStatusItem) +@implementation QNSStatusItem -(id)initWithSysTray:(QCocoaSystemTrayIcon *)sys { @@ -416,7 +420,7 @@ QT_END_NAMESPACE menu = 0; menuVisible = false; systray = sys; - imageCell = [[QT_MANGLE_NAMESPACE(QNSImageView) alloc] initWithParent:self]; + imageCell = [[QNSImageView alloc] initWithParent:self]; [item setView: imageCell]; } return self; @@ -494,7 +498,7 @@ private: QSystemTrayIconQMenu(); }; -@implementation QT_MANGLE_NAMESPACE(QNSMenu) +@implementation QNSMenu -(id)initWithQMenu:(QPlatformMenu*)qm { self = [super init]; if (self) {