Skip to content

Commit

Permalink
Merge #404: Fix various edge case bugs in QValidatedLineEdit
Browse files Browse the repository at this point in the history
aeb18b6 Bugfix: GUI: Check validity when QValidatedLineEdit::setText is called (Luke Dashjr)
b1a544b Bugfix: GUI: Re-check validity after QValidatedLineEdit::setCheckValidator (Luke Dashjr)
2385b50 Bugfix: GUI: Only apply invalid style to QValidatedLineEdit, not its tooltip (Luke Dashjr)

Pull request description:

  1. Use a CSS selector to avoid changing the background colour of the tooltip.
  2. Re-check validity of input when we first set the validator (probably a no-op in practice).
  3. Check validity of input when it is set programmatically via `setText` (eg, via the address book). Probably no-op in practice UNTIL merging bitcoin/bitcoin#15987 or any other PR that adds a warning for valid addresses.

  Moved from bitcoin/bitcoin#18133 (just concept ACKs)

ACKs for top commit:
  Sjors:
    tACK aeb18b6
  hebasto:
    ACK aeb18b6, tested on Linux Mint 20.3 (Qt 5.12.8).

Tree-SHA512: b6fa8ee4dec76e1c759095721240e6fa5071a02993cb28406e96a0fa2e819f5dddc03d2e7c9073354d7865c2b09eb263afaf853ecba42e9fc4f50ef4ae20bf0f
  • Loading branch information
hebasto committed Feb 9, 2022
2 parents 280a777 + aeb18b6 commit b7942c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/qt/qvalidatedlineedit.cpp
Expand Up @@ -15,6 +15,12 @@ QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) :
connect(this, &QValidatedLineEdit::textChanged, this, &QValidatedLineEdit::markValid);
}

void QValidatedLineEdit::setText(const QString& text)
{
QLineEdit::setText(text);
checkValidity();
}

void QValidatedLineEdit::setValid(bool _valid)
{
if(_valid == this->valid)
Expand All @@ -28,7 +34,7 @@ void QValidatedLineEdit::setValid(bool _valid)
}
else
{
setStyleSheet(STYLE_INVALID);
setStyleSheet("QValidatedLineEdit { " STYLE_INVALID "}");
}
this->valid = _valid;
}
Expand Down Expand Up @@ -106,6 +112,7 @@ void QValidatedLineEdit::checkValidity()
void QValidatedLineEdit::setCheckValidator(const QValidator *v)
{
checkValidator = v;
checkValidity();
}

bool QValidatedLineEdit::isValid()
Expand Down
1 change: 1 addition & 0 deletions src/qt/qvalidatedlineedit.h
Expand Up @@ -29,6 +29,7 @@ class QValidatedLineEdit : public QLineEdit
const QValidator *checkValidator;

public Q_SLOTS:
void setText(const QString&);
void setValid(bool valid);
void setEnabled(bool enabled);

Expand Down

0 comments on commit b7942c9

Please sign in to comment.