diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 29 | ||||
-rw-r--r-- | src/widgets/CMakeLists.txt | 26 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 31 |
4 files changed, 31 insertions, 61 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 4a0cf11257..a406cae366 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -31,12 +31,6 @@ public Q_SLOTS: void onAppFocusWindowChanged(QWindow *window); private: - /* - Function to return the default background pixmap. - Needed by QWizard in the Qt widget module. - */ - Q_INVOKABLE QPixmap defaultBackgroundPixmapForQWizard(); - Q_INVOKABLE void clearCurrentThreadCocoaEventDispatcherInterruptFlag(); static void registerDraggedTypes(const QStringList &types); diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index e95a3c0331..58bda2706a 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -75,35 +75,6 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter return nullptr; } -QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() -{ - // Note: starting with macOS 10.14, the KeyboardSetupAssistant app bundle no - // longer contains the "Background.png" image. This function then returns a - // null pixmap. - const int ExpectedImageWidth = 242; - const int ExpectedImageHeight = 414; - QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier( - CFSTR("com.apple.KeyboardSetupAssistant"), nullptr); - if (urls && CFArrayGetCount(urls) > 0) { - CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0); - QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url); - if (bundle) { - url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), nullptr); - if (url) { - QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, nullptr); - QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, nullptr); - 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::clearCurrentThreadCocoaEventDispatcherInterruptFlag() { QCocoaEventDispatcher::clearCurrentThreadCocoaEventDispatcherInterruptFlag(); diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index ed9086e19a..417f6a2d8e 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -684,15 +684,25 @@ qt_internal_extend_target(Widgets CONDITION QT_FEATURE_progressdialog dialogs/qprogressdialog.cpp dialogs/qprogressdialog.h ) -qt_internal_extend_target(Widgets CONDITION QT_FEATURE_wizard - SOURCES - dialogs/qwizard.cpp dialogs/qwizard.h -) +if(QT_FEATURE_wizard) + qt_internal_extend_target(Widgets CONDITION + SOURCES + dialogs/qwizard.cpp dialogs/qwizard.h + ) -qt_internal_extend_target(Widgets CONDITION QT_FEATURE_wizard AND WIN32 - SOURCES - dialogs/qwizard_win.cpp dialogs/qwizard_win_p.h -) + if(APPLE) + set_source_files_properties(dialogs/qwizard.cpp + PROPERTIES + COMPILE_FLAGS "-x objective-c++" + SKIP_PRECOMPILE_HEADERS ON + ) + endif() + + qt_internal_extend_target(Widgets CONDITION WIN32 + SOURCES + dialogs/qwizard_win.cpp dialogs/qwizard_win_p.h + ) +endif() qt_internal_extend_target(Widgets CONDITION QT_FEATURE_accessibility SOURCES diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index cd41efa313..9d260cf4cf 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -29,9 +29,8 @@ #include "qstyleoption.h" #include "qvarlengtharray.h" #if defined(Q_OS_MACOS) -#include <QtCore/QMetaMethod> -#include <QtGui/QGuiApplication> -#include <qpa/qplatformnativeinterface.h> +#include <AppKit/AppKit.h> +#include <QtGui/private/qcoregraphics_p.h> #elif QT_CONFIG(style_windowsvista) #include "qwizard_win_p.h" #include "qtimer.h" @@ -1705,23 +1704,19 @@ void QWizardPrivate::setStyle(QStyle *style) } #ifdef Q_OS_MACOS - QPixmap QWizardPrivate::findDefaultBackgroundPixmap() { - QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance()); - if (!app) - return QPixmap(); - QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface(); - int at = platformNativeInterface->metaObject()->indexOfMethod("defaultBackgroundPixmapForQWizard()"); - if (at == -1) - return QPixmap(); - QMetaMethod defaultBackgroundPixmapForQWizard = platformNativeInterface->metaObject()->method(at); - QPixmap result; - if (!defaultBackgroundPixmapForQWizard.invoke(platformNativeInterface, Q_RETURN_ARG(QPixmap, result))) - return QPixmap(); - return result; -} + auto *keyboardAssistantURL = [NSWorkspace.sharedWorkspace + URLForApplicationWithBundleIdentifier:@"com.apple.KeyboardSetupAssistant"]; + auto *keyboardAssistantBundle = [NSBundle bundleWithURL:keyboardAssistantURL]; + auto *assistantBackground = [keyboardAssistantBundle imageForResource:@"Background"]; + auto size = QSizeF::fromCGSize(assistantBackground.size); + static const QSizeF expectedSize(242, 414); + if (size == expectedSize) + return qt_mac_toQPixmap(assistantBackground, size); + return QPixmap(); +} #endif #if QT_CONFIG(style_windowsvista) @@ -2820,7 +2815,7 @@ void QWizard::setPixmap(WizardPixmap which, const QPixmap &pixmap) Returns the pixmap set for role \a which. By default, the only pixmap that is set is the BackgroundPixmap on - \macos version 10.13 and earlier. + \macos. \sa QWizardPage::pixmap(), {Elements of a Wizard Page} */ |