diff options
-rw-r--r-- | src/widgets/widgets/qabstractbutton.cpp | 20 | ||||
-rw-r--r-- | src/widgets/widgets/qbuttongroup.cpp | 39 | ||||
-rw-r--r-- | src/widgets/widgets/qbuttongroup.h | 12 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp | 8 |
4 files changed, 67 insertions, 12 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index badeec37ee..a128b23950 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -415,13 +415,16 @@ void QAbstractButtonPrivate::emitClicked() emit q->clicked(checked); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idClicked(id); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonClicked(group->id(q)); if (guard && group) + emit group->buttonClicked(id); QT_WARNING_POP #endif + if (guard && group) emit group->buttonClicked(q); } #endif @@ -434,13 +437,16 @@ void QAbstractButtonPrivate::emitPressed() emit q->pressed(); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idPressed(id); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonPressed(group->id(q)); if (guard && group) + emit group->buttonPressed(id); QT_WARNING_POP #endif + if (guard && group) emit group->buttonPressed(q); } #endif @@ -453,13 +459,16 @@ void QAbstractButtonPrivate::emitReleased() emit q->released(); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idReleased(id); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonReleased(group->id(q)); if (guard && group) + emit group->buttonReleased(id); QT_WARNING_POP #endif + if (guard && group) emit group->buttonReleased(q); } #endif @@ -472,13 +481,16 @@ void QAbstractButtonPrivate::emitToggled(bool checked) emit q->toggled(checked); #if QT_CONFIG(buttongroup) if (guard && group) { + const int id = group->id(q); + emit group->idToggled(id, checked); #if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED - emit group->buttonToggled(group->id(q), checked); if (guard && group) + emit group->buttonToggled(id, checked); QT_WARNING_POP #endif + if (guard && group) emit group->buttonToggled(q, checked); } #endif diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index 9162029cdb..5b407fc0f0 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -173,6 +173,16 @@ void QButtonGroup::setExclusive(bool exclusive) */ /*! + \fn void QButtonGroup::idClicked(int id) + \since 5.15 + + This signal is emitted when a button with the given \a id is + clicked. + + \sa checkedButton(), QAbstractButton::clicked() +*/ + +/*! \fn void QButtonGroup::buttonPressed(QAbstractButton *button) \since 4.2 @@ -193,6 +203,16 @@ void QButtonGroup::setExclusive(bool exclusive) */ /*! + \fn void QButtonGroup::idPressed(int id) + \since 5.15 + + This signal is emitted when a button with the given \a id is + pressed down. + + \sa QAbstractButton::pressed() +*/ + +/*! \fn void QButtonGroup::buttonReleased(QAbstractButton *button) \since 4.2 @@ -213,6 +233,16 @@ void QButtonGroup::setExclusive(bool exclusive) */ /*! + \fn void QButtonGroup::idReleased(int id) + \since 5.15 + + This signal is emitted when a button with the given \a id is + released. + + \sa QAbstractButton::released() +*/ + +/*! \fn void QButtonGroup::buttonToggled(QAbstractButton *button, bool checked) \since 5.2 @@ -233,6 +263,15 @@ void QButtonGroup::setExclusive(bool exclusive) \sa QAbstractButton::toggled() */ +/*! + \fn void QButtonGroup::idToggled(int id, bool checked) + \since 5.15 + + This signal is emitted when a button with the given \a id is toggled. + \a checked is true if the button is checked, or false if the button is unchecked. + + \sa QAbstractButton::toggled() +*/ /*! Adds the given \a button to the button group. If \a id is -1, diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index 2989dcb4ba..b2e507f31c 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -81,14 +81,18 @@ Q_SIGNALS: void buttonPressed(QAbstractButton *); void buttonReleased(QAbstractButton *); void buttonToggled(QAbstractButton *, bool); + void idClicked(int); + void idPressed(int); + void idReleased(int); + void idToggled(int, bool); #if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonClicked(QAbstractButton *) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idClicked(int) instead") void buttonClicked(int); - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonPressed(QAbstractButton *) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idPressed(int) instead") void buttonPressed(int); - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonReleased(QAbstractButton *) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idReleased(int) instead") void buttonReleased(int); - QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonToggled(QAbstractButton *, bool) instead") + QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::idToggled(int, bool) instead") void buttonToggled(int, bool); #endif diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp index 3b8bcf98c3..7454acbec7 100644 --- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp @@ -365,11 +365,11 @@ void tst_QButtonGroup::testSignals() qRegisterMetaType<QAbstractButton *>("QAbstractButton *"); QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*))); - QSignalSpy clickedIdSpy(&buttons, SIGNAL(buttonClicked(int))); + QSignalSpy clickedIdSpy(&buttons, SIGNAL(idClicked(int))); QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*))); - QSignalSpy pressedIdSpy(&buttons, SIGNAL(buttonPressed(int))); + QSignalSpy pressedIdSpy(&buttons, SIGNAL(idPressed(int))); QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*))); - QSignalSpy releasedIdSpy(&buttons, SIGNAL(buttonReleased(int))); + QSignalSpy releasedIdSpy(&buttons, SIGNAL(idReleased(int))); pb1.animateClick(); QTestEventLoop::instance().enterLoop(1); @@ -409,7 +409,7 @@ void tst_QButtonGroup::testSignals() QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool))); - QSignalSpy toggledIdSpy(&buttons, SIGNAL(buttonToggled(int, bool))); + QSignalSpy toggledIdSpy(&buttons, SIGNAL(idToggled(int, bool))); pb1.setCheckable(true); pb2.setCheckable(true); |