diff options
author | Liang Qi <liang.qi@digia.com> | 2013-09-26 13:37:08 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-26 20:42:33 +0200 |
commit | 5b70efb1258fd7435e8cfbed1a54abb46db0adcc (patch) | |
tree | 46041057d9010e64e767102c77c6f25175fae364 /src/plugins/platforms/cocoa | |
parent | 5889b239b17b27f0c93fe4f8a56fc1cc32708e8b (diff) |
Mac: QWizard default background pixmap works again
Task-number: QTBUG-26722
Change-Id: I579111b5d34f8e3cdc6bb016d9c0e42ec3ffb8c9
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Stephen Chu <stephen@ju-ju.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 26 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 2e5e65f577..d30b281eb8 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -45,6 +45,7 @@ #include <ApplicationServices/ApplicationServices.h> #include <qpa/qplatformnativeinterface.h> +#include <QtGui/qpixmap.h> QT_BEGIN_NAMESPACE @@ -91,6 +92,11 @@ private: Needed by the native print dialog in the Qt Print Support module. */ Q_INVOKABLE void *NSPrintInfoForPrintEngine(QPrintEngine *printEngine); + /* + Function to return the default background pixmap. + Needed by QWizard in the Qt widget module. + */ + Q_INVOKABLE QPixmap defaultBackgroundPixmapForQWizard(); // QMacPastebardMime support. The mac pasteboard void pointers are // QMacPastebardMime instances from the cocoa plugin or qtmacextras diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index a53a6bca46..972c171f69 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -50,6 +50,7 @@ #include <qbytearray.h> #include <qwindow.h> +#include <qpixmap.h> #include <qpa/qplatformwindow.h> #include "qsurfaceformat.h" #include <qpa/qplatformopenglcontext.h> @@ -154,6 +155,31 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine #endif } +QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() +{ + QCFType<CFURLRef> url; + const int ExpectedImageWidth = 242; + const int ExpectedImageHeight = 414; + if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"), + 0, 0, &url) == noErr) { + QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url); + if (bundle) { + url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); + if (url) { + QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); + QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); + if (image) { + int width = CGImageGetWidth(image); + int height = CGImageGetHeight(image); + if (width == ExpectedImageWidth && height == ExpectedImageHeight) + return QPixmap::fromImage(qt_mac_toQImage(image)); + } + } + } + } + return QPixmap(); +} + void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window) { Q_UNUSED(window); |