summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-03-18 15:05:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 08:35:24 +0100
commit1cc421eb250a2fabe55133155a5c5ab8a0e5dd31 (patch)
tree2ac0df38b447a63bef6216c0eef6af9b6309dccf /src/widgets/widgets
parente07684294d6a6659997d60ef946b6c2d713d984d (diff)
Use parent cursor for QLineEdit's clear button when not shown.
Task-number: QTBUG-37548 Change-Id: I8a4eb52f9a5a9551e53dab100f2337cf201d7401 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp12
-rw-r--r--src/widgets/widgets/qlineedit_p.h3
2 files changed, 12 insertions, 3 deletions
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 9ff77c87de..10689b2fc3 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -309,9 +309,7 @@ QLineEditIconButton::QLineEditIconButton(QWidget *parent)
: QToolButton(parent)
, m_opacity(0)
{
-#ifndef QT_NO_CURSOR
- setCursor(Qt::ArrowCursor);
-#endif
+ updateCursor();
setFocusPolicy(Qt::NoFocus);
}
@@ -342,11 +340,19 @@ 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);
}
+void QLineEditIconButton::updateCursor()
+{
+#ifndef QT_NO_CURSOR
+ setCursor(qFuzzyCompare(m_opacity, 1.0) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor());
+#endif
+}
+
void QLineEditPrivate::_q_textChanged(const QString &text)
{
if (hasSideWidgets()) {
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index aa5b57a920..db8edee005 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -89,6 +89,9 @@ public:
protected:
void paintEvent(QPaintEvent *event);
+private slots:
+ void updateCursor();
+
private:
void startOpacityAnimation(qreal endValue);