From 5f71203dd0129de76220f7a3198111a0d2186667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 3 Jan 2013 09:38:10 +0100 Subject: Cocoa: export setDockMenu Change-Id: I1eb35c34427660d2662f310a3e8c4e5ba42e08eb Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoanativeinterface.h | 4 ++++ src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 13 +++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 34e8fb61e2..592ede4617 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE class QWidget; class QPlatformPrinterSupport; class QPrintEngine; +class QPlatformMenu; class QCocoaNativeInterface : public QPlatformNativeInterface { @@ -92,6 +93,9 @@ private: static void addToMimeList(void *macPasteboardMime); static void removeFromMimeList(void *macPasteboardMime); static void registerDraggedTypes(const QStringList &types); + + // Dock menu support + static void setDockMenu(QPlatformMenu *platformMenu); }; #endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 08084b5200..14bb82bc7e 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -42,6 +42,7 @@ #include "qcocoanativeinterface.h" #include "qcocoaglcontext.h" #include "qcocoawindow.h" +#include "qcocoamenu.h" #include "qcocoamenubar.h" #include "qmacmime.h" @@ -60,6 +61,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE QCocoaNativeInterface::QCocoaNativeInterface() @@ -103,6 +106,8 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter return NativeResourceForIntegrationFunction(QCocoaNativeInterface::removeFromMimeList); if (resource.toLower() == "registerdraggedtypes") return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerDraggedTypes); + if (resource.toLower() == "setdockmenu") + return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setDockMenu); return 0; } @@ -170,4 +175,12 @@ void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types) qt_mac_registerDraggedTypes(types); } +void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu) +{ + QCocoaMenu *cocoaPlatformMenu = static_cast(platformMenu); + NSMenu *menu = cocoaPlatformMenu->nsMenu(); + // setDockMenu seems to be undocumented, but this is what Qt 4 did. + [NSApp setDockMenu: menu]; +} + QT_END_NAMESPACE -- cgit v1.2.3 From 7bb43454b83ab0f055248b80defe0b985e59ed64 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sun, 27 Jan 2013 12:58:38 +0800 Subject: Fix minor typos in docs, printed messages & comments Missing apostrophes Change-Id: I3ef5e9d494fb7a37f8e6075f24cd3a274e572c23 Reviewed-by: Jerome Pasion --- src/plugins/platforms/cocoa/qmacclipboard.mm | 2 +- src/plugins/platforms/cocoa/qnsview.mm | 2 +- src/plugins/platforms/cocoa/qprintengine_mac.mm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 6fcf4d5746..95143fd8ea 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -135,7 +135,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id, } if (!promise.itemId && flavorAsQString == QLatin1String("com.trolltech.qt.MimeTypeName")) { - // we have promised this data, but wont be able to convert, so return null data. + // we have promised this data, but won't be able to convert, so return null data. // This helps in making the application/x-qt-mime-type-name hidden from normal use. QByteArray ba; QCFType data = CFDataCreate(0, (UInt8*)ba.constData(), ba.size()); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index b822061feb..da3e6277c6 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1025,7 +1025,7 @@ static QTouchDevice *touchDevice = 0; - (NSUInteger)characterIndexForPoint:(NSPoint)aPoint { - // We dont support cursor movements using mouse while composing. + // We don't support cursor movements using mouse while composing. Q_UNUSED(aPoint); return NSNotFound; } diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index a5382c5ef6..54019372bc 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -109,7 +109,7 @@ bool QMacPrintEngine::end() if (d->state == QPrinter::Aborted) return true; // I was just here a function call ago :) if (d->paintEngine->type() == QPaintEngine::CoreGraphics) { - // We dont need the paint engine to call restoreGraphicsState() + // We don't need the paint engine to call restoreGraphicsState() static_cast(d->paintEngine)->d_func()->stackCount = 0; static_cast(d->paintEngine)->d_func()->hd = 0; } -- cgit v1.2.3 From 2aef22b77aa15eb0863a9585af77ccab04425dbd Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 10 Dec 2012 11:19:52 +0100 Subject: Mac: make windows not restorable on 10.7 and later MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default value for NSWindow::setRestorable: is true, it means application will have some information for each window stored. After a crash happened and application relaunched, the application tries to restore those windows from the broken file. And then the "Retore Windows" will pop up. There is no workaround for application users or develoeprs. What they can do is to manually remove the the saved application state file for the applicaiton. To avoid that, better to switch it off. Task-number: QTBUG-28281 Change-Id: I8ce3cd94f5ae81d7877a346743ca4e0e188baa02 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 551e51bfa9..463c065c9a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -710,6 +710,11 @@ NSWindow * QCocoaWindow::createNSWindow() createdWindow = window; } +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if ([createdWindow respondsToSelector:@selector(setRestorable:)]) + [createdWindow setRestorable: NO]; +#endif + NSInteger level = windowLevel(flags); [createdWindow setLevel:level]; m_windowModality = window()->modality(); -- cgit v1.2.3 From 70d38f078e2bd853508d073ea88b59b3a857a83a Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 18 Dec 2012 10:32:08 +0100 Subject: Mac: Ensure the native filedialog sets file name when saving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The name field string was not set in native dialog when one was present. Task-number: QTBUG-28342 Change-Id: I243b491c8bc094d45f25be96b3bde8eccbb65acd Reviewed-by: Andy Shaw Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 7992461032..61646041fb 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -250,6 +250,7 @@ static QString strippedText(QString s) [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; + [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : nil]; // Call processEvents in case the event dispatcher has been interrupted, and needs to do // cleanup of modal sessions. Do this before showing the native dialog, otherwise it will @@ -275,6 +276,7 @@ static QString strippedText(QString s) [mSavePanel setDirectoryURL:selectable ? [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath())] : [NSURL fileURLWithPath:QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.path())]]; + [mSavePanel setNameFieldStringValue:selectable ? QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName()) : nil]; NSWindow *nsparent = static_cast(qGuiApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parent)); [mSavePanel beginSheetModalForWindow:nsparent completionHandler:^(NSInteger result){ -- cgit v1.2.3 From 393fcf69dc9efc5f990fc37e2205112ae4620562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 4 Jan 2013 11:11:49 +0100 Subject: Cocoa: prevent scale factor value of 0. Check that the NSWindow pointer is valid before calling backingScaleFactor. Change-Id: Ia23cbb4058b7d0fece008bc437f8bfec6c0ddebe Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index fd0f4529cc..7f022da4c3 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -67,7 +67,7 @@ QPaintDevice *QCocoaBackingStore::paintDevice() #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { QCocoaWindow *cocoaWindow = static_cast(window()->handle()); - if (cocoaWindow && cocoaWindow->m_contentView) { + if (cocoaWindow && cocoaWindow->m_contentView && [cocoaWindow->m_contentView window]) { scaleFactor = int([[cocoaWindow->m_contentView window] backingScaleFactor]); } } -- cgit v1.2.3 From 655ba5755696df8e2594bca9f7696ab621f5afc3 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 5 Feb 2013 13:39:33 +0100 Subject: Cocoa QPA: Fix compilation error The error appeared with latest clang as of Feb. 5, 2013. Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn) Target: x86_64-apple-darwin12.2.0 Change-Id: I8df8cccc941ac03a7a997bdd5afe095b7b6f65d3 Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/cocoa/qcocoawindow.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 3b5be0af0f..324a43c8ae 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -49,7 +49,8 @@ #include "qcocoaglcontext.h" #include "qnsview.h" -class QT_PREPEND_NAMESPACE(QCocoaWindow); + +QT_FORWARD_DECLARE_CLASS(QCocoaWindow) @interface QNSWindow : NSWindow { @public QCocoaWindow *m_cocoaPlatformWindow; -- cgit v1.2.3 From 2be39c68320ab058ac5428ed1a9f0bb69a6c5893 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 6 Feb 2013 16:29:58 +0100 Subject: Cocoa: Make tool window receive mouse events also when its parent is modal We need to check for the Cocoa window class because of the way currently QDockWidget works. Change-Id: If69c7327c168518614fe884defa79deb358e260d Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 463c065c9a..14d62c9fca 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -301,9 +301,11 @@ void QCocoaWindow::setVisible(bool visible) [m_nsWindow orderFront: nil]; } - // We want the events to properly reach the popup and dialog - if (window()->type() == Qt::Popup || window()->type() == Qt::Dialog) + // We want the events to properly reach the popup, dialog, and tool + if ((window()->type() == Qt::Popup || window()->type() == Qt::Dialog || window()->type() == Qt::Tool) + && [m_nsWindow isKindOfClass:[NSPanel class]]) { [(NSPanel *)m_nsWindow setWorksWhenModal:YES]; + } } } else { [m_contentView setHidden:NO]; -- cgit v1.2.3 From 5a46251de36e568513bca70b82a1d6cc9c9cb0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 29 Jan 2013 09:11:21 +0100 Subject: Fix devicePixelRatio getter for embedded QWindows. m_nsWindow is not set for non-toplevel QWindows, causing devicePixelRatio to always return 1. Use [m_contentView window] instead. Change-Id: I6689a70812c9484f103b5e706fe4c1b76406b750 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoawindow.mm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 14d62c9fca..45100f9906 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -837,11 +837,9 @@ QCocoaMenuBar *QCocoaWindow::menubar() const qreal QCocoaWindow::devicePixelRatio() const { - if (!m_nsWindow) - return 1.0; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { - return qreal([m_nsWindow backingScaleFactor]); + return qreal([[m_contentView window] backingScaleFactor]); } else #endif { -- cgit v1.2.3 From 784b9655597d2c23a00d57181b1853e6df07fdf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 7 Jan 2013 22:38:10 +0100 Subject: Cocoa: Export QImage <-> CGImage conversion funcs. For implementing to/fromMacCGImageRef in QtMacExtras. These do not depend on internal Qt state. The main reason for exporting them is to keep the implementation in one place to ease maintenance. Refactor qt_mac_cg_context to support QImage. Add qt_mac_toQImage. Change-Id: Ia9c226ed52d087b2c6b47aa8210ed8f2645b9cf2 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoahelpers.h | 3 +- src/plugins/platforms/cocoa/qcocoahelpers.mm | 55 ++++++++++++++-------- .../platforms/cocoa/qcocoanativeinterface.h | 6 +++ .../platforms/cocoa/qcocoanativeinterface.mm | 16 +++++++ src/plugins/platforms/cocoa/qcocoatheme.mm | 4 +- 5 files changed, 61 insertions(+), 23 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index b065c72e68..831ab579f5 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -158,8 +158,9 @@ public: } }; -CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); +CGContextRef qt_mac_cg_context(QPaintDevice *pdev); CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy); +QImage qt_mac_toQImage(CGImageRef image); QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 0c5d26054c..91a6f5a4c7 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -719,35 +719,38 @@ QString qt_mac_removeAmpersandEscapes(QString s) \warning This function is only available on Mac OS X. \warning This function is duplicated in qmacstyle_mac.mm */ -CGContextRef qt_mac_cg_context(const QPaintDevice *pdev) +CGContextRef qt_mac_cg_context(QPaintDevice *pdev) { - if (pdev->devType() == QInternal::Pixmap) { - const QPixmap *pm = static_cast(pdev); - CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev); - uint flags = kCGImageAlphaPremultipliedFirst; - flags |= kCGBitmapByteOrder32Host; - CGContextRef ret = 0; + // In Qt 5, QWidget and QPixmap (and QImage) paint devices are all QImages under the hood. + QImage *image = 0; + if (pdev->devType() == QInternal::Image) { + image = static_cast(pdev); + } else if (pdev->devType() == QInternal::Pixmap) { + const QPixmap *pm = static_cast(pdev); QPlatformPixmap *data = const_cast(pm)->data_ptr().data(); if (data && data->classId() == QPlatformPixmap::RasterClass) { - QImage *image = data->buffer(); - ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(), - 8, image->bytesPerLine(), colorspace, flags); + image = data->buffer(); } else { qDebug() << "qt_mac_cg_context: Unsupported pixmap class"; } - - CGContextTranslateCTM(ret, 0, pm->height()); - CGContextScaleCTM(ret, 1, -1); - return ret; } else if (pdev->devType() == QInternal::Widget) { - //CGContextRef ret = static_cast(static_cast(pdev)->macCGHandle()); - ///CGContextRetain(ret); - //return ret; + // TODO test: image = static_cast(static_cast(pdev)->backingStore()->paintDevice()); qDebug() << "qt_mac_cg_context: not implemented: Widget class"; - return 0; } - return 0; + + if (!image) + return 0; // Context type not supported. + + CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pdev); + uint flags = kCGImageAlphaPremultipliedFirst; + flags |= kCGBitmapByteOrder32Host; + CGContextRef ret = 0; + ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(), + 8, image->bytesPerLine(), colorspace, flags); + CGContextTranslateCTM(ret, 0, image->height()); + CGContextScaleCTM(ret, 1, -1); + return ret; } CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy) @@ -841,4 +844,18 @@ CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy) return cgImage; } +QImage qt_mac_toQImage(CGImageRef image) +{ + const size_t w = CGImageGetWidth(image), + h = CGImageGetHeight(image); + QImage ret(w, h, QImage::Format_ARGB32_Premultiplied); + ret.fill(Qt::transparent); + CGRect rect = CGRectMake(0, 0, w, h); + CGContextRef ctx = qt_mac_cg_context(&ret); + qt_mac_drawCGImage(ctx, &rect, image); + CGContextRelease(ctx); + return ret; +} + + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 592ede4617..9506f86238 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -42,6 +42,8 @@ #ifndef QCOCOANATIVEINTERFACE_H #define QCOCOANATIVEINTERFACE_H +#include + #include QT_BEGIN_NAMESPACE @@ -96,6 +98,10 @@ private: // Dock menu support static void setDockMenu(QPlatformMenu *platformMenu); + + // QImage <-> CGImage conversion functions + static CGImageRef qImageToCGImage(const QImage &image); + static QImage cgImageToQImage(CGImageRef image); }; #endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 14bb82bc7e..bd3a909137 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -45,6 +45,7 @@ #include "qcocoamenu.h" #include "qcocoamenubar.h" #include "qmacmime.h" +#include "qcocoahelpers.h" #include #include @@ -108,6 +109,10 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerDraggedTypes); if (resource.toLower() == "setdockmenu") return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setDockMenu); + if (resource.toLower() == "qimagetocgimage") + return NativeResourceForIntegrationFunction(QCocoaNativeInterface::qImageToCGImage); + if (resource.toLower() == "cgimagetoqimage") + return NativeResourceForIntegrationFunction(QCocoaNativeInterface::cgImageToQImage); return 0; } @@ -183,4 +188,15 @@ void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu) [NSApp setDockMenu: menu]; } +CGImageRef QCocoaNativeInterface::qImageToCGImage(const QImage &image) +{ + return qt_mac_toCGImage(image, false, 0); +} + +QImage QCocoaNativeInterface::cgImageToQImage(CGImageRef image) +{ + return qt_mac_toQImage(image); +} + + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 0845ab8e94..beaa50da6d 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -53,6 +53,7 @@ #include "qcocoamenuitem.h" #include "qcocoamenu.h" #include "qcocoamenubar.h" +#include "qcocoahelpers.h" #include #include @@ -137,9 +138,6 @@ const QFont *QCocoaTheme::font(Font type) const return m_fonts.value(type, 0); } -// Defined in qpaintengine_mac.mm -extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); - //! \internal QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height) { -- cgit v1.2.3