diff --git src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/cocoa/qcocoamenu.mm
index 981d900..77eca5a 100644
|
|
void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem * |
331 | 331 | |
332 | 332 | // Empty menus on a menubar are hidden by default. If the menu gets |
333 | 333 | // added to the menubar before it contains any item, we need to sync. |
334 | | if (isVisible() && attachedItem().hidden) { |
| 334 | if (isVisible() && [m_attachedItem isHidden]) { |
335 | 335 | if (auto *mb = qobject_cast<QCocoaMenuBar *>(menuParent())) |
336 | 336 | mb->syncMenu(this); |
337 | 337 | } |
diff --git src/plugins/platforms/cocoa/qcocoanativeinterface.mm src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index ee762f6..de47af3 100644
|
|
void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine |
172 | 172 | |
173 | 173 | QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() |
174 | 174 | { |
| 175 | QCFType<CFURLRef> url109; |
| 176 | CFURLRef url = nullptr; |
175 | 177 | const int ExpectedImageWidth = 242; |
176 | 178 | const int ExpectedImageHeight = 414; |
177 | | QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier( |
178 | | CFSTR("com.apple.KeyboardSetupAssistant"), nullptr); |
179 | | if (urls && CFArrayGetCount(urls) > 0) { |
180 | | CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0); |
| 179 | bool ok = false; |
| 180 | if (QSysInfo::macVersion() < QSysInfo::MV_10_10) { |
| 181 | if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"), |
| 182 | 0, 0, &url109) == noErr) { |
| 183 | url = url109; |
| 184 | ok = true; |
| 185 | } |
| 186 | } else { |
| 187 | #if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10) |
| 188 | QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier( |
| 189 | CFSTR("com.apple.KeyboardSetupAssistant"), nullptr); |
| 190 | if (urls && CFArrayGetCount(urls) > 0) { |
| 191 | url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0); |
| 192 | ok = true; |
| 193 | } |
| 194 | #endif |
| 195 | } |
| 196 | if (ok) { |
181 | 197 | QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url); |
182 | 198 | if (bundle) { |
183 | 199 | url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); |
diff --git src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/cocoa/qcocoawindow.mm
index 7f94e31..7516826 100644
|
|
|
60 | 60 | |
61 | 61 | #include <vector> |
62 | 62 | |
| 63 | #if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10) |
| 64 | # define NSWINPROPERTY(w,property,selector) (w).property |
| 65 | #else |
| 66 | # define NSWINPROPERTY(w,property,selector) [(w) selector] |
| 67 | #endif |
| 68 | |
| 69 | #ifndef __has_builtin |
| 70 | # define __has_builtin(x) false |
| 71 | #endif |
| 72 | |
63 | 73 | enum { |
64 | 74 | defaultWindowWidth = 160, |
65 | 75 | defaultWindowHeight = 160 |
… |
… |
static void qt_closePopups() |
320 | 326 | + (void)applicationActivationChanged:(NSNotification*)notification |
321 | 327 | { |
322 | 328 | const id sender = self; |
| 329 | #if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_11) |
| 330 | // ObjC generics were introduced with Xcode 7 (= OS X 10.10) but only allow the compiler |
| 331 | // to generate errors when storing a deviant type. The 10.10SDK on 10.9 doesn't yet |
| 332 | // know about them, so we only support them from 10.11 onwards. |
323 | 333 | NSEnumerator<NSWindow*> *windowEnumerator = nullptr; |
| 334 | #else |
| 335 | NSEnumerator *windowEnumerator = nullptr; |
| 336 | #endif |
324 | 337 | NSApplication *application = [NSApplication sharedApplication]; |
325 | 338 | |
326 | 339 | #if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) |
… |
… |
void QCocoaWindow::show(bool becauseOfAncestor) |
779 | 792 | if ([m_nsWindow isVisible]) |
780 | 793 | return; |
781 | 794 | |
782 | | if (m_view.window.parentWindow && !m_view.window.parentWindow.visible) { |
| 795 | if (m_view.window.parentWindow && !NSWINPROPERTY(m_view.window.parentWindow,visible,isVisible)) { |
783 | 796 | m_hiddenByAncestor = true; // Parent still hidden, don't show now |
784 | 797 | } else if ((becauseOfAncestor == m_hiddenByAncestor) // Was NEITHER explicitly hidden |
785 | 798 | && !m_hiddenByClipping) { // ... NOR clipped |
… |
… |
Qt::WindowState QCocoaWindow::windowState() const |
2095 | 2108 | // FIXME: Support compound states (Qt::WindowStates) |
2096 | 2109 | |
2097 | 2110 | NSWindow *window = m_view.window; |
2098 | | if (window.miniaturized) |
| 2111 | if (NSWINPROPERTY(window, miniaturized, isMiniaturized)) |
2099 | 2112 | return Qt::WindowMinimized; |
2100 | 2113 | if (window.qt_fullScreen) |
2101 | 2114 | return Qt::WindowFullScreen; |
2102 | | if ((window.zoomed && !isTransitioningToFullScreen()) |
| 2115 | if ((NSWINPROPERTY(window, zoomed, isZoomed) && !isTransitioningToFullScreen()) |
2103 | 2116 | || (m_lastReportedWindowState == Qt::WindowMaximized && isTransitioningToFullScreen())) |
2104 | 2117 | return Qt::WindowMaximized; |
2105 | 2118 | |
… |
… |
void QCocoaWindow::applyContentBorderThickness(NSWindow *window) |
2229 | 2242 | |
2230 | 2243 | QMacAutoReleasePool pool; |
2231 | 2244 | |
| 2245 | #if !__has_builtin(__builtin_available) // #if __MAC_OS_X_VERSION_MAX_ALLOWED < 101200 |
| 2246 | bool hasTitlebarAppearsTransparent = [window respondsToSelector:@selector(setTitlebarAppearsTransparent:)]; |
| 2247 | #endif |
| 2248 | |
2232 | 2249 | if (!m_drawContentBorderGradient) { |
2233 | 2250 | [window setStyleMask:[window styleMask] & ~NSTexturedBackgroundWindowMask]; |
2234 | 2251 | [[[window contentView] superview] setNeedsDisplay:YES]; |
2235 | | window.titlebarAppearsTransparent = NO; |
| 2252 | #if __has_builtin(__builtin_available) // #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 |
| 2253 | if (__builtin_available(macOS 10.10, *)) { |
| 2254 | window.titlebarAppearsTransparent = NO; |
| 2255 | } |
| 2256 | #else |
| 2257 | if (hasTitlebarAppearsTransparent) { |
| 2258 | [window setTitlebarAppearsTransparent:NO]; |
| 2259 | } |
| 2260 | #endif |
2236 | 2261 | return; |
2237 | 2262 | } |
2238 | 2263 | |
… |
… |
void QCocoaWindow::applyContentBorderThickness(NSWindow *window) |
2257 | 2282 | int effectiveBottomContentBorderThickness = m_bottomContentBorderThickness; |
2258 | 2283 | |
2259 | 2284 | [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask]; |
2260 | | window.titlebarAppearsTransparent = YES; |
| 2285 | #if __has_builtin(__builtin_available) // #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 |
| 2286 | if (__builtin_available(macOS 10.10, *)) { |
| 2287 | window.titlebarAppearsTransparent = YES; |
| 2288 | } |
| 2289 | #else |
| 2290 | if (hasTitlebarAppearsTransparent) { |
| 2291 | [window setTitlebarAppearsTransparent:YES]; |
| 2292 | } |
| 2293 | #endif |
2261 | 2294 | |
2262 | 2295 | [window setContentBorderThickness:effectiveTopContentBorderThickness forEdge:NSMaxYEdge]; |
2263 | 2296 | [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; |