forked from qt-creator/qt-creator
JsonWizard: Fix restoreLastHistoryItem for LineEdit
The value was successfully loaded from the history, but overwritten again. Let's now check if the line edit already contains a value (loaded from history) before setting the default text. Change-Id: Ic0acad83f76e0aca76309dfd213183a210d334ac Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
98fb412e6e
commit
e3abd5b348
@@ -561,7 +561,7 @@ bool LineEditField::validate(MacroExpander *expander, QString *message)
|
||||
m_currentText.clear();
|
||||
}
|
||||
} else {
|
||||
w->setText(expander->expand(m_defaultText));
|
||||
setDefaultText(w, expander);
|
||||
m_isModified = false;
|
||||
}
|
||||
} else {
|
||||
@@ -579,7 +579,7 @@ void LineEditField::initializeData(MacroExpander *expander)
|
||||
auto w = qobject_cast<FancyLineEdit *>(widget());
|
||||
QTC_ASSERT(w, return);
|
||||
m_isValidating = true;
|
||||
w->setText(expander->expand(m_defaultText));
|
||||
setDefaultText(w, expander);
|
||||
w->setPlaceholderText(m_placeholderText);
|
||||
m_isModified = false;
|
||||
m_isValidating = false;
|
||||
@@ -595,6 +595,15 @@ QVariant LineEditField::toSettings() const
|
||||
return qobject_cast<FancyLineEdit *>(widget())->text();
|
||||
}
|
||||
|
||||
void LineEditField::setDefaultText(FancyLineEdit *edit, MacroExpander *expander)
|
||||
{
|
||||
if (!edit->text().isEmpty())
|
||||
return;
|
||||
|
||||
const QString expandedText = expander->expand(m_defaultText);
|
||||
edit->setText(expandedText);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// TextEditFieldData:
|
||||
// --------------------------------------------------------------------
|
||||
|
@@ -111,6 +111,8 @@ private:
|
||||
void fromSettings(const QVariant &value) override;
|
||||
QVariant toSettings() const override;
|
||||
|
||||
void setDefaultText(Utils::FancyLineEdit *edit, Utils::MacroExpander *expander);
|
||||
|
||||
bool m_isModified = false;
|
||||
bool m_isValidating = false;
|
||||
bool m_restoreLastHistoryItem = false;
|
||||
|
Reference in New Issue
Block a user