QButtonGroup: deprecate overloaded signals
Deprecate the overloaded signals buttonClicked/buttonPressed/buttonReleased/buttonToggled taking an int to avoid to need to use QOverload<> when connecting the signal. The id of a button in a button group can be easily fetched with QButtonGroup::id(). Task-number: QTBUG-80906 Change-Id: Idaaab54bbcb25cba543fc99f305b9f4743ee3ed8 Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
4bb897a384
commit
fb7c9dfc06
@ -67,7 +67,7 @@ Window::Window(QWidget *parent)
|
||||
|
||||
connect(m_ui.easingCurvePicker, &QListWidget::currentRowChanged,
|
||||
this, &Window::curveChanged);
|
||||
connect(m_ui.buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
||||
connect(m_ui.buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||
this, &Window::pathChanged);
|
||||
connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, &Window::periodChanged);
|
||||
@ -180,9 +180,10 @@ void Window::curveChanged(int row)
|
||||
m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack);
|
||||
}
|
||||
|
||||
void Window::pathChanged(int index)
|
||||
void Window::pathChanged(QAbstractButton *button)
|
||||
{
|
||||
m_anim->setPathType((Animation::PathType)index);
|
||||
const int index = m_ui.buttonGroup->id(button);
|
||||
m_anim->setPathType(Animation::PathType(index));
|
||||
}
|
||||
|
||||
void Window::periodChanged(double value)
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
Window(QWidget *parent = nullptr);
|
||||
private slots:
|
||||
void curveChanged(int row);
|
||||
void pathChanged(int index);
|
||||
void pathChanged(QAbstractButton *button);
|
||||
void periodChanged(double);
|
||||
void amplitudeChanged(double);
|
||||
void overshootChanged(double);
|
||||
|
@ -113,13 +113,14 @@ void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
|
||||
//! [1]
|
||||
|
||||
//! [2]
|
||||
void MainWindow::buttonGroupClicked(int id)
|
||||
void MainWindow::buttonGroupClicked(QAbstractButton *button)
|
||||
{
|
||||
const QList<QAbstractButton *> buttons = buttonGroup->buttons();
|
||||
for (QAbstractButton *button : buttons) {
|
||||
if (buttonGroup->button(id) != button)
|
||||
for (QAbstractButton *myButton : buttons) {
|
||||
if (myButton != button)
|
||||
button->setChecked(false);
|
||||
}
|
||||
const int id = buttonGroup->id(button);
|
||||
if (id == InsertTextButton) {
|
||||
scene->setMode(DiagramScene::InsertText);
|
||||
} else {
|
||||
@ -154,7 +155,7 @@ void MainWindow::deleteItem()
|
||||
//! [3]
|
||||
|
||||
//! [4]
|
||||
void MainWindow::pointerGroupClicked(int)
|
||||
void MainWindow::pointerGroupClicked()
|
||||
{
|
||||
scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
|
||||
}
|
||||
@ -334,7 +335,7 @@ void MainWindow::createToolBox()
|
||||
{
|
||||
buttonGroup = new QButtonGroup(this);
|
||||
buttonGroup->setExclusive(false);
|
||||
connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
||||
connect(buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||
this, &MainWindow::buttonGroupClicked);
|
||||
QGridLayout *layout = new QGridLayout;
|
||||
layout->addWidget(createCellWidget(tr("Conditional"), DiagramItem::Conditional), 0, 0);
|
||||
@ -528,7 +529,7 @@ void MainWindow::createToolbars()
|
||||
pointerTypeGroup = new QButtonGroup(this);
|
||||
pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
|
||||
pointerTypeGroup->addButton(linePointerButton, int(DiagramScene::InsertLine));
|
||||
connect(pointerTypeGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
||||
connect(pointerTypeGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||
this, &MainWindow::pointerGroupClicked);
|
||||
|
||||
sceneScaleCombo = new QComboBox;
|
||||
|
@ -82,9 +82,9 @@ public:
|
||||
|
||||
private slots:
|
||||
void backgroundButtonGroupClicked(QAbstractButton *button);
|
||||
void buttonGroupClicked(int id);
|
||||
void buttonGroupClicked(QAbstractButton *button);
|
||||
void deleteItem();
|
||||
void pointerGroupClicked(int id);
|
||||
void pointerGroupClicked();
|
||||
void bringToFront();
|
||||
void sendToBack();
|
||||
void itemInserted(DiagramItem *item);
|
||||
|
@ -415,8 +415,13 @@ void QAbstractButtonPrivate::emitClicked()
|
||||
emit q->clicked(checked);
|
||||
#if QT_CONFIG(buttongroup)
|
||||
if (guard && group) {
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
emit group->buttonClicked(group->id(q));
|
||||
if (guard && group)
|
||||
QT_WARNING_POP
|
||||
#endif
|
||||
emit group->buttonClicked(q);
|
||||
}
|
||||
#endif
|
||||
@ -429,8 +434,13 @@ void QAbstractButtonPrivate::emitPressed()
|
||||
emit q->pressed();
|
||||
#if QT_CONFIG(buttongroup)
|
||||
if (guard && group) {
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
emit group->buttonPressed(group->id(q));
|
||||
if (guard && group)
|
||||
QT_WARNING_POP
|
||||
#endif
|
||||
emit group->buttonPressed(q);
|
||||
}
|
||||
#endif
|
||||
@ -443,8 +453,13 @@ void QAbstractButtonPrivate::emitReleased()
|
||||
emit q->released();
|
||||
#if QT_CONFIG(buttongroup)
|
||||
if (guard && group) {
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
emit group->buttonReleased(group->id(q));
|
||||
if (guard && group)
|
||||
QT_WARNING_POP
|
||||
#endif
|
||||
emit group->buttonReleased(q);
|
||||
}
|
||||
#endif
|
||||
@ -457,8 +472,13 @@ void QAbstractButtonPrivate::emitToggled(bool checked)
|
||||
emit q->toggled(checked);
|
||||
#if QT_CONFIG(buttongroup)
|
||||
if (guard && group) {
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
emit group->buttonToggled(group->id(q), checked);
|
||||
if (guard && group)
|
||||
QT_WARNING_POP
|
||||
#endif
|
||||
emit group->buttonToggled(q, checked);
|
||||
}
|
||||
#endif
|
||||
|
@ -164,6 +164,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
||||
|
||||
/*!
|
||||
\fn void QButtonGroup::buttonClicked(int id)
|
||||
\obsolete
|
||||
|
||||
This signal is emitted when a button with the given \a id is
|
||||
clicked.
|
||||
@ -183,6 +184,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
||||
/*!
|
||||
\fn void QButtonGroup::buttonPressed(int id)
|
||||
\since 4.2
|
||||
\obsolete
|
||||
|
||||
This signal is emitted when a button with the given \a id is
|
||||
pressed down.
|
||||
@ -202,6 +204,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
||||
/*!
|
||||
\fn void QButtonGroup::buttonReleased(int id)
|
||||
\since 4.2
|
||||
\obsolete
|
||||
|
||||
This signal is emitted when a button with the given \a id is
|
||||
released.
|
||||
@ -222,6 +225,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
||||
/*!
|
||||
\fn void QButtonGroup::buttonToggled(int id, bool checked)
|
||||
\since 5.2
|
||||
\obsolete
|
||||
|
||||
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.
|
||||
|
@ -78,13 +78,19 @@ public:
|
||||
|
||||
Q_SIGNALS:
|
||||
void buttonClicked(QAbstractButton *);
|
||||
void buttonClicked(int);
|
||||
void buttonPressed(QAbstractButton *);
|
||||
void buttonPressed(int);
|
||||
void buttonReleased(QAbstractButton *);
|
||||
void buttonReleased(int);
|
||||
void buttonToggled(QAbstractButton *, bool);
|
||||
#if QT_DEPRECATED_SINCE(5, 15)
|
||||
QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonClicked(QAbstractButton *) instead")
|
||||
void buttonClicked(int);
|
||||
QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonPressed(QAbstractButton *) instead")
|
||||
void buttonPressed(int);
|
||||
QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonReleased(QAbstractButton *) instead")
|
||||
void buttonReleased(int);
|
||||
QT_DEPRECATED_VERSION_X_5_15("Use QButtonGroup::buttonToggled(QAbstractButton *, bool) instead")
|
||||
void buttonToggled(int, bool);
|
||||
#endif
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QButtonGroup)
|
||||
|
Loading…
Reference in New Issue
Block a user