Deprecate QMacNativeWidget and QMacCocoaViewContainer

Change-Id: I489870f97dcf7b54a4427ead3a9e627dd938f4ca
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-04-03 15:00:58 +02:00
parent eaada70d4e
commit d6fe9c2160
6 changed files with 19 additions and 5 deletions

View File

@ -1306,6 +1306,14 @@
# define QT_WARNING_DISABLE_DEPRECATED # define QT_WARNING_DISABLE_DEPRECATED
#endif #endif
#ifndef QT_IGNORE_DEPRECATIONS
#define QT_IGNORE_DEPRECATIONS(statement) \
QT_WARNING_PUSH \
QT_WARNING_DISABLE_DEPRECATED \
statement \
QT_WARNING_POP
#endif
/* /*
Proper for-scoping in MIPSpro CC Proper for-scoping in MIPSpro CC
*/ */

View File

@ -47,8 +47,10 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if QT_DEPRECATED_SINCE(5, 15)
class QMacCocoaViewContainerPrivate; class QMacCocoaViewContainerPrivate;
class Q_WIDGETS_EXPORT QMacCocoaViewContainer : public QWidget class QT_DEPRECATED_X("Use QWindow::fromWinId and QWidget::createWindowContainer instead")
Q_WIDGETS_EXPORT QMacCocoaViewContainer : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -61,6 +63,7 @@ public:
private: private:
Q_DECLARE_PRIVATE(QMacCocoaViewContainer) Q_DECLARE_PRIVATE(QMacCocoaViewContainer)
}; };
#endif
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -114,7 +114,7 @@ QT_BEGIN_NAMESPACE
class QMacCocoaViewContainerPrivate : public QWidgetPrivate class QMacCocoaViewContainerPrivate : public QWidgetPrivate
{ {
Q_DECLARE_PUBLIC(QMacCocoaViewContainer) QT_IGNORE_DEPRECATIONS(Q_DECLARE_PUBLIC(QMacCocoaViewContainer))
public: public:
NSView *nsview; NSView *nsview;
QMacCocoaViewContainerPrivate(); QMacCocoaViewContainerPrivate();

View File

@ -47,7 +47,9 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class Q_WIDGETS_EXPORT QMacNativeWidget : public QWidget #if QT_DEPRECATED_SINCE(5, 15)
class QT_DEPRECATED_X("Use QWidget::winId instead")
Q_WIDGETS_EXPORT QMacNativeWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -60,6 +62,7 @@ public:
protected: protected:
bool event(QEvent *ev) override; bool event(QEvent *ev) override;
}; };
#endif
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -3549,7 +3549,7 @@ void QMenu::actionEvent(QActionEvent *e)
if (QWidget *widget = d->widgetItems.value(wa)) { if (QWidget *widget = d->widgetItems.value(wa)) {
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
QWidget *p = widget->parentWidget(); QWidget *p = widget->parentWidget();
if (p != this && qobject_cast<QMacNativeWidget *>(p)) { if (p != this && QT_IGNORE_DEPRECATIONS(qobject_cast<QMacNativeWidget *>(p))) {
// This widget was reparented into a native Mac view // This widget was reparented into a native Mac view
// (see QMenuPrivate::moveWidgetToPlatformItem). // (see QMenuPrivate::moveWidgetToPlatformItem).
// Reset the parent and delete the native widget. // Reset the parent and delete the native widget.

View File

@ -125,7 +125,7 @@ void QMenu::setAsDockMenu()
void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem* item) void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem* item)
{ {
QMacNativeWidget *container = new QMacNativeWidget; auto *container = new QT_IGNORE_DEPRECATIONS(QMacNativeWidget);
QObject::connect(platformMenu, SIGNAL(destroyed()), container, SLOT(deleteLater())); QObject::connect(platformMenu, SIGNAL(destroyed()), container, SLOT(deleteLater()));
container->resize(widget->sizeHint()); container->resize(widget->sizeHint());
widget->setParent(container); widget->setParent(container);