aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-09-12 13:11:33 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-09-12 12:52:00 +0000
commit34a0f1fd7579a70c9d8916754e8201308a29f21d (patch)
tree0258e4ef08e63a142e1b065dd9fad6a7eb189195
parent41f3e8a4d295d79cc4fad31d6ca0d1fa662bdb51 (diff)
Deprecate APIs where other alternatives are preferred
Some of the APIs in this module now have APIs in other parts of Qt, more closely tied to the classes they convert back and forth from. Other APIs have native equivalents that are just as simple as the Qt wrapper, and we want people to use the native APIs since that scales better, and teaches users that they can mix native and Qt APIs. Change-Id: Id587cefe3ab8bee9f7d3e7dc4cb223882d57d325 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/macextras/qmacfunctions.h28
-rw-r--r--src/macextras/qmacfunctions.mm2
-rw-r--r--src/macextras/qmacfunctions_ios.mm2
-rw-r--r--src/macextras/qmacfunctions_mac.mm4
-rw-r--r--src/macextras/qmactoolbaritem.mm3
5 files changed, 31 insertions, 8 deletions
diff --git a/src/macextras/qmacfunctions.h b/src/macextras/qmacfunctions.h
index ccdbd6e..88be13c 100644
--- a/src/macextras/qmacfunctions.h
+++ b/src/macextras/qmacfunctions.h
@@ -65,20 +65,32 @@ class QWindow;
namespace QtMac
{
#if QT_DEPRECATED_SINCE(5,3)
-QT_DEPRECATED Q_MACEXTRAS_EXPORT NSData *toNSData(const QByteArray &data);
-QT_DEPRECATED Q_MACEXTRAS_EXPORT QByteArray fromNSData(const NSData *data);
+QT_DEPRECATED_X("Use QByteArray::toNSData") Q_MACEXTRAS_EXPORT NSData *toNSData(const QByteArray &data);
+QT_DEPRECATED_X("Use QByteArray::fromNSData") Q_MACEXTRAS_EXPORT QByteArray fromNSData(const NSData *data);
#endif
-Q_MACEXTRAS_EXPORT CGImageRef toCGImageRef(const QPixmap &pixmap);
+#if QT_DEPRECATED_SINCE(5, 12)
+QT_DEPRECATED_X("Use QPixmap::toImage and QImage::toCGImage") Q_MACEXTRAS_EXPORT CGImageRef toCGImageRef(const QPixmap &pixmap);
+#endif
Q_MACEXTRAS_EXPORT QPixmap fromCGImageRef(CGImageRef image);
+#if QT_DEPRECATED_SINCE(5, 12)
+# if defined(QT_PLATFORM_UIKIT)
+QT_DEPRECATED_X("Use UIGraphicsGetCurrentContext()")
+# else
+QT_DEPRECATED_X("Use NSGraphicsContext.currentContext.CGContext")
+# endif
Q_MACEXTRAS_EXPORT CGContextRef currentCGContext();
+#endif
#ifdef Q_OS_OSX
-Q_MACEXTRAS_EXPORT void setBadgeLabelText(const QString &text);
-Q_MACEXTRAS_EXPORT QString badgeLabelText();
+#if QT_DEPRECATED_SINCE(5, 12)
+QT_DEPRECATED_X("Use NSApp.dockTile.badgeLabel") Q_MACEXTRAS_EXPORT void setBadgeLabelText(const QString &text);
+QT_DEPRECATED_X("Use NSApp.dockTile.badgeLabel") Q_MACEXTRAS_EXPORT QString badgeLabelText();
+QT_DEPRECATED_X("Use QPixmap::toImage, QImage::toCGImage, and -[NSImage initWithCGImage:size:]")
Q_MACEXTRAS_EXPORT NSImage *toNSImage(const QPixmap &pixmap);
+#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_MACEXTRAS_EXPORT bool isMainWindow(QWindow *window);
@@ -86,8 +98,10 @@ Q_MACEXTRAS_EXPORT bool isMainWindow(QWindow *window);
#endif // Q_OS_OSX
#if defined(QT_PLATFORM_UIKIT) && !defined(Q_OS_WATCHOS)
-Q_MACEXTRAS_EXPORT void setApplicationIconBadgeNumber(int number) __attribute__((availability(ios_app_extension,unavailable)));
-Q_MACEXTRAS_EXPORT int applicationIconBadgeNumber() __attribute__((availability(ios_app_extension,unavailable)));
+#if QT_DEPRECATED_SINCE(5, 12)
+QT_DEPRECATED_X("Use UIApplication.sharedApplication.applicationIconBadgeNumber") Q_MACEXTRAS_EXPORT void setApplicationIconBadgeNumber(int number) __attribute__((availability(ios_app_extension,unavailable)));
+QT_DEPRECATED_X("Use UIApplication.sharedApplication.applicationIconBadgeNumber") Q_MACEXTRAS_EXPORT int applicationIconBadgeNumber() __attribute__((availability(ios_app_extension,unavailable)));
+#endif
#endif // defined(QT_PLATFORM_UIKIT) && !defined(Q_OS_WATCHOS)
}
diff --git a/src/macextras/qmacfunctions.mm b/src/macextras/qmacfunctions.mm
index 1171598..60cb733 100644
--- a/src/macextras/qmacfunctions.mm
+++ b/src/macextras/qmacfunctions.mm
@@ -98,6 +98,7 @@ QByteArray fromNSData(const NSData *data)
}
#endif // QT_DEPRECATED_SINCE
+#if QT_DEPRECATED_SINCE(5, 12)
/*!
\fn CGImageRef QtMac::toCGImageRef(const QPixmap &pixmap)
@@ -124,6 +125,7 @@ CGImageRef toCGImageRef(const QPixmap &pixmap)
return pixmap.toCGImageRef();
#endif
}
+#endif
/*!
\fn QPixmap QtMac::fromCGImageRef(CGImageRef image)
diff --git a/src/macextras/qmacfunctions_ios.mm b/src/macextras/qmacfunctions_ios.mm
index f2b8e57..0aaada8 100644
--- a/src/macextras/qmacfunctions_ios.mm
+++ b/src/macextras/qmacfunctions_ios.mm
@@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE
namespace QtMac
{
+#if QT_DEPRECATED_SINCE(5, 12)
CGContextRef currentCGContext()
{
return UIGraphicsGetCurrentContext();
@@ -77,6 +78,7 @@ int applicationIconBadgeNumber()
{
return [[UIApplication sharedApplication] applicationIconBadgeNumber];
}
+#endif
} // namespace QtMac
diff --git a/src/macextras/qmacfunctions_mac.mm b/src/macextras/qmacfunctions_mac.mm
index 076f269..2e66e23 100644
--- a/src/macextras/qmacfunctions_mac.mm
+++ b/src/macextras/qmacfunctions_mac.mm
@@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE
namespace QtMac
{
+#if QT_DEPRECATED_SINCE(5, 12)
/*!
\fn NSImage* QtMac::toNSImage(const QPixmap &pixmap)
@@ -77,6 +78,7 @@ NSImage* toNSImage(const QPixmap &pixmap)
CFRelease(cgimage);
return image;
}
+#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
/*!
@@ -95,6 +97,7 @@ bool isMainWindow(QWindow *window)
}
#endif
+#if QT_DEPRECATED_SINCE(5, 12)
CGContextRef currentCGContext()
{
return reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
@@ -125,6 +128,7 @@ QString badgeLabelText()
{
return QString::fromNSString([[[NSApplication sharedApplication] dockTile] badgeLabel]);
}
+#endif
} // namespace QtMac
diff --git a/src/macextras/qmactoolbaritem.mm b/src/macextras/qmactoolbaritem.mm
index b215bd8..3bb3a5a 100644
--- a/src/macextras/qmactoolbaritem.mm
+++ b/src/macextras/qmactoolbaritem.mm
@@ -169,7 +169,8 @@ void QMacToolBarItem::setIcon(const QIcon &icon)
return;
if (pixmap.isNull() == false) {
- [d->toolbarItem setImage: QtMac::toNSImage(pixmap)];
+ NSImage *image = [[NSImage alloc] initWithCGImage:pixmap.toImage().toCGImage() size:NSZeroSize];
+ d->toolbarItem.image = [image autorelease];
}
}