diff options
author | Romain Perier <romain.perier@gmail.com> | 2013-05-11 09:28:53 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-16 10:45:04 +0200 |
commit | 94c7002df30d931df13b3bae9d4c46ff1e6f714c (patch) | |
tree | 17cb12d18eb5437ad4fbf16f5e8d2804924ffcaa /src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | |
parent | adaa50e37da1fddada874a289792a1bd95c5aebc (diff) |
Improve Qt-in-namespace implementation in the Cocoa platform plugin
Objective-C++ does not support namespaces. In order to make this work,
we decorate each symbol with suffix using the macro QT_MANGLE_NAMESPACE.
However, with such a technic each public symbol needs to be explicitly exported through
this macro. The use of @compatibility_alias allows to define alias to use it
automatically and transparently.
Task-number: QTBUG-23946
Change-Id: Id521b8160bab126fda40a9d960277b1c04cc8b66
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 20 |
1 files changed, 11 insertions, 9 deletions
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<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate) release]; + [reinterpret_cast<QNSColorPanelDelegate *>(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<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); if ([delegate runApplicationModalPanel]) emit accept(); else @@ -378,14 +380,14 @@ void QCocoaColorDialogHelper::hide() { if (!mDelegate) return; - [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate)->mColorPanel close]; + [reinterpret_cast<QNSColorPanelDelegate *>(mDelegate)->mColorPanel close]; } void QCocoaColorDialogHelper::setCurrentColor(const QColor &color) { if (!mDelegate) createNSColorPanelDelegate(); - QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(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<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate)->mQtColor; + return reinterpret_cast<QNSColorPanelDelegate *>(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<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(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<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); + QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); [delegate closePanel]; return true; } |