summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-07-05 14:39:18 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-19 13:30:27 +0000
commit2cfdbd62be950a5b2c512d64d7dd6f7060c11f7a (patch)
tree66c829c303b817fab102c3b74dd86b870769f7b7 /src
parentf209eb464cfa1a4f0f58640b59fd5c834c8bf7e0 (diff)
Fix placement of placeholder text in QLineEdits with action icons
After dc794f7622bc00f7ca50fab65d6965695d6d2972, side widgets only got space if they were not fading out, but the logic was not correctly accounting for side widgets that never fade, such as buttons added via QLineEdit::addAction. Fix this to give visible widgets space, unless they are fading out. That was the intent of the original change. Rename the variable to make its purpose clearer, and reset it at the end of the fade-out animation. Add a much-needed test that relies on private APIs to verify that the effective margins are calculated correctly. Fixes: QTBUG-94824 Change-Id: If2ee6be52be9e4f9be1e91f72f27681ce27def6d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 0e6b31019f01c72ea3af3de31095f8269c7d7f30) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp5
-rw-r--r--src/widgets/widgets/qlineedit_p.h9
2 files changed, 9 insertions, 5 deletions
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 89fc66d123..e5499dbb3f 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -406,8 +406,9 @@ void QLineEditIconButton::setHideWithText(bool hide)
void QLineEditIconButton::onAnimationFinished()
{
- if (shouldHideWithText() && isVisible() && !m_wasHidden) {
+ if (shouldHideWithText() && isVisible() && m_fadingOut) {
hide();
+ m_fadingOut = false;
// Invalidate previous geometry to take into account new size of side widgets
if (auto le = lineEditPrivate())
@@ -417,7 +418,7 @@ void QLineEditIconButton::onAnimationFinished()
void QLineEditIconButton::animateShow(bool visible)
{
- m_wasHidden = visible;
+ m_fadingOut = !visible;
if (shouldHideWithText() && !isVisible()) {
show();
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index c03265e3f9..1ffb46cdb4 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -95,8 +95,11 @@ public:
bool shouldHideWithText() const;
void setHideWithText(bool hide);
- // m_wasHidden is true unless the button is fading out
- bool needsSpace() const { return m_wasHidden; }
+ bool needsSpace() const {
+ if (m_fadingOut)
+ return false;
+ return isVisibleTo(parentWidget());
+ }
#endif
protected:
@@ -120,7 +123,7 @@ private:
#if QT_CONFIG(animation)
bool m_hideWithText = false;
- bool m_wasHidden = false;
+ bool m_fadingOut = false;
#endif
};