Commit b0bb2d34 authored by Tobias Hunger's avatar Tobias Hunger

FancyLineEdit: Allow to set the ok color

... and not just the error color.

Change-Id: I7fabd85404193ca3ee54d27025ca952995a0840f
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 1f8b9077
......@@ -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::okColor() const
{
return d->m_okTextColor;
}
QColor FancyLineEdit::textColor(const QWidget *w)
void FancyLineEdit::setOkColor(const QColor &c)
{
return w->palette().color(QPalette::Active, QPalette::Text);
d->m_okTextColor = c;
validate();
}
void FancyLineEdit::setTextColor(QWidget *w, const QColor &c)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment