Fix SearchBar Placeholder Alignment in RTL

Align placeholder at leading position in line edit
This commit is contained in:
ShaopengLin 2024-09-05 16:16:16 -04:00 committed by Kelson
parent 05fcff0834
commit 3906888801

View File

@ -54,7 +54,14 @@ SearchBarLineEdit::SearchBarLineEdit(QWidget *parent) :
setAlignment(KiwixApp::isRightToLeft() ? Qt::AlignRight : Qt::AlignLeft);
mp_typingTimer = new QTimer(this);
mp_typingTimer->setSingleShot(true);
setPlaceholderText(gt("search"));
/* Placeholder does not affect line edit alignment and is aligned to line
edit purely by text direction (LTR leading RTL ending). Thus, we need
directional mask to make it LTR at leading position.
https://stackoverflow.com/questions/66430215/english-and-arabic-mixed-string-not-ordered-correctly-qt
*/
const QString ltrConversionChar = QString{"\u200e"};
setPlaceholderText(ltrConversionChar + gt("search"));
setToolTip(gt("search"));
m_completer.setCompletionMode(QCompleter::UnfilteredPopupCompletion);
m_completer.setCaseSensitivity(Qt::CaseInsensitive);