Skip to content

Commit b7942c9

Browse files
committed
Merge bitcoin-core/gui#404: Fix various edge case bugs in QValidatedLineEdit
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#15987 or any other PR that adds a warning for valid addresses. Moved from 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
2 parents 280a777 + aeb18b6 commit b7942c9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/qt/qvalidatedlineedit.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) :
1515
connect(this, &QValidatedLineEdit::textChanged, this, &QValidatedLineEdit::markValid);
1616
}
1717

18+
void QValidatedLineEdit::setText(const QString& text)
19+
{
20+
QLineEdit::setText(text);
21+
checkValidity();
22+
}
23+
1824
void QValidatedLineEdit::setValid(bool _valid)
1925
{
2026
if(_valid == this->valid)
@@ -28,7 +34,7 @@ void QValidatedLineEdit::setValid(bool _valid)
2834
}
2935
else
3036
{
31-
setStyleSheet(STYLE_INVALID);
37+
setStyleSheet("QValidatedLineEdit { " STYLE_INVALID "}");
3238
}
3339
this->valid = _valid;
3440
}
@@ -106,6 +112,7 @@ void QValidatedLineEdit::checkValidity()
106112
void QValidatedLineEdit::setCheckValidator(const QValidator *v)
107113
{
108114
checkValidator = v;
115+
checkValidity();
109116
}
110117

111118
bool QValidatedLineEdit::isValid()

src/qt/qvalidatedlineedit.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class QValidatedLineEdit : public QLineEdit
2929
const QValidator *checkValidator;
3030

3131
public Q_SLOTS:
32+
void setText(const QString&);
3233
void setValid(bool valid);
3334
void setEnabled(bool enabled);
3435

0 commit comments

Comments
 (0)