Show the correct cursor for QLineEdit's side buttons.

Task-number: QTBUG-40708
Change-Id: I5869f42bab3a27085b5572a4b83b16c39a67f733
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Marcel Krems 2014-08-12 13:10:08 +02:00
parent 296142ba05
commit 9f486efcbe
2 changed files with 5 additions and 2 deletions

View File

@ -309,7 +309,6 @@ QLineEditIconButton::QLineEditIconButton(QWidget *parent)
: QToolButton(parent)
, m_opacity(0)
{
updateCursor();
setFocusPolicy(Qt::NoFocus);
}
@ -333,6 +332,7 @@ void QLineEditIconButton::setOpacity(qreal value)
{
if (!qFuzzyCompare(m_opacity, value)) {
m_opacity = value;
updateCursor();
update();
}
}
@ -340,7 +340,6 @@ void QLineEditIconButton::setOpacity(qreal value)
void QLineEditIconButton::startOpacityAnimation(qreal endValue)
{
QPropertyAnimation *animation = new QPropertyAnimation(this, QByteArrayLiteral("opacity"));
connect(animation, &QAbstractAnimation::finished, this, &QLineEditIconButton::updateCursor);
animation->setDuration(160);
animation->setEndValue(endValue);
animation->start(QAbstractAnimation::DeleteWhenStopped);

View File

@ -4182,10 +4182,12 @@ void tst_QLineEdit::clearButton()
QVERIFY(clearButton);
QCOMPARE(filterModel->rowCount(), 3);
QTest::keyClick(filterLineEdit, 'a');
QTRY_COMPARE(clearButton->cursor().shape(), Qt::ArrowCursor);
QTRY_COMPARE(filterModel->rowCount(), 2); // matches 'aa', 'ab'
QTest::keyClick(filterLineEdit, 'b');
QTRY_COMPARE(filterModel->rowCount(), 1); // matches 'ab'
QTest::mouseClick(clearButton, Qt::LeftButton, 0, QRect(QPoint(0, 0), clearButton->size()).center());
QTRY_COMPARE(clearButton->cursor().shape(), filterLineEdit->cursor().shape());
QTRY_COMPARE(filterModel->rowCount(), 3);
filterLineEdit->setReadOnly(true); // QTBUG-34315
@ -4215,6 +4217,8 @@ void tst_QLineEdit::sideWidgets()
testWidget.move(300, 300);
testWidget.show();
QVERIFY(QTest::qWaitForWindowExposed(&testWidget));
foreach (QToolButton *button, lineEdit->findChildren<QToolButton *>())
QCOMPARE(button->cursor().shape(), Qt::ArrowCursor);
// Arbitrarily add/remove actions, trying to detect crashes. Add QTRY_VERIFY(false) to view the result.
delete label3Action;
lineEdit->removeAction(label2Action);