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,
|
connect(m_ui.easingCurvePicker, &QListWidget::currentRowChanged,
|
||||||
this, &Window::curveChanged);
|
this, &Window::curveChanged);
|
||||||
connect(m_ui.buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
connect(m_ui.buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||||
this, &Window::pathChanged);
|
this, &Window::pathChanged);
|
||||||
connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
this, &Window::periodChanged);
|
this, &Window::periodChanged);
|
||||||
@ -180,9 +180,10 @@ void Window::curveChanged(int row)
|
|||||||
m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack);
|
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)
|
void Window::periodChanged(double value)
|
||||||
|
@ -69,7 +69,7 @@ public:
|
|||||||
Window(QWidget *parent = nullptr);
|
Window(QWidget *parent = nullptr);
|
||||||
private slots:
|
private slots:
|
||||||
void curveChanged(int row);
|
void curveChanged(int row);
|
||||||
void pathChanged(int index);
|
void pathChanged(QAbstractButton *button);
|
||||||
void periodChanged(double);
|
void periodChanged(double);
|
||||||
void amplitudeChanged(double);
|
void amplitudeChanged(double);
|
||||||
void overshootChanged(double);
|
void overshootChanged(double);
|
||||||
|
@ -113,13 +113,14 @@ void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
|
|||||||
//! [1]
|
//! [1]
|
||||||
|
|
||||||
//! [2]
|
//! [2]
|
||||||
void MainWindow::buttonGroupClicked(int id)
|
void MainWindow::buttonGroupClicked(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
const QList<QAbstractButton *> buttons = buttonGroup->buttons();
|
const QList<QAbstractButton *> buttons = buttonGroup->buttons();
|
||||||
for (QAbstractButton *button : buttons) {
|
for (QAbstractButton *myButton : buttons) {
|
||||||
if (buttonGroup->button(id) != button)
|
if (myButton != button)
|
||||||
button->setChecked(false);
|
button->setChecked(false);
|
||||||
}
|
}
|
||||||
|
const int id = buttonGroup->id(button);
|
||||||
if (id == InsertTextButton) {
|
if (id == InsertTextButton) {
|
||||||
scene->setMode(DiagramScene::InsertText);
|
scene->setMode(DiagramScene::InsertText);
|
||||||
} else {
|
} else {
|
||||||
@ -154,7 +155,7 @@ void MainWindow::deleteItem()
|
|||||||
//! [3]
|
//! [3]
|
||||||
|
|
||||||
//! [4]
|
//! [4]
|
||||||
void MainWindow::pointerGroupClicked(int)
|
void MainWindow::pointerGroupClicked()
|
||||||
{
|
{
|
||||||
scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
|
scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
|
||||||
}
|
}
|
||||||
@ -334,7 +335,7 @@ void MainWindow::createToolBox()
|
|||||||
{
|
{
|
||||||
buttonGroup = new QButtonGroup(this);
|
buttonGroup = new QButtonGroup(this);
|
||||||
buttonGroup->setExclusive(false);
|
buttonGroup->setExclusive(false);
|
||||||
connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
connect(buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||||
this, &MainWindow::buttonGroupClicked);
|
this, &MainWindow::buttonGroupClicked);
|
||||||
QGridLayout *layout = new QGridLayout;
|
QGridLayout *layout = new QGridLayout;
|
||||||
layout->addWidget(createCellWidget(tr("Conditional"), DiagramItem::Conditional), 0, 0);
|
layout->addWidget(createCellWidget(tr("Conditional"), DiagramItem::Conditional), 0, 0);
|
||||||
@ -528,7 +529,7 @@ void MainWindow::createToolbars()
|
|||||||
pointerTypeGroup = new QButtonGroup(this);
|
pointerTypeGroup = new QButtonGroup(this);
|
||||||
pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
|
pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
|
||||||
pointerTypeGroup->addButton(linePointerButton, int(DiagramScene::InsertLine));
|
pointerTypeGroup->addButton(linePointerButton, int(DiagramScene::InsertLine));
|
||||||
connect(pointerTypeGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
|
connect(pointerTypeGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
||||||
this, &MainWindow::pointerGroupClicked);
|
this, &MainWindow::pointerGroupClicked);
|
||||||
|
|
||||||
sceneScaleCombo = new QComboBox;
|
sceneScaleCombo = new QComboBox;
|
||||||
|
@ -82,9 +82,9 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void backgroundButtonGroupClicked(QAbstractButton *button);
|
void backgroundButtonGroupClicked(QAbstractButton *button);
|
||||||
void buttonGroupClicked(int id);
|
void buttonGroupClicked(QAbstractButton *button);
|
||||||
void deleteItem();
|
void deleteItem();
|
||||||
void pointerGroupClicked(int id);
|
void pointerGroupClicked();
|
||||||
void bringToFront();
|
void bringToFront();
|
||||||
void sendToBack();
|
void sendToBack();
|
||||||
void itemInserted(DiagramItem *item);
|
void itemInserted(DiagramItem *item);
|
||||||
|
@ -415,8 +415,13 @@ void QAbstractButtonPrivate::emitClicked()
|
|||||||
emit q->clicked(checked);
|
emit q->clicked(checked);
|
||||||
#if QT_CONFIG(buttongroup)
|
#if QT_CONFIG(buttongroup)
|
||||||
if (guard && group) {
|
if (guard && group) {
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
emit group->buttonClicked(group->id(q));
|
emit group->buttonClicked(group->id(q));
|
||||||
if (guard && group)
|
if (guard && group)
|
||||||
|
QT_WARNING_POP
|
||||||
|
#endif
|
||||||
emit group->buttonClicked(q);
|
emit group->buttonClicked(q);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -429,8 +434,13 @@ void QAbstractButtonPrivate::emitPressed()
|
|||||||
emit q->pressed();
|
emit q->pressed();
|
||||||
#if QT_CONFIG(buttongroup)
|
#if QT_CONFIG(buttongroup)
|
||||||
if (guard && group) {
|
if (guard && group) {
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
emit group->buttonPressed(group->id(q));
|
emit group->buttonPressed(group->id(q));
|
||||||
if (guard && group)
|
if (guard && group)
|
||||||
|
QT_WARNING_POP
|
||||||
|
#endif
|
||||||
emit group->buttonPressed(q);
|
emit group->buttonPressed(q);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -443,8 +453,13 @@ void QAbstractButtonPrivate::emitReleased()
|
|||||||
emit q->released();
|
emit q->released();
|
||||||
#if QT_CONFIG(buttongroup)
|
#if QT_CONFIG(buttongroup)
|
||||||
if (guard && group) {
|
if (guard && group) {
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
emit group->buttonReleased(group->id(q));
|
emit group->buttonReleased(group->id(q));
|
||||||
if (guard && group)
|
if (guard && group)
|
||||||
|
QT_WARNING_POP
|
||||||
|
#endif
|
||||||
emit group->buttonReleased(q);
|
emit group->buttonReleased(q);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -457,8 +472,13 @@ void QAbstractButtonPrivate::emitToggled(bool checked)
|
|||||||
emit q->toggled(checked);
|
emit q->toggled(checked);
|
||||||
#if QT_CONFIG(buttongroup)
|
#if QT_CONFIG(buttongroup)
|
||||||
if (guard && group) {
|
if (guard && group) {
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
emit group->buttonToggled(group->id(q), checked);
|
emit group->buttonToggled(group->id(q), checked);
|
||||||
if (guard && group)
|
if (guard && group)
|
||||||
|
QT_WARNING_POP
|
||||||
|
#endif
|
||||||
emit group->buttonToggled(q, checked);
|
emit group->buttonToggled(q, checked);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -164,6 +164,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QButtonGroup::buttonClicked(int id)
|
\fn void QButtonGroup::buttonClicked(int id)
|
||||||
|
\obsolete
|
||||||
|
|
||||||
This signal is emitted when a button with the given \a id is
|
This signal is emitted when a button with the given \a id is
|
||||||
clicked.
|
clicked.
|
||||||
@ -183,6 +184,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
/*!
|
/*!
|
||||||
\fn void QButtonGroup::buttonPressed(int id)
|
\fn void QButtonGroup::buttonPressed(int id)
|
||||||
\since 4.2
|
\since 4.2
|
||||||
|
\obsolete
|
||||||
|
|
||||||
This signal is emitted when a button with the given \a id is
|
This signal is emitted when a button with the given \a id is
|
||||||
pressed down.
|
pressed down.
|
||||||
@ -202,6 +204,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
/*!
|
/*!
|
||||||
\fn void QButtonGroup::buttonReleased(int id)
|
\fn void QButtonGroup::buttonReleased(int id)
|
||||||
\since 4.2
|
\since 4.2
|
||||||
|
\obsolete
|
||||||
|
|
||||||
This signal is emitted when a button with the given \a id is
|
This signal is emitted when a button with the given \a id is
|
||||||
released.
|
released.
|
||||||
@ -222,6 +225,7 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
/*!
|
/*!
|
||||||
\fn void QButtonGroup::buttonToggled(int id, bool checked)
|
\fn void QButtonGroup::buttonToggled(int id, bool checked)
|
||||||
\since 5.2
|
\since 5.2
|
||||||
|
\obsolete
|
||||||
|
|
||||||
This signal is emitted when a button with the given \a id is toggled.
|
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.
|
\a checked is true if the button is checked, or false if the button is unchecked.
|
||||||
|
@ -78,13 +78,19 @@ public:
|
|||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void buttonClicked(QAbstractButton *);
|
void buttonClicked(QAbstractButton *);
|
||||||
void buttonClicked(int);
|
|
||||||
void buttonPressed(QAbstractButton *);
|
void buttonPressed(QAbstractButton *);
|
||||||
void buttonPressed(int);
|
|
||||||
void buttonReleased(QAbstractButton *);
|
void buttonReleased(QAbstractButton *);
|
||||||
void buttonReleased(int);
|
|
||||||
void buttonToggled(QAbstractButton *, bool);
|
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);
|
void buttonToggled(int, bool);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QButtonGroup)
|
Q_DISABLE_COPY(QButtonGroup)
|
||||||
|
Loading…
Reference in New Issue
Block a user