summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-03-25 23:20:15 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-03-27 09:00:11 +0000
commit80be47ae06e979a4736b6f86c0ee043d61008ea3 (patch)
treeae620c39d24d7b9b70a58cebde1bd946259f24af
parent78f774da7087f0ee3aeb853eb6a3d3b7db072414 (diff)
macOS: Fix or ignore deprecated API in 10.14
Fixes: QTBUG-82128 Change-Id: I11abfcf7f245a7a25733625b50e207b07abba289 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm28
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h8
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm2
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview_dragging.mm17
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm40
9 files changed, 58 insertions, 52 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index cb019c3775..2947c8c885 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -189,7 +189,7 @@ void QNSWindowBackingStore::flush(QWindow *window, const QRegion &region, const
// its parent/ancestor, and the parent/ancestor being the one locked by AppKit.
// In this case we also need to lock and unlock focus manually.
const bool shouldHandleViewLockManually = [NSView focusView] != view;
- if (shouldHandleViewLockManually && ![view lockFocusIfCanDraw]) {
+ if (shouldHandleViewLockManually && !QT_IGNORE_DEPRECATIONS([view lockFocusIfCanDraw])) {
qWarning() << "failed to lock focus of" << view;
return;
}
@@ -263,14 +263,13 @@ void QNSWindowBackingStore::flush(QWindow *window, const QRegion &region, const
// -------------------------------------------------------------------------
if (shouldHandleViewLockManually)
- [view unlockFocus];
+ QT_IGNORE_DEPRECATIONS([view unlockFocus]);
if (drawingOutsideOfDisplayCycle) {
redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]);
- [view.window flushWindow];
+ QT_IGNORE_DEPRECATIONS([view.window flushWindow]);
}
-
// Done flushing to NSWindow backingstore
QCocoaWindow *topLevelCocoaWindow = static_cast<QCocoaWindow *>(topLevelWindow->handle());
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index ccb6e20071..9ca3892cbb 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -145,17 +145,17 @@ void QCocoaGLContext::initialize()
// --------------------- Set NSOpenGLContext properties ---------------------
const GLint interval = m_format.swapInterval() >= 0 ? m_format.swapInterval() : 1;
- [m_context setValues:&interval forParameter:NSOpenGLCPSwapInterval];
+ [m_context setValues:&interval forParameter:NSOpenGLContextParameterSwapInterval];
if (m_format.alphaBufferSize() > 0) {
int zeroOpacity = 0;
- [m_context setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity];
+ [m_context setValues:&zeroOpacity forParameter:NSOpenGLContextParameterSurfaceOpacity];
}
// OpenGL surfaces can be ordered either above(default) or below the NSWindow
// FIXME: Promote to QSurfaceFormat option or property
const GLint order = qt_mac_resolveOption(1, "QT_MAC_OPENGL_SURFACE_ORDER");
- [m_context setValues:&order forParameter:NSOpenGLCPSurfaceOrder];
+ [m_context setValues:&order forParameter:NSOpenGLContextParameterSurfaceOrder];
updateSurfaceFormat();
@@ -342,7 +342,7 @@ void QCocoaGLContext::updateSurfaceFormat()
return value;
};
- m_format.setSwapInterval(glContextParameter(NSOpenGLCPSwapInterval));
+ m_format.setSwapInterval(glContextParameter(NSOpenGLContextParameterSwapInterval));
if (oldContext)
[oldContext makeCurrentContext];
@@ -390,7 +390,7 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
// Clear the current drawable and reset the active window, so that GL
// commands that don't target a specific FBO will not end up stomping
// on the previously set drawable.
- qCDebug(lcQpaOpenGLContext) << "Clearing current drawable" << m_context.view << "for" << m_context;
+ qCDebug(lcQpaOpenGLContext) << "Clearing current drawable" << QT_IGNORE_DEPRECATIONS(m_context.view) << "for" << m_context;
[m_context clearDrawable];
return true;
}
@@ -399,7 +399,7 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
auto *cocoaWindow = static_cast<QCocoaWindow *>(surface);
QNSView *view = qnsview_cast(cocoaWindow->view());
- if (view == m_context.view)
+ if (view == QT_IGNORE_DEPRECATIONS(m_context.view))
return true;
prepareDrawable(cocoaWindow);
@@ -412,7 +412,7 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
auto updateCallback = [this, view]() {
Q_ASSERT(QThread::currentThread() == qApp->thread());
- if (m_context.view != view)
+ if (QT_IGNORE_DEPRECATIONS(m_context.view) != view)
return;
m_needsUpdate = true;
};
@@ -423,7 +423,7 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
m_updateObservers.append(QMacNotificationObserver(view, NSViewFrameDidChangeNotification, updateCallback));
m_updateObservers.append(QMacNotificationObserver(view.window, NSWindowDidChangeScreenNotification, updateCallback));
} else {
- m_updateObservers.append(QMacNotificationObserver(view, NSViewGlobalFrameDidChangeNotification, updateCallback));
+ m_updateObservers.append(QMacNotificationObserver(view, QT_IGNORE_DEPRECATIONS(NSViewGlobalFrameDidChangeNotification), updateCallback));
}
m_updateObservers.append(QMacNotificationObserver([NSApplication sharedApplication],
@@ -435,14 +435,14 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface)
// have the same effect as an update.
// Now we are ready to associate the view with the context
- m_context.view = view;
- if (m_context.view != view) {
+ QT_IGNORE_DEPRECATIONS(m_context.view) = view;
+ if (QT_IGNORE_DEPRECATIONS(m_context.view) != view) {
qCInfo(lcQpaOpenGLContext) << "Failed to set" << view << "as drawable for" << m_context;
m_updateObservers.clear();
return false;
}
- qCInfo(lcQpaOpenGLContext) << "Set drawable for" << m_context << "to" << m_context.view;
+ qCInfo(lcQpaOpenGLContext) << "Set drawable for" << m_context << "to" << QT_IGNORE_DEPRECATIONS(m_context.view);
return true;
}
@@ -467,7 +467,7 @@ void QCocoaGLContext::prepareDrawable(QCocoaWindow *platformWindow)
}
}
- view.wantsBestResolutionOpenGLSurface = prefersBestResolutionOpenGLSurface;
+ QT_IGNORE_DEPRECATIONS(view.wantsBestResolutionOpenGLSurface) = prefersBestResolutionOpenGLSurface;
}
// NSOpenGLContext is not re-entrant. Even when using separate contexts per thread,
@@ -483,7 +483,7 @@ void QCocoaGLContext::update()
QMacAutoReleasePool pool;
QMutexLocker locker(&s_reentrancyMutex);
- qCInfo(lcQpaOpenGLContext) << "Updating" << m_context << "for" << m_context.view;
+ qCInfo(lcQpaOpenGLContext) << "Updating" << m_context << "for" << QT_IGNORE_DEPRECATIONS(m_context.view);
[m_context update];
}
@@ -501,7 +501,7 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
return;
}
- if (m_context.view.layer) {
+ if (QT_IGNORE_DEPRECATIONS(m_context.view).layer) {
// Flushing an NSOpenGLContext will hit the screen immediately, ignoring
// any Core Animation transactions in place. This may result in major
// visual artifacts if the flush happens out of sync with the size
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index 69a1854598..cbe86e7e48 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -70,6 +70,14 @@ Q_DECLARE_LOGGING_CATEGORY(lcQpaDrawing)
Q_DECLARE_LOGGING_CATEGORY(lcQpaMouse)
Q_DECLARE_LOGGING_CATEGORY(lcQpaScreen)
+#ifndef QT_IGNORE_DEPRECATIONS
+#define QT_IGNORE_DEPRECATIONS(statement) \
+ QT_WARNING_PUSH \
+ QT_WARNING_DISABLE_DEPRECATED \
+ statement \
+ QT_WARNING_POP
+#endif
+
class QPixmap;
class QString;
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index c9eafa81d0..dab67268e3 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -514,8 +514,8 @@ QT_END_NAMESPACE
- (NSButton *)createButtonWithTitle:(const char *)title
{
NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect];
- button.buttonType = NSMomentaryLightButton;
- button.bezelStyle = NSRoundedBezelStyle;
+ button.buttonType = NSButtonTypeMomentaryLight;
+ button.bezelStyle = NSBezelStyleRounded;
const QString &cleanTitle = QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", title));
// FIXME: Not obvious, from Cocoa's documentation, that QString::toNSString() makes a deep copy
button.title = (NSString *)cleanTitle.toCFString();
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index a2100a6369..cba2babb8d 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -342,7 +342,7 @@ NSMenuItem *QCocoaMenuItem::sync()
m_native.image = [NSImage imageFromQIcon:m_icon withSize:m_iconSize];
- m_native.state = m_checked ? NSOnState : NSOffState;
+ m_native.state = m_checked ? NSControlStateValueOn : NSControlStateValueOff;
return m_native;
}
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 8e7c86a0ef..bb1b1fc02e 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -282,7 +282,7 @@ void QCocoaSystemTrayIcon::statusItemClicked()
emit activated(activationReason);
if (NSMenu *menu = m_menu ? m_menu->nsMenu() : nil)
- [m_statusItem popUpStatusItemMenu:menu];
+ QT_IGNORE_DEPRECATIONS([m_statusItem popUpStatusItemMenu:menu]);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm
index 654647b35a..c5d823693c 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.mm
+++ b/src/plugins/platforms/cocoa/qmacclipboard.mm
@@ -594,7 +594,7 @@ QString qt_mac_get_pasteboardString(PasteboardRef paste)
pb = [NSPasteboard generalPasteboard];
}
if (pb) {
- NSString *text = [pb stringForType:NSStringPboardType];
+ NSString *text = [pb stringForType:NSPasteboardTypeString];
if (text)
return QString::fromNSString(text);
}
diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm
index 463e3c5579..2e88b6a08f 100644
--- a/src/plugins/platforms/cocoa/qnsview_dragging.mm
+++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm
@@ -47,15 +47,14 @@
NSString * const mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName";
NSMutableArray<NSString *> *supportedTypes = [NSMutableArray<NSString *> arrayWithArray:@[
- NSColorPboardType,
- NSFilenamesPboardType, NSStringPboardType,
- NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType,
- NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType,
- NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType,
- NSRTFDPboardType, NSHTMLPboardType,
- NSURLPboardType, NSPDFPboardType, NSVCardPboardType,
- NSFilesPromisePboardType, NSInkTextPboardType,
- NSMultipleTextSelectionPboardType, mimeTypeGeneric]];
+ NSPasteboardTypeColor, NSPasteboardTypeString,
+ NSPasteboardTypeFileURL, @"com.adobe.encapsulated-postscript", NSPasteboardTypeTIFF,
+ NSPasteboardTypeRTF, NSPasteboardTypeTabularText, NSPasteboardTypeFont,
+ NSPasteboardTypeRuler, NSFileContentsPboardType,
+ NSPasteboardTypeRTFD , NSPasteboardTypeHTML,
+ NSPasteboardTypeURL, NSPasteboardTypePDF, (NSString *)kUTTypeVCard,
+ (NSString *)kPasteboardTypeFileURLPromise, (NSString *)kUTTypeInkText,
+ NSPasteboardTypeMultipleTextSelection, mimeTypeGeneric]];
// Add custom types supported by the application
for (const QString &customType : qt_mac_enabledDraggedTypes())
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index f8e423456f..70e97b0295 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -1641,24 +1641,24 @@ bool QMacStylePrivate::CocoaControl::getCocoaButtonTypeAndBezelStyle(NSButtonTyp
{
switch (type) {
case Button_CheckBox:
- *buttonType = NSSwitchButton;
- *bezelStyle = NSRegularSquareBezelStyle;
+ *buttonType = NSButtonTypeSwitch;
+ *bezelStyle = NSBezelStyleRegularSquare;
break;
case Button_Disclosure:
- *buttonType = NSOnOffButton;
- *bezelStyle = NSDisclosureBezelStyle;
+ *buttonType = NSButtonTypeOnOff;
+ *bezelStyle = NSBezelStyleDisclosure;
break;
case Button_RadioButton:
- *buttonType = NSRadioButton;
- *bezelStyle = NSRegularSquareBezelStyle;
+ *buttonType = NSButtonTypeRadio;
+ *bezelStyle = NSBezelStyleRegularSquare;
break;
case Button_SquareButton:
- *buttonType = NSPushOnPushOffButton;
- *bezelStyle = NSShadowlessSquareBezelStyle;
+ *buttonType = NSButtonTypePushOnPushOff;
+ *bezelStyle = NSBezelStyleShadowlessSquare;
break;
case Button_PushButton:
- *buttonType = NSPushOnPushOffButton;
- *bezelStyle = NSRoundedBezelStyle;
+ *buttonType = NSButtonTypePushOnPushOff;
+ *bezelStyle = NSBezelStyleRounded;
break;
default:
return false;
@@ -1977,8 +1977,8 @@ NSCell *QMacStylePrivate::cocoaCell(CocoaControl widget) const
break;
case Button_Disclosure: {
NSButtonCell *bc = [[NSButtonCell alloc] init];
- bc.buttonType = NSOnOffButton;
- bc.bezelStyle = NSDisclosureBezelStyle;
+ bc.buttonType = NSButtonTypeOnOff;
+ bc.bezelStyle = NSBezelStyleDisclosure;
cell = bc;
break;
}
@@ -3261,8 +3261,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *tb = static_cast<NSButton *>(d->cocoaControl(cw));
tb.enabled = isEnabled;
- tb.state = (opt->state & State_NoChange) ? NSMixedState :
- (opt->state & State_On) ? NSOnState : NSOffState;
+ tb.state = (opt->state & State_NoChange) ? NSControlStateValueMixed :
+ (opt->state & State_On) ? NSControlStateValueOn : NSControlStateValueOff;
[tb highlight:isPressed];
const auto vOffset = [=] {
// As measured
@@ -3284,7 +3284,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
break;
const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Button_Disclosure, QStyleHelper::SizeLarge);
NSButtonCell *triangleCell = static_cast<NSButtonCell *>(d->cocoaCell(cw));
- [triangleCell setState:(opt->state & State_Open) ? NSOnState : NSOffState];
+ [triangleCell setState:(opt->state & State_Open) ? NSControlStateValueOn : NSControlStateValueOff];
bool viewHasFocus = (w && w->hasFocus()) || (opt->state & State_HasFocus);
[triangleCell setBackgroundStyle:((opt->state & State_Selected) && viewHasFocus) ? NSBackgroundStyleDark : NSBackgroundStyleLight];
@@ -3703,7 +3703,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
pb.enabled = isEnabled;
[pb highlight:isPressed];
- pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState;
+ pb.state = isHighlighted && !isPressed ? NSControlStateValueOn : NSControlStateValueOff;
d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef, const CGRect &r) {
[pb.cell drawBezelWithFrame:r inView:pb.superview];
});
@@ -3928,7 +3928,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
pb.enabled = isEnabled;
[pb highlight:isPressed];
// Set off state when inactive. See needsInactiveHack for when it's selected
- pb.state = (isActive && isSelected && !isPressed) ? NSOnState : NSOffState;
+ pb.state = (isActive && isSelected && !isPressed) ? NSControlStateValueOn : NSControlStateValueOff;
const auto drawBezelBlock = ^(CGContextRef ctx, const CGRect &r) {
CGContextClipToRect(ctx, opt->rect.toCGRect());
@@ -5693,12 +5693,12 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
const auto cw = QMacStylePrivate::CocoaControl(ct, cs);
auto *pb = static_cast<NSButton *>(d->cocoaControl(cw));
- pb.bezelStyle = NSShadowlessSquareBezelStyle; // TODO Use NSTexturedRoundedBezelStyle in the future.
+ pb.bezelStyle = NSBezelStyleShadowlessSquare; // TODO Use NSTexturedRoundedBezelStyle in the future.
pb.frame = opt->rect.toCGRect();
- pb.buttonType = NSPushOnPushOffButton;
+ pb.buttonType = NSButtonTypePushOnPushOff;
pb.enabled = isEnabled;
[pb highlight:isPressed];
- pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState;
+ pb.state = isHighlighted && !isPressed ? NSControlStateValueOn : NSControlStateValueOff;
const auto buttonRect = proxy()->subControlRect(cc, tb, SC_ToolButton, widget);
d->drawNSViewInRect(pb, buttonRect, p, ^(CGContextRef, const CGRect &rect) {
[pb.cell drawBezelWithFrame:rect inView:pb];