[neon/qt/qtbase/Neon/release] debian: Backport upstream patch to fix misplacement of placeholder text in QLineEdit with RTL content

Dmitry Shachnev null at kde.org
Thu May 5 10:59:24 BST 2022


Git commit 1b0fec274de680c1ac0b47e675d604b06bbf6742 by Dmitry Shachnev, on behalf of Lu Yaning.
Committed on 16/06/2021 at 17:26.
Pushed by jriddell into branch 'Neon/release'.

Backport upstream patch to fix misplacement of placeholder text in QLineEdit with RTL content

M  +3    -0    debian/changelog
A  +53   -0    debian/patches/fix-misplacement-of-placeholder-text-in-QLineEdit.diff
M  +1    -0    debian/patches/series

https://invent.kde.org/neon/qt/qtbase/commit/1b0fec274de680c1ac0b47e675d604b06bbf6742

diff --git a/debian/changelog b/debian/changelog
index 33450fd..9e8e4c8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,8 @@
 qtbase-opensource-src (5.15.2+dfsg-8) UNRELEASED; urgency=medium
 
+  [ Lu Yaning ]
+  * Backport upstream patch to fix misplacement of placeholder text in
+    QLineEdit with RTL content.
 
  -- Debian Qt/KDE Maintainers <debian-qt-kde at lists.debian.org>  Sat, 12 Jun 2021 20:32:46 +0300
 
diff --git a/debian/patches/fix-misplacement-of-placeholder-text-in-QLineEdit.diff b/debian/patches/fix-misplacement-of-placeholder-text-in-QLineEdit.diff
new file mode 100644
index 0000000..3a14d54
--- /dev/null
+++ b/debian/patches/fix-misplacement-of-placeholder-text-in-QLineEdit.diff
@@ -0,0 +1,53 @@
+Description: fix misplacement of placeholder text in QLineEdit with RTL content
+ The placeholder text was rendered in the wrong position after clicking
+ on the clear button in a QLineEdit with right-to-left content. The
+ button was still taking up space while it was fading out, so the first
+ paintEvent rendered the placeholder with space reserved for the clear
+ button. Once the button gets hidden, no new update was issued, so
+ garbage was left behind.
+ .
+ Fix this by not giving a fading-out clear button any margin space. The
+ result of this is that the placeholder text is visible underneath the
+ fading-out clear button. This is preferable to the placeholder text
+ being first rendered next to the fading-out clear button, and then
+ popping to the edge when the clear button is hidden (which would have
+ been the result of issuing a complete update for the line edit at the
+ end of the fade-out animation).
+Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=dc794f7622bc00f7
+Last-Update: 2021-06-16
+
+--- a/src/widgets/widgets/qlineedit_p.cpp
++++ b/src/widgets/widgets/qlineedit_p.cpp
+@@ -664,10 +664,18 @@ static int effectiveTextMargin(int defau
+     if (widgets.empty())
+         return defaultMargin;
+ 
+-    return defaultMargin + (parameters.margin + parameters.widgetWidth) *
+-           int(std::count_if(widgets.begin(), widgets.end(),
++    const auto visibleSideWidgetCount = std::count_if(widgets.begin(), widgets.end(),
+                              [](const QLineEditPrivate::SideWidgetEntry &e) {
+-                                 return e.widget->isVisibleTo(e.widget->parentWidget()); }));
++#if QT_CONFIG(animation)
++        // a button that's fading out doesn't get any space
++        if (auto* iconButton = qobject_cast<QLineEditIconButton*>(e.widget))
++            return iconButton->needsSpace();
++
++#endif
++        return e.widget->isVisibleTo(e.widget->parentWidget());
++    });
++
++    return defaultMargin + (parameters.margin + parameters.widgetWidth) * visibleSideWidgetCount;
+ }
+ 
+ QMargins QLineEditPrivate::effectiveTextMargins() const
+--- a/src/widgets/widgets/qlineedit_p.h
++++ b/src/widgets/widgets/qlineedit_p.h
+@@ -95,6 +95,8 @@ public:
+ 
+     bool shouldHideWithText() const;
+     void setHideWithText(bool hide);
++    // m_wasHidden is true unless the button is fading out
++    bool needsSpace() const { return m_wasHidden; }
+ #endif
+ 
+ protected:
diff --git a/debian/patches/series b/debian/patches/series
index 7cf8202..f702b2a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,6 +5,7 @@ gcc_11_limits.diff
 qiodevice_readline_memory.diff
 mime_globs.diff
 fix-invalid-pointer-return-with-QGridLayout.diff
+fix-misplacement-of-placeholder-text-in-QLineEdit.diff
 
 # Debian specific.
 gnukfreebsd.diff



More information about the Neon-commits mailing list