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