diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-07-08 16:27:52 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-13 19:58:08 +0200 |
commit | 09d1196281ccd03dac55781ac91f6c4eb7bb4de9 (patch) | |
tree | b2c21360c48a8a2c513efa8fd3a91aae1359e531 /src/widgets/widgets/qmenu.cpp | |
parent | 08e4d2db084f6abbf1840ffb694b15bd215ad069 (diff) |
QMenu/QToolBar: remove addAction() functions
They're now in QWidget itself. Remove them from the API, but not the
ABI.
The QToolBar case is straight-forward. QMenu is a bit more complicated:
Since QT_CONFIG(shortcut) builds changed the signature of an existing
function instead of adding/removing an overload, we have to deal with
two cases: In a QT_CONFIG(shortcut) build, these overloads that take a
trailing QKeySequence parameter have been deprecated and therefore
cannot be removed. In a !QT_CONFIG(shortcut) build, the same functions
are 1:1 copies of QWidget functions and can be removed (from the API).
[ChangeLog][QtWidgets][QMenu/QToolBar] The addAction() functions have
been moved down into QWidget.
Change-Id: I49997b3440c137a1d4e3858d1d27d34a191e1eed
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenu.cpp')
-rw-r--r-- | src/widgets/widgets/qmenu.cpp | 147 |
1 files changed, 30 insertions, 117 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 282cbe420f..9612e11c01 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1757,162 +1757,75 @@ QMenu::~QMenu() hideTearOffMenu(); } +#if QT_DEPRECATED_SINCE(6, 4) /*! - 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. + \fn QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut) + \obsolete - QMenu takes ownership of the returned QAction. - - \sa QWidget::addAction() -*/ -QAction *QMenu::addAction(const QString &text) -{ - QAction *ret = new QAction(text, this); - addAction(ret); - return ret; -} - -/*! - \overload - - This convenience function creates a new action with an \a icon - and some \a text. The function adds the newly created action to - the menu's list of actions, and returns it. - - QMenu takes ownership of the returned QAction. - - \sa QWidget::addAction() -*/ -QAction *QMenu::addAction(const QIcon &icon, const QString &text) -{ - QAction *ret = new QAction(icon, text, this); - addAction(ret); - return ret; -} - -/*! - \overload - - This convenience function creates a new action with the text \a - text and an optional shortcut \a shortcut. The action's - \l{QAction::triggered()}{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. - - QMenu takes ownership of the returned QAction. - - \sa QWidget::addAction() + Use \c{QWidget::addAction(text, shortcut, receiver, member)} instead. */ -QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member #if QT_CONFIG(shortcut) - , const QKeySequence &shortcut -#endif - ) +QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut) { - QAction *action = new QAction(text, this); -#if QT_CONFIG(shortcut) - action->setShortcut(shortcut); -#endif - QObject::connect(action, SIGNAL(triggered(bool)), receiver, member); - addAction(action); - return action; + return QWidget::addAction(text, shortcut, receiver, member); } +#endif -/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0) +/*! + \fn template<typename Functor> QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut) \since 5.6 + \obsolete - \overload - - This convenience function creates a new action with the text \a - text and an optional shortcut \a shortcut. The action's - \l{QAction::triggered()}{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. - - QMenu takes ownership of the returned QAction. + Use QWidget::addAction(text, shortcut, functor) instead. */ -/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut) +/*! + \fn template<typename Functor> QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut) \since 5.6 + \obsolete - \overload - - This convenience function creates a new action with the text \a - text and an optional shortcut \a shortcut. The action's - \l{QAction::triggered()}{triggered()} signal is connected to the - \a functor. The functor can be a pointer to a member function of - the \a context object. The newly created action is added to the - menu's list of actions and a pointer to it is returned. - - If the \a context object is destroyed, the functor will not be called. - - QMenu takes ownership of the returned QAction. + Use QWidget::addAction(text, shortcut, context, functor) instead. */ -/*!\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0) +/*! + \fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut) \since 5.6 + \obsolete - \overload - - This convenience function creates a new action with an \a icon - and some \a text and an optional shortcut \a shortcut. The action's - \l{QAction::triggered()}{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. - - QMenu takes ownership of the returned QAction. + Use QWidget::addAction(icon, text, shortcut, functor) instead. */ -/*!\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut) +/*! + \fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut) \since 5.6 + \obsolete - \overload - - This convenience function creates a new action with an \a icon - and some \a text and an optional shortcut \a shortcut. The action's - \l{QAction::triggered()}{triggered()} signal is connected to the - \a functor. The \a functor can be a pointer to a member function - of the \a context object. The newly created action is added to the - menu's list of actions and a pointer to it is returned. - - If \a context is destroyed, the functor will not be called. - - QMenu takes ownership of the returned QAction. + Use QWidget::addAction(icon, text, shortcut, context, functor) instead. */ /*! - \overload + \fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut) - This convenience function creates a new action with an \a icon and - some \a text and an optional shortcut \a shortcut. The action's - \l{QAction::triggered()}{triggered()} signal is connected to the - \a member slot of the \a receiver object. The function adds the - newly created action to the menu's list of actions, and returns it. + \obsolete - QMenu takes ownership of the returned QAction. - - \sa QWidget::addAction() + Use QWidget::addAction(icon, text, shortcut, receiver, member) instead. */ -QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, - const char* member #if QT_CONFIG(shortcut) - , const QKeySequence &shortcut -#endif - ) +QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, + const char* member, const QKeySequence &shortcut) { QAction *action = new QAction(icon, text, this); -#if QT_CONFIG(shortcut) action->setShortcut(shortcut); -#endif QObject::connect(action, SIGNAL(triggered(bool)), receiver, member); addAction(action); return action; } +#endif +#endif // QT_DEPRECATED_SINCE(6, 4) /*! This convenience function adds \a menu as a submenu to this menu. |