aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-09 06:17:21 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-09 06:23:44 +0200
commitb7942c94824e4e06489417ee587d1f3ac631fce0 (patch)
tree6ea7b7a56ac18d947dc7fe11ba116a07ac8de31d /src
parent280a7777d3a368101d667a80ebc536e95abb2f8c (diff)
parentaeb18b665c616c3326671b4c7e9d6421306564f0 (diff)
downloadbitcoin-b7942c94824e4e06489417ee587d1f3ac631fce0.tar.xz
Merge bitcoin-core/gui#404: Fix various edge case bugs in QValidatedLineEdit
aeb18b665c616c3326671b4c7e9d6421306564f0 Bugfix: GUI: Check validity when QValidatedLineEdit::setText is called (Luke Dashjr) b1a544be109d336c0b53722e3f8b51687972c94e Bugfix: GUI: Re-check validity after QValidatedLineEdit::setCheckValidator (Luke Dashjr) 2385b508d5f2db118513c3e0b343d2309cdfdcd8 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 https://github.com/bitcoin/bitcoin/pull/15987 or any other PR that adds a warning for valid addresses. Moved from https://github.com/bitcoin/bitcoin/pull/18133 (just concept ACKs) ACKs for top commit: Sjors: tACK aeb18b665c616c3326671b4c7e9d6421306564f0 hebasto: ACK aeb18b665c616c3326671b4c7e9d6421306564f0, tested on Linux Mint 20.3 (Qt 5.12.8). Tree-SHA512: b6fa8ee4dec76e1c759095721240e6fa5071a02993cb28406e96a0fa2e819f5dddc03d2e7c9073354d7865c2b09eb263afaf853ecba42e9fc4f50ef4ae20bf0f
Diffstat (limited to 'src')
-rw-r--r--src/qt/qvalidatedlineedit.cpp9
-rw-r--r--src/qt/qvalidatedlineedit.h1
2 files changed, 9 insertions, 1 deletions
diff --git a/src/qt/qvalidatedlineedit.cpp b/src/qt/qvalidatedlineedit.cpp
index aa936d6b7c..bd4df75d23 100644
--- a/src/qt/qvalidatedlineedit.cpp
+++ b/src/qt/qvalidatedlineedit.cpp
@@ -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)
@@ -28,7 +34,7 @@ void QValidatedLineEdit::setValid(bool _valid)
}
else
{
- setStyleSheet(STYLE_INVALID);
+ setStyleSheet("QValidatedLineEdit { " STYLE_INVALID "}");
}
this->valid = _valid;
}
@@ -106,6 +112,7 @@ void QValidatedLineEdit::checkValidity()
void QValidatedLineEdit::setCheckValidator(const QValidator *v)
{
checkValidator = v;
+ checkValidity();
}
bool QValidatedLineEdit::isValid()
diff --git a/src/qt/qvalidatedlineedit.h b/src/qt/qvalidatedlineedit.h
index b32305f5e1..12d35aa264 100644
--- a/src/qt/qvalidatedlineedit.h
+++ b/src/qt/qvalidatedlineedit.h
@@ -29,6 +29,7 @@ private:
const QValidator *checkValidator;
public Q_SLOTS:
+ void setText(const QString&);
void setValid(bool valid);
void setEnabled(bool enabled);