forked from qt-creator/qt-creator
PathChooser: Add interface to set ok/error color for lineedit
Change-Id: I4fcd72e8b9281d1cdb404ccc268c453417ec35db Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -336,6 +336,16 @@ void PathChooser::setFileName(const FileName &fn)
|
||||
d->m_lineEdit->setText(fn.toUserOutput());
|
||||
}
|
||||
|
||||
void PathChooser::setErrorColor(const QColor &errorColor)
|
||||
{
|
||||
d->m_lineEdit->setErrorColor(errorColor);
|
||||
}
|
||||
|
||||
void PathChooser::setOkColor(const QColor &okColor)
|
||||
{
|
||||
d->m_lineEdit->setOkColor(okColor);
|
||||
}
|
||||
|
||||
bool PathChooser::isReadOnly() const
|
||||
{
|
||||
return d->m_lineEdit->isReadOnly();
|
||||
@@ -461,6 +471,16 @@ void PathChooser::setAboutToShowContextMenuHandler(PathChooser::AboutToShowConte
|
||||
s_aboutToShowContextMenuHandler = handler;
|
||||
}
|
||||
|
||||
QColor PathChooser::errorColor() const
|
||||
{
|
||||
return d->m_lineEdit->errorColor();
|
||||
}
|
||||
|
||||
QColor PathChooser::okColor() const
|
||||
{
|
||||
return d->m_lineEdit->okColor();
|
||||
}
|
||||
|
||||
FancyLineEdit::ValidationFunction PathChooser::defaultValidationFunction() const
|
||||
{
|
||||
return std::bind(&PathChooser::validatePath, this, std::placeholders::_1, std::placeholders::_2);
|
||||
|
@@ -62,6 +62,8 @@ class QTCREATOR_UTILS_EXPORT PathChooser : public QWidget
|
||||
// Designer does not know this type, so force designable to false:
|
||||
Q_PROPERTY(Utils::FileName fileName READ fileName WRITE setFileName DESIGNABLE false)
|
||||
Q_PROPERTY(Utils::FileName baseFileName READ baseFileName WRITE setBaseFileName DESIGNABLE false)
|
||||
Q_PROPERTY(QColor errorColor READ errorColor WRITE setErrorColor DESIGNABLE true)
|
||||
Q_PROPERTY(QColor okColor READ okColor WRITE setOkColor DESIGNABLE true)
|
||||
|
||||
public:
|
||||
static QString browseButtonLabel();
|
||||
@@ -145,6 +147,9 @@ public:
|
||||
using AboutToShowContextMenuHandler = std::function<void (Utils::PathChooser *, QMenu *)>;
|
||||
static void setAboutToShowContextMenuHandler(AboutToShowContextMenuHandler handler);
|
||||
|
||||
QColor errorColor() const;
|
||||
QColor okColor() const;
|
||||
|
||||
private:
|
||||
bool validatePath(FancyLineEdit *edit, QString *errorMessage) const;
|
||||
// Returns overridden title or the one from <title>
|
||||
@@ -165,6 +170,9 @@ public slots:
|
||||
void setPath(const QString &);
|
||||
void setFileName(const Utils::FileName &);
|
||||
|
||||
void setErrorColor(const QColor &errorColor);
|
||||
void setOkColor(const QColor &okColor);
|
||||
|
||||
private:
|
||||
PathChooserPrivate *d;
|
||||
static AboutToShowContextMenuHandler s_aboutToShowContextMenuHandler;
|
||||
|
Reference in New Issue
Block a user