From d3ecc6db293143bdd4a5da5f28144a7e145f257c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 13 Jul 2021 19:23:36 +0200 Subject: QMenuBar: remove addAction() functions They're now in QWidget itself. Remove them from the API, but not the ABI. [ChangeLog][QtWidgets][QMenuBar] The addAction() functions have been moved down into QWidget. Change-Id: Iaa023ff227686e8e67a2b5594f0fbc31b95177a3 Reviewed-by: Volker Hilsheimer --- src/widgets/compat/removed_api.cpp | 12 +++++++ src/widgets/widgets/qmenubar.cpp | 68 +------------------------------------- src/widgets/widgets/qmenubar.h | 28 ++-------------- 3 files changed, 15 insertions(+), 93 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/compat/removed_api.cpp b/src/widgets/compat/removed_api.cpp index 3af337d853..32f4e7c806 100644 --- a/src/widgets/compat/removed_api.cpp +++ b/src/widgets/compat/removed_api.cpp @@ -96,6 +96,18 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text, return QWidget::addAction(icon, text, receiver, member); } +#include "qmenubar.h" + +QAction *QMenuBar::addAction(const QString &text) +{ + return QWidget::addAction(text); +} + +QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const char* member) +{ + return QWidget::addAction(text, receiver, member); +} + // #include // // implement removed functions from qotherheader.h diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index f92a975455..24a9fd8a0a 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -750,72 +750,6 @@ QMenuBar::~QMenuBar() d->platformMenuBar = nullptr; } -/*! - This convenience function creates a new action with \a text. - The function adds the newly created action to the menu's - list of actions, and returns it. - - \sa QWidget::addAction(), QWidget::actions() -*/ -QAction *QMenuBar::addAction(const QString &text) -{ - QAction *ret = new QAction(text, this); - addAction(ret); - return ret; -} - -/*! - \overload - - This convenience function creates a new action with the given \a - text. The action's triggered() signal is connected to the \a - receiver's \a member slot. The function adds the newly created - action to the menu's list of actions and returns it. - - \sa QWidget::addAction(), QWidget::actions() -*/ -QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const char* member) -{ - QAction *ret = new QAction(text, this); - QObject::connect(ret, SIGNAL(triggered(bool)), receiver, member); - addAction(ret); - return ret; -} - -/*! - \fn template QAction *QMenuBar::addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method) - - \since 5.11 - - \overload - - This convenience function creates a new action with the given \a - text. The action's triggered() signal is connected to the - \a method of the \a receiver. The function adds the newly created - action to the menu's list of actions and returns it. - - QMenuBar takes ownership of the returned QAction. - - \sa QWidget::addAction(), QWidget::actions() -*/ - -/*! - \fn template QAction *QMenuBar::addAction(const QString &text, Functor functor) - - \since 5.11 - - \overload - - This convenience function creates a new action with the given \a - text. The action's triggered() signal is connected to the - \a functor. The function adds the newly created - action to the menu's list of actions and returns it. - - QMenuBar takes ownership of the returned QAction. - - \sa QWidget::addAction(), QWidget::actions() -*/ - /*! Appends a new QMenu with \a title to the menu bar. The menu bar takes ownership of the menu. Returns the new menu. @@ -1588,7 +1522,7 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event) Returns the QAction at \a pt. Returns \nullptr if there is no action at \a pt or if the location has a separator. - \sa addAction(), addSeparator() + \sa QWidget::addAction(), addSeparator() */ QAction *QMenuBar::actionAt(const QPoint &pt) const { diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index f2170ebf5a..43bcd39f71 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -64,34 +64,10 @@ public: ~QMenuBar(); using QWidget::addAction; +#if QT_REMOVED_SINCE(6, 3) QAction *addAction(const QString &text); QAction *addAction(const QString &text, const QObject *receiver, const char* member); - -#ifdef Q_CLANG_QDOC - template - QAction *addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method); - template - QAction *addAction(const QString &text, Functor functor); -#else - // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) - template - inline typename std::enable_if::value - && QtPrivate::IsPointerToTypeDerivedFromQObject::Value, QAction *>::type - addAction(const QString &text, const Obj *object, Func1 slot) - { - QAction *result = addAction(text); - connect(result, &QAction::triggered, object, std::move(slot)); - return result; - } - // addAction(QString): Connect to a functor or function pointer (without context) - template - inline QAction *addAction(const QString &text, Func1 slot) - { - QAction *result = addAction(text); - connect(result, &QAction::triggered, std::move(slot)); - return result; - } -#endif // !Q_CLANG_QDOC +#endif QAction *addMenu(QMenu *menu); QMenu *addMenu(const QString &title); -- cgit v1.2.3