forked from qt-creator/qt-creator
FancyLineEdit: Remove property initialText
The same can be easily achieved by placeholderText nowadays. Change-Id: Icfe0652ae8536c8077cf45a03844275aa1eddad6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
310a2bf96f
commit
8d1a592d16
@@ -105,7 +105,6 @@ public:
|
||||
QColor m_okTextColor;
|
||||
QColor m_errorTextColor = Qt::red;
|
||||
QString m_errorMessage;
|
||||
QString m_initialText;
|
||||
};
|
||||
|
||||
FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
|
||||
@@ -373,20 +372,6 @@ void FancyLineEdit::setFiltering(bool on)
|
||||
}
|
||||
}
|
||||
|
||||
QString FancyLineEdit::initialText() const
|
||||
{
|
||||
return d->m_initialText;
|
||||
}
|
||||
|
||||
void FancyLineEdit::setInitialText(const QString &t)
|
||||
{
|
||||
if (d->m_initialText != t) {
|
||||
d->m_initialText = t;
|
||||
d->m_firstChange = true;
|
||||
setText(t);
|
||||
}
|
||||
}
|
||||
|
||||
QColor FancyLineEdit::errorColor() const
|
||||
{
|
||||
return d->m_errorTextColor;
|
||||
@@ -458,13 +443,13 @@ void FancyLineEdit::validate()
|
||||
}
|
||||
|
||||
d->m_errorMessage.clear();
|
||||
// Are we displaying the initial text?
|
||||
const bool isDisplayingInitialText = !d->m_initialText.isEmpty() && t == d->m_initialText;
|
||||
const State newState = isDisplayingInitialText ?
|
||||
DisplayingInitialText :
|
||||
// Are we displaying the placeholder text?
|
||||
const bool isDisplayingPlaceholderText = !placeholderText().isEmpty() && t.isEmpty();
|
||||
const State newState = isDisplayingPlaceholderText ?
|
||||
DisplayingPlaceholderText :
|
||||
(d->m_validationFunction(this, &d->m_errorMessage) ? Valid : Invalid);
|
||||
setToolTip(d->m_errorMessage);
|
||||
// Changed..figure out if valid changed. DisplayingInitialText is not valid,
|
||||
// Changed..figure out if valid changed. DisplayingPlaceholderText is not valid,
|
||||
// but should not show error color. Also trigger on the first change.
|
||||
if (newState != d->m_state || d->m_firstChange) {
|
||||
const bool validHasChanged = (d->m_state == Valid) != (newState == Valid);
|
||||
|
@@ -73,7 +73,6 @@ class QTCREATOR_UTILS_EXPORT FancyLineEdit : public CompletingLineEdit
|
||||
Q_ENUMS(Side)
|
||||
|
||||
// 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)
|
||||
|
||||
@@ -123,15 +122,12 @@ public:
|
||||
|
||||
// line edit, (out)errorMessage -> valid?
|
||||
typedef std::function<bool(FancyLineEdit *, QString *)> ValidationFunction;
|
||||
enum State { Invalid, DisplayingInitialText, Valid };
|
||||
enum State { Invalid, DisplayingPlaceholderText, Valid };
|
||||
|
||||
State state() const;
|
||||
bool isValid() const;
|
||||
QString errorMessage() const;
|
||||
|
||||
QString initialText() const;
|
||||
void setInitialText(const QString &);
|
||||
|
||||
QColor errorColor() const;
|
||||
void setErrorColor(const QColor &c);
|
||||
|
||||
|
@@ -85,7 +85,7 @@ ProjectIntroPage::ProjectIntroPage(QWidget *parent) :
|
||||
{
|
||||
d->m_ui.setupUi(this);
|
||||
hideStatusLabel();
|
||||
d->m_ui.nameLineEdit->setInitialText(tr("<Enter_Name>"));
|
||||
d->m_ui.nameLineEdit->setPlaceholderText(tr("Enter project name"));
|
||||
d->m_ui.nameLineEdit->setFocus();
|
||||
d->m_ui.nameLineEdit->setValidationFunction([this](FancyLineEdit *edit, QString *errorString) {
|
||||
return validateProjectName(edit->text(), errorString);
|
||||
@@ -178,13 +178,13 @@ bool ProjectIntroPage::validate()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Name valid? Ignore 'DisplayingInitialText' state.
|
||||
// Name valid? Ignore 'DisplayingPlaceholderText' state.
|
||||
bool nameValid = false;
|
||||
switch (d->m_ui.nameLineEdit->state()) {
|
||||
case FancyLineEdit::Invalid:
|
||||
displayStatusMessage(Error, d->m_ui.nameLineEdit->errorMessage());
|
||||
return false;
|
||||
case FancyLineEdit::DisplayingInitialText:
|
||||
case FancyLineEdit::DisplayingPlaceholderText:
|
||||
break;
|
||||
case FancyLineEdit::Valid:
|
||||
nameValid = true;
|
||||
|
Reference in New Issue
Block a user