mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Fix SearchBar Cursor Alignment in RTL
The cursor was misaligned to the left in RTL.
This commit is contained in:
parent
e47d224469
commit
05fcff0834
@ -51,6 +51,7 @@ SearchBarLineEdit::SearchBarLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent),
|
||||
m_completer(&m_completionModel, this)
|
||||
{
|
||||
setAlignment(KiwixApp::isRightToLeft() ? Qt::AlignRight : Qt::AlignLeft);
|
||||
mp_typingTimer = new QTimer(this);
|
||||
mp_typingTimer->setSingleShot(true);
|
||||
setPlaceholderText(gt("search"));
|
||||
@ -77,6 +78,12 @@ SearchBarLineEdit::SearchBarLineEdit(QWidget *parent) :
|
||||
if (m_returnPressed) {
|
||||
this->setText(m_searchbarInput);
|
||||
}
|
||||
|
||||
/* Empty text is LTR which changes the line edit alignment.
|
||||
Need to explicitly align right. This is a generalized
|
||||
solution that aligns text to the direction of the app. */
|
||||
bool isSameDirection = text.isRightToLeft() == KiwixApp::isRightToLeft();
|
||||
setAlignment(isSameDirection ? Qt::AlignLeft : Qt::AlignRight);
|
||||
});
|
||||
connect(this, &QLineEdit::returnPressed, this, [=]() {
|
||||
m_returnPressed = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user