Skip to content

Commit

Permalink
merge bitcoin-core/gui#404: Fix various edge case bugs in QValidatedL…
Browse files Browse the repository at this point in the history
…ineEdit
  • Loading branch information
kwvg committed Feb 5, 2025
1 parent c02483c commit d451246
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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 @@ -27,7 +33,7 @@ void QValidatedLineEdit::setValid(bool _valid)
}
else
{
setStyleSheet(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_INVALID));
setStyleSheet("QValidatedLineEdit { " + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_INVALID) + " }");
}
this->valid = _valid;
}
Expand Down Expand Up @@ -105,6 +111,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
Original file line number Diff line number Diff line change
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 d451246

Please sign in to comment.