mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 03:58: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),
|
QLineEdit(parent),
|
||||||
m_completer(&m_completionModel, this)
|
m_completer(&m_completionModel, this)
|
||||||
{
|
{
|
||||||
|
setAlignment(KiwixApp::isRightToLeft() ? Qt::AlignRight : Qt::AlignLeft);
|
||||||
mp_typingTimer = new QTimer(this);
|
mp_typingTimer = new QTimer(this);
|
||||||
mp_typingTimer->setSingleShot(true);
|
mp_typingTimer->setSingleShot(true);
|
||||||
setPlaceholderText(gt("search"));
|
setPlaceholderText(gt("search"));
|
||||||
@ -77,6 +78,12 @@ SearchBarLineEdit::SearchBarLineEdit(QWidget *parent) :
|
|||||||
if (m_returnPressed) {
|
if (m_returnPressed) {
|
||||||
this->setText(m_searchbarInput);
|
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, [=]() {
|
connect(this, &QLineEdit::returnPressed, this, [=]() {
|
||||||
m_returnPressed = true;
|
m_returnPressed = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user