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());
|
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
|
bool PathChooser::isReadOnly() const
|
||||||
{
|
{
|
||||||
return d->m_lineEdit->isReadOnly();
|
return d->m_lineEdit->isReadOnly();
|
||||||
@@ -461,6 +471,16 @@ void PathChooser::setAboutToShowContextMenuHandler(PathChooser::AboutToShowConte
|
|||||||
s_aboutToShowContextMenuHandler = handler;
|
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
|
FancyLineEdit::ValidationFunction PathChooser::defaultValidationFunction() const
|
||||||
{
|
{
|
||||||
return std::bind(&PathChooser::validatePath, this, std::placeholders::_1, std::placeholders::_2);
|
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:
|
// 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 fileName READ fileName WRITE setFileName DESIGNABLE false)
|
||||||
Q_PROPERTY(Utils::FileName baseFileName READ baseFileName WRITE setBaseFileName 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:
|
public:
|
||||||
static QString browseButtonLabel();
|
static QString browseButtonLabel();
|
||||||
@@ -145,6 +147,9 @@ public:
|
|||||||
using AboutToShowContextMenuHandler = std::function<void (Utils::PathChooser *, QMenu *)>;
|
using AboutToShowContextMenuHandler = std::function<void (Utils::PathChooser *, QMenu *)>;
|
||||||
static void setAboutToShowContextMenuHandler(AboutToShowContextMenuHandler handler);
|
static void setAboutToShowContextMenuHandler(AboutToShowContextMenuHandler handler);
|
||||||
|
|
||||||
|
QColor errorColor() const;
|
||||||
|
QColor okColor() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool validatePath(FancyLineEdit *edit, QString *errorMessage) const;
|
bool validatePath(FancyLineEdit *edit, QString *errorMessage) const;
|
||||||
// Returns overridden title or the one from <title>
|
// Returns overridden title or the one from <title>
|
||||||
@@ -165,6 +170,9 @@ public slots:
|
|||||||
void setPath(const QString &);
|
void setPath(const QString &);
|
||||||
void setFileName(const Utils::FileName &);
|
void setFileName(const Utils::FileName &);
|
||||||
|
|
||||||
|
void setErrorColor(const QColor &errorColor);
|
||||||
|
void setOkColor(const QColor &okColor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PathChooserPrivate *d;
|
PathChooserPrivate *d;
|
||||||
static AboutToShowContextMenuHandler s_aboutToShowContextMenuHandler;
|
static AboutToShowContextMenuHandler s_aboutToShowContextMenuHandler;
|
||||||
|
Reference in New Issue
Block a user