From 0e6b31019f01c72ea3af3de31095f8269c7d7f30 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 5 Jul 2021 14:39:18 +0200 Subject: 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 Pick-to: 6.2 6.1 5.15 Change-Id: If2ee6be52be9e4f9be1e91f72f27681ce27def6d Reviewed-by: Richard Moe Gustavsen Reviewed-by: Qt CI Bot --- src/widgets/widgets/qlineedit_p.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/widgets/widgets/qlineedit_p.cpp') diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index a0a745ac4c..9298e08501 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -418,8 +418,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()) @@ -429,7 +430,7 @@ void QLineEditIconButton::onAnimationFinished() void QLineEditIconButton::animateShow(bool visible) { - m_wasHidden = visible; + m_fadingOut = !visible; if (shouldHideWithText() && !isVisible()) { show(); -- cgit v1.2.3