From b0bb2d3422540cc6d4f9daced6c59aab822be850 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 12 Oct 2015 15:25:37 +0200 Subject: [PATCH] FancyLineEdit: Allow to set the ok color ... and not just the error color. Change-Id: I7fabd85404193ca3ee54d27025ca952995a0840f Reviewed-by: Eike Ziller --- src/libs/utils/fancylineedit.cpp | 20 ++++++++++++++------ src/libs/utils/fancylineedit.h | 7 +++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp index c9ff21dc901..ececf043184 100644 --- a/src/libs/utils/fancylineedit.cpp +++ b/src/libs/utils/fancylineedit.cpp @@ -105,7 +105,7 @@ public: QString m_lastFilterText; - const QColor m_okTextColor; + QColor m_okTextColor; QColor m_errorTextColor = Qt::red; QString m_errorMessage; QString m_initialText; @@ -113,9 +113,10 @@ public: FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) : QObject(parent), - m_lineEdit(parent), - m_okTextColor(FancyLineEdit::textColor(parent)) + m_lineEdit(parent) { + m_okTextColor = parent->palette().color(QPalette::Active, QPalette::Text); + for (int i = 0; i < 2; ++i) { m_iconbutton[i] = new IconButton(parent); m_iconbutton[i]->installEventFilter(this); @@ -395,12 +396,19 @@ QColor FancyLineEdit::errorColor() const void FancyLineEdit::setErrorColor(const QColor &c) { - d->m_errorTextColor = c; + d->m_errorTextColor = c; + validate(); } -QColor FancyLineEdit::textColor(const QWidget *w) +QColor FancyLineEdit::okColor() const { - return w->palette().color(QPalette::Active, QPalette::Text); + return d->m_okTextColor; +} + +void FancyLineEdit::setOkColor(const QColor &c) +{ + d->m_okTextColor = c; + validate(); } void FancyLineEdit::setTextColor(QWidget *w, const QColor &c) diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h index 9c9c1477ac1..f897123c429 100644 --- a/src/libs/utils/fancylineedit.h +++ b/src/libs/utils/fancylineedit.h @@ -84,6 +84,7 @@ class QTCREATOR_UTILS_EXPORT FancyLineEdit : public CompletingLineEdit // Validation. Q_PROPERTY(QString initialText READ initialText WRITE setInitialText DESIGNABLE true) Q_PROPERTY(QColor errorColor READ errorColor WRITE setErrorColor DESIGNABLE true) + Q_PROPERTY(QColor okColor READ okColor WRITE setOkColor DESIGNABLE true) public: enum Side {Left = 0, Right = 1}; @@ -141,9 +142,11 @@ public: void setInitialText(const QString &); QColor errorColor() const; - void setErrorColor(const QColor &); + void setErrorColor(const QColor &c); + + QColor okColor() const; + void setOkColor(const QColor &c); - static QColor textColor(const QWidget *w); static void setTextColor(QWidget *w, const QColor &c); void setValidationFunction(const ValidationFunction &fn);