mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 20:09:50 +01:00
Change a bit the LTR logic (move the clear button also when editing/removing the text
This commit is contained in:
parent
062889b50f
commit
3838bd7bd7
@ -119,7 +119,6 @@ void ExtendedEditor::Paint(QPaintDevice* device) {
|
||||
}
|
||||
} else {
|
||||
clear_button_->setVisible(has_clear_button_);
|
||||
Resize();
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,16 +142,19 @@ LineEdit::LineEdit(QWidget* parent)
|
||||
ExtendedEditor(this)
|
||||
{
|
||||
connect(reset_button_, SIGNAL(clicked()), SIGNAL(Reset()));
|
||||
connect(this, SIGNAL(textChanged(QString)), SLOT(text_changed(QString)));
|
||||
}
|
||||
|
||||
void LineEdit::set_text(const QString& text) {
|
||||
QLineEdit::setText(text);
|
||||
|
||||
// For some reason Qt will detect any text with LTR at the end as LTR, so instead
|
||||
// compare only the first character
|
||||
if (!text.isEmpty()) {
|
||||
void LineEdit::text_changed(const QString& text) {
|
||||
if (text.isEmpty()) {
|
||||
// Consider empty string as LTR
|
||||
set_rtl(false);
|
||||
} else {
|
||||
// For some reason Qt will detect any text with LTR at the end as LTR, so instead
|
||||
// compare only the first character
|
||||
set_rtl(QString(text.at(0)).isRightToLeft());
|
||||
}
|
||||
Resize();
|
||||
}
|
||||
|
||||
void LineEdit::paintEvent(QPaintEvent* e) {
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
// ExtendedEditor
|
||||
void set_focus() { QLineEdit::setFocus(); }
|
||||
QString text() const { return QLineEdit::text(); }
|
||||
void set_text(const QString& text);
|
||||
void set_text(const QString& text) { QLineEdit::setText(text); }
|
||||
void set_enabled(bool enabled) { QLineEdit::setEnabled(enabled); }
|
||||
|
||||
protected:
|
||||
@ -114,6 +114,9 @@ private:
|
||||
bool is_rtl() const { return is_rtl_; }
|
||||
void set_rtl(bool rtl) { is_rtl_ = rtl; }
|
||||
|
||||
private slots:
|
||||
void text_changed(const QString& text);
|
||||
|
||||
signals:
|
||||
void Reset();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user