FancyLineEdit: Do not set empty tooltip for no reason

If the tooltip was previously set, it is overridden on validate() even if
there's no reason to change it (e.g. there is no QValidator nor a
validation function).

Change-Id: I854f2cd4b1a8b52c8fc1ae579876aec8d10c0b8a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2019-10-09 23:29:28 +03:00
committed by Orgad Shaneh
parent 28e4ed61af
commit 734b9097c7

View File

@@ -129,6 +129,7 @@ public:
bool m_isFiltering = false;
bool m_firstChange = true;
bool m_toolTipSet = false;
QString m_lastFilterText;
@@ -520,7 +521,10 @@ void FancyLineEdit::validate()
const bool validates = d->m_validationFunction(this, &d->m_errorMessage);
const State newState = isDisplayingPlaceholderText ? DisplayingPlaceholderText
: (validates ? Valid : Invalid);
if (!validates || d->m_toolTipSet) {
setToolTip(d->m_errorMessage);
d->m_toolTipSet = true;
}
// Changed..figure out if valid changed. DisplayingPlaceholderText is not valid,
// but should not show error color. Also trigger on the first change.
if (newState != d->m_state || d->m_firstChange) {