1
0
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:
Arnaud Bienner 2014-01-12 17:40:28 +01:00
parent 062889b50f
commit 3838bd7bd7
2 changed files with 13 additions and 8 deletions

View File

@ -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) {

View File

@ -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();
};