forked from qt-creator/qt-creator
FancyLineEdit: Mark placeholder text that doesn't pass validation
... also for place holder text. While this omission was apparently intentional, the opposite behavior was used in the Beautifier settings, arguably being a better standard as this makes clear to the user that the pre-selected placeholder value won't be ok to use. Change-Id: Iaf15b1351de929dee57329efdf18d7e831b4f8bc Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -115,6 +115,7 @@ public:
|
||||
|
||||
const QColor m_okTextColor;
|
||||
const QColor m_errorTextColor;
|
||||
const QColor m_placeholderTextColor;
|
||||
QString m_errorMessage;
|
||||
};
|
||||
|
||||
@@ -123,7 +124,9 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
|
||||
m_lineEdit(parent),
|
||||
m_completionShortcut(completionShortcut()->key(), parent),
|
||||
m_okTextColor(creatorTheme()->color(Theme::TextColorNormal)),
|
||||
m_errorTextColor(creatorTheme()->color(Theme::TextColorError))
|
||||
m_errorTextColor(creatorTheme()->color(Theme::TextColorError)),
|
||||
m_placeholderTextColor(creatorTheme()->color(Theme::PalettePlaceholderText))
|
||||
|
||||
{
|
||||
m_completionShortcut.setContext(Qt::WidgetShortcut);
|
||||
connect(completionShortcut(), &CompletionShortcut::keyChanged,
|
||||
@@ -485,15 +488,18 @@ void FancyLineEdit::validate()
|
||||
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.
|
||||
// Changed..figure out if valid changed. Also trigger on the first change.
|
||||
// Invalid DisplayingPlaceholderText shows also error color.
|
||||
if (newState != d->m_state || d->m_firstChange) {
|
||||
const bool validHasChanged = (d->m_state == Valid) != (newState == Valid);
|
||||
d->m_state = newState;
|
||||
d->m_firstChange = false;
|
||||
|
||||
QPalette p = palette();
|
||||
p.setColor(QPalette::Active, QPalette::Text, newState == Invalid ? d->m_errorTextColor : d->m_okTextColor);
|
||||
p.setColor(QPalette::Active, QPalette::Text,
|
||||
newState == Invalid ? d->m_errorTextColor : d->m_okTextColor);
|
||||
p.setColor(QPalette::Active, QPalette::PlaceholderText,
|
||||
validates ? d->m_placeholderTextColor : d->m_errorTextColor);
|
||||
setPalette(p);
|
||||
|
||||
if (validHasChanged)
|
||||
|
Reference in New Issue
Block a user