QButtonGroup: remove deprecated signals
Task-number: QTBUG-80906 Change-Id: I6f697b0a070ba4c401117fe7cdf02429b47d9a11 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
511cb760ee
commit
0b325602b1
@ -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<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
|
connect(m_ui.buttonGroup, &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);
|
||||||
|
@ -172,15 +172,16 @@ void MainWindow::changeStyle(bool checked)
|
|||||||
//! [4]
|
//! [4]
|
||||||
|
|
||||||
//! [5]
|
//! [5]
|
||||||
void MainWindow::changeSize(int id, bool checked)
|
void MainWindow::changeSize(QAbstractButton *button, bool checked)
|
||||||
{
|
{
|
||||||
if (!checked)
|
if (!checked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool other = id == int(OtherSize);
|
const int index = sizeButtonGroup->id(button);
|
||||||
|
const bool other = index == int(OtherSize);
|
||||||
const int extent = other
|
const int extent = other
|
||||||
? otherSpinBox->value()
|
? otherSpinBox->value()
|
||||||
: QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(id));
|
: QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(index));
|
||||||
|
|
||||||
previewArea->setSize(QSize(extent, extent));
|
previewArea->setSize(QSize(extent, extent));
|
||||||
otherSpinBox->setEnabled(other);
|
otherSpinBox->setEnabled(other);
|
||||||
@ -188,7 +189,7 @@ void MainWindow::changeSize(int id, bool checked)
|
|||||||
|
|
||||||
void MainWindow::triggerChangeSize()
|
void MainWindow::triggerChangeSize()
|
||||||
{
|
{
|
||||||
changeSize(sizeButtonGroup->checkedId(), true);
|
changeSize(sizeButtonGroup->checkedButton(), true);
|
||||||
}
|
}
|
||||||
//! [5]
|
//! [5]
|
||||||
|
|
||||||
@ -372,7 +373,7 @@ QWidget *MainWindow::createIconSizeGroupBox()
|
|||||||
sizeButtonGroup = new QButtonGroup(this);
|
sizeButtonGroup = new QButtonGroup(this);
|
||||||
sizeButtonGroup->setExclusive(true);
|
sizeButtonGroup->setExclusive(true);
|
||||||
|
|
||||||
connect(sizeButtonGroup, QOverload<int, bool>::of(&QButtonGroup::buttonToggled),
|
connect(sizeButtonGroup, &QButtonGroup::buttonToggled,
|
||||||
this, &MainWindow::changeSize);
|
this, &MainWindow::changeSize);
|
||||||
|
|
||||||
QRadioButton *smallRadioButton = new QRadioButton;
|
QRadioButton *smallRadioButton = new QRadioButton;
|
||||||
|
@ -62,6 +62,7 @@ class QActionGroup;
|
|||||||
class QLabel;
|
class QLabel;
|
||||||
class QButtonGroup;
|
class QButtonGroup;
|
||||||
class QTableWidget;
|
class QTableWidget;
|
||||||
|
class QAbstractButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
class IconPreviewArea;
|
class IconPreviewArea;
|
||||||
class IconSizeSpinBox;
|
class IconSizeSpinBox;
|
||||||
@ -81,7 +82,7 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void about();
|
void about();
|
||||||
void changeStyle(bool checked);
|
void changeStyle(bool checked);
|
||||||
void changeSize(int, bool);
|
void changeSize(QAbstractButton *button, bool);
|
||||||
void triggerChangeSize();
|
void triggerChangeSize();
|
||||||
void changeIcon();
|
void changeIcon();
|
||||||
void addSampleImages();
|
void addSampleImages();
|
||||||
|
@ -413,16 +413,8 @@ void QAbstractButtonPrivate::emitClicked()
|
|||||||
QPointer<QAbstractButton> guard(q);
|
QPointer<QAbstractButton> guard(q);
|
||||||
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)
|
emit group->buttonClicked(q);
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,16 +424,8 @@ void QAbstractButtonPrivate::emitPressed()
|
|||||||
QPointer<QAbstractButton> guard(q);
|
QPointer<QAbstractButton> guard(q);
|
||||||
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)
|
emit group->buttonPressed(q);
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,16 +435,8 @@ void QAbstractButtonPrivate::emitReleased()
|
|||||||
QPointer<QAbstractButton> guard(q);
|
QPointer<QAbstractButton> guard(q);
|
||||||
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)
|
emit group->buttonReleased(q);
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,16 +446,8 @@ void QAbstractButtonPrivate::emitToggled(bool checked)
|
|||||||
QPointer<QAbstractButton> guard(q);
|
QPointer<QAbstractButton> guard(q);
|
||||||
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)
|
emit group->buttonToggled(q, checked);
|
||||||
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,16 +162,6 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
\sa checkedButton(), QAbstractButton::clicked()
|
\sa checkedButton(), QAbstractButton::clicked()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QButtonGroup::buttonClicked(int id)
|
|
||||||
\obsolete
|
|
||||||
|
|
||||||
This signal is emitted when a button with the given \a id is
|
|
||||||
clicked.
|
|
||||||
|
|
||||||
\sa checkedButton(), QAbstractButton::clicked()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QButtonGroup::buttonPressed(QAbstractButton *button)
|
\fn void QButtonGroup::buttonPressed(QAbstractButton *button)
|
||||||
\since 4.2
|
\since 4.2
|
||||||
@ -181,17 +171,6 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
\sa QAbstractButton::pressed()
|
\sa QAbstractButton::pressed()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\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.
|
|
||||||
|
|
||||||
\sa QAbstractButton::pressed()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QButtonGroup::buttonReleased(QAbstractButton *button)
|
\fn void QButtonGroup::buttonReleased(QAbstractButton *button)
|
||||||
\since 4.2
|
\since 4.2
|
||||||
@ -201,17 +180,6 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
\sa QAbstractButton::released()
|
\sa QAbstractButton::released()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QButtonGroup::buttonReleased(int id)
|
|
||||||
\since 4.2
|
|
||||||
\obsolete
|
|
||||||
|
|
||||||
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)
|
\fn void QButtonGroup::buttonToggled(QAbstractButton *button, bool checked)
|
||||||
\since 5.2
|
\since 5.2
|
||||||
@ -222,17 +190,6 @@ void QButtonGroup::setExclusive(bool exclusive)
|
|||||||
\sa QAbstractButton::toggled()
|
\sa QAbstractButton::toggled()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\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.
|
|
||||||
|
|
||||||
\sa QAbstractButton::toggled()
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Adds the given \a button to the button group. If \a id is -1,
|
Adds the given \a button to the button group. If \a id is -1,
|
||||||
|
@ -81,16 +81,6 @@ Q_SIGNALS:
|
|||||||
void buttonPressed(QAbstractButton *);
|
void buttonPressed(QAbstractButton *);
|
||||||
void buttonReleased(QAbstractButton *);
|
void buttonReleased(QAbstractButton *);
|
||||||
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);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QButtonGroup)
|
Q_DISABLE_COPY(QButtonGroup)
|
||||||
|
@ -280,67 +280,43 @@ void tst_QButtonGroup::testSignals()
|
|||||||
|
|
||||||
qRegisterMetaType<QAbstractButton *>("QAbstractButton *");
|
qRegisterMetaType<QAbstractButton *>("QAbstractButton *");
|
||||||
QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*)));
|
QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton*)));
|
||||||
QSignalSpy clickedIdSpy(&buttons, SIGNAL(buttonClicked(int)));
|
|
||||||
QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*)));
|
QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton*)));
|
||||||
QSignalSpy pressedIdSpy(&buttons, SIGNAL(buttonPressed(int)));
|
|
||||||
QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*)));
|
QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton*)));
|
||||||
QSignalSpy releasedIdSpy(&buttons, SIGNAL(buttonReleased(int)));
|
|
||||||
|
|
||||||
pb1.animateClick();
|
pb1.animateClick();
|
||||||
QTestEventLoop::instance().enterLoop(1);
|
QTestEventLoop::instance().enterLoop(1);
|
||||||
|
|
||||||
QCOMPARE(clickedSpy.count(), 1);
|
QCOMPARE(clickedSpy.count(), 1);
|
||||||
QCOMPARE(clickedIdSpy.count(), 1);
|
|
||||||
|
|
||||||
int expectedId = -2;
|
|
||||||
|
|
||||||
QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), expectedId);
|
|
||||||
QCOMPARE(pressedSpy.count(), 1);
|
QCOMPARE(pressedSpy.count(), 1);
|
||||||
QCOMPARE(pressedIdSpy.count(), 1);
|
|
||||||
QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), expectedId);
|
|
||||||
QCOMPARE(releasedSpy.count(), 1);
|
QCOMPARE(releasedSpy.count(), 1);
|
||||||
QCOMPARE(releasedIdSpy.count(), 1);
|
|
||||||
QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), expectedId);
|
|
||||||
|
|
||||||
clickedSpy.clear();
|
clickedSpy.clear();
|
||||||
clickedIdSpy.clear();
|
|
||||||
pressedSpy.clear();
|
pressedSpy.clear();
|
||||||
pressedIdSpy.clear();
|
|
||||||
releasedSpy.clear();
|
releasedSpy.clear();
|
||||||
releasedIdSpy.clear();
|
|
||||||
|
|
||||||
pb2.animateClick();
|
pb2.animateClick();
|
||||||
QTestEventLoop::instance().enterLoop(1);
|
QTestEventLoop::instance().enterLoop(1);
|
||||||
|
|
||||||
QCOMPARE(clickedSpy.count(), 1);
|
QCOMPARE(clickedSpy.count(), 1);
|
||||||
QCOMPARE(clickedIdSpy.count(), 1);
|
|
||||||
QCOMPARE(clickedIdSpy.takeFirst().at(0).toInt(), 23);
|
|
||||||
QCOMPARE(pressedSpy.count(), 1);
|
QCOMPARE(pressedSpy.count(), 1);
|
||||||
QCOMPARE(pressedIdSpy.count(), 1);
|
|
||||||
QCOMPARE(pressedIdSpy.takeFirst().at(0).toInt(), 23);
|
|
||||||
QCOMPARE(releasedSpy.count(), 1);
|
QCOMPARE(releasedSpy.count(), 1);
|
||||||
QCOMPARE(releasedIdSpy.count(), 1);
|
|
||||||
QCOMPARE(releasedIdSpy.takeFirst().at(0).toInt(), 23);
|
|
||||||
|
|
||||||
|
|
||||||
QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool)));
|
QSignalSpy toggledSpy(&buttons, SIGNAL(buttonToggled(QAbstractButton*, bool)));
|
||||||
QSignalSpy toggledIdSpy(&buttons, SIGNAL(buttonToggled(int, bool)));
|
|
||||||
|
|
||||||
pb1.setCheckable(true);
|
pb1.setCheckable(true);
|
||||||
pb2.setCheckable(true);
|
pb2.setCheckable(true);
|
||||||
pb1.toggle();
|
pb1.toggle();
|
||||||
QCOMPARE(toggledSpy.count(), 1);
|
QCOMPARE(toggledSpy.count(), 1);
|
||||||
QCOMPARE(toggledIdSpy.count(), 1);
|
|
||||||
|
|
||||||
pb2.toggle();
|
pb2.toggle();
|
||||||
QCOMPARE(toggledSpy.count(), 3); // equals 3 since pb1 and pb2 are both toggled
|
QCOMPARE(toggledSpy.count(), 3); // equals 3 since pb1 and pb2 are both toggled
|
||||||
QCOMPARE(toggledIdSpy.count(), 3);
|
|
||||||
|
|
||||||
pb1.setCheckable(false);
|
pb1.setCheckable(false);
|
||||||
pb2.setCheckable(false);
|
pb2.setCheckable(false);
|
||||||
pb1.toggle();
|
pb1.toggle();
|
||||||
QCOMPARE(toggledSpy.count(), 3);
|
QCOMPARE(toggledSpy.count(), 3);
|
||||||
QCOMPARE(toggledIdSpy.count(), 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QButtonGroup::task106609()
|
void tst_QButtonGroup::task106609()
|
||||||
@ -372,7 +348,6 @@ void tst_QButtonGroup::task106609()
|
|||||||
|
|
||||||
qRegisterMetaType<QAbstractButton*>("QAbstractButton*");
|
qRegisterMetaType<QAbstractButton*>("QAbstractButton*");
|
||||||
QSignalSpy spy1(buttons, SIGNAL(buttonClicked(QAbstractButton*)));
|
QSignalSpy spy1(buttons, SIGNAL(buttonClicked(QAbstractButton*)));
|
||||||
QSignalSpy spy2(buttons, SIGNAL(buttonClicked(int)));
|
|
||||||
|
|
||||||
QApplication::setActiveWindow(&dlg);
|
QApplication::setActiveWindow(&dlg);
|
||||||
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&dlg));
|
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&dlg));
|
||||||
@ -381,8 +356,6 @@ void tst_QButtonGroup::task106609()
|
|||||||
radio1->setChecked(true);
|
radio1->setChecked(true);
|
||||||
QTestEventLoop::instance().enterLoop(1);
|
QTestEventLoop::instance().enterLoop(1);
|
||||||
|
|
||||||
//qDebug() << "int:" << spy2.count() << "QAbstractButton*:" << spy1.count();
|
|
||||||
QCOMPARE(spy2.count(), 2);
|
|
||||||
QCOMPARE(spy1.count(), 2);
|
QCOMPARE(spy1.count(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,11 +400,12 @@ public:
|
|||||||
: group(group)
|
: group(group)
|
||||||
, deleteButton(deleteButton)
|
, deleteButton(deleteButton)
|
||||||
{
|
{
|
||||||
connect(group, SIGNAL(buttonClicked(int)), SLOT(buttonClicked(int)));
|
connect(group, &QButtonGroup::buttonClicked,
|
||||||
|
this, &task209485_ButtonDeleter::buttonClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void buttonClicked(int)
|
void buttonClicked()
|
||||||
{
|
{
|
||||||
if (deleteButton)
|
if (deleteButton)
|
||||||
group->removeButton(group->buttons().first());
|
group->removeButton(group->buttons().first());
|
||||||
@ -447,7 +421,7 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler_data()
|
|||||||
QTest::addColumn<bool>("deleteButton");
|
QTest::addColumn<bool>("deleteButton");
|
||||||
QTest::addColumn<int>("signalCount");
|
QTest::addColumn<int>("signalCount");
|
||||||
QTest::newRow("buttonPress 1") << true << 1;
|
QTest::newRow("buttonPress 1") << true << 1;
|
||||||
QTest::newRow("buttonPress 2") << false << 2;
|
QTest::newRow("buttonPress 2") << false << 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
|
void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
|
||||||
@ -463,12 +437,11 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
|
|||||||
task209485_ButtonDeleter buttonDeleter(&group, deleteButton);
|
task209485_ButtonDeleter buttonDeleter(&group, deleteButton);
|
||||||
|
|
||||||
QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton*)));
|
QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton*)));
|
||||||
QSignalSpy spy2(&group, SIGNAL(buttonClicked(int)));
|
|
||||||
|
|
||||||
// NOTE: Reintroducing the bug of this task will cause the following line to crash:
|
// NOTE: Reintroducing the bug of this task will cause the following line to crash:
|
||||||
QTest::mouseClick(button, Qt::LeftButton);
|
QTest::mouseClick(button, Qt::LeftButton);
|
||||||
|
|
||||||
QCOMPARE(spy1.count() + spy2.count(), signalCount);
|
QCOMPARE(spy1.count(), signalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QButtonGroup::autoIncrementId()
|
void tst_QButtonGroup::autoIncrementId()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user