diff --git a/doc/src/projects/creator-projects-custom-wizards.qdoc b/doc/src/projects/creator-projects-custom-wizards.qdoc index 4aefc1295e71dab9c152e65120bf43b08cc9cafb..9c50be37adf26bcd52708a284a3716e220544858 100644 --- a/doc/src/projects/creator-projects-custom-wizards.qdoc +++ b/doc/src/projects/creator-projects-custom-wizards.qdoc @@ -257,7 +257,7 @@ <fieldpagetitle xml:lang="de">Hallo Welt Parameter</fieldpagetitle> <fields> <field mandatory="true" name="MESSAGE"> - <fieldcontrol class="QLineEdit" validator='^[^"]+$' defaulttext="Hello world!" /> + <fieldcontrol class="QLineEdit" validator='^[^"]+$' defaulttext="Hello world!" placeholdertext="Enter a message"/> <fielddescription>Hello world message:</fielddescription> <fielddescription xml:lang="de">Hallo-Welt-Nachricht:</fielddescription> </field> @@ -290,6 +290,9 @@ \li \c defaulttext specifies text that appears in the field by default. + \li For a QLineEdit, \c placeholdertext specifies placeholder text that appears in the + field. + \li \c fielddescription specifies the field name that appears on the wizard page. diff --git a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml index 7ba312f925e23184f673398c930bfb59663903cb..df3724c26894df8ac950122f4d5accee9b5da964 100644 --- a/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml +++ b/share/qtcreator/templates/wizards/helloworld/wizard_sample.xml @@ -51,7 +51,7 @@ leave room for the Qt 4 target page. <fields> <field mandatory="true" name="MESSAGE"> <fieldcontrol class="QLineEdit" validator='^[^"]+$' - defaulttext="Hello world from project '%ProjectName:c%'!" /> + defaulttext="Hello world from project '%ProjectName:c%'!" placeholdertext="Enter a message"/> <fielddescription>Hello world message:</fielddescription> <fielddescription xml:lang="de">Hallo-Welt-Nachricht:</fielddescription> </field> diff --git a/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml b/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml index cdfd456f15059d9557127f91167ee76b550accf5..d608fe3a1dedeb1f4a361d334ec5101327286a77 100644 --- a/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml +++ b/share/qtcreator/templates/wizards/listmodel/wizard_sample.xml @@ -46,7 +46,7 @@ Custom class wizard example configuration file. --> <fieldpagetitle xml:lang="de">Parameter des ListModel</fieldpagetitle> <fields> <field name="ClassName"> - <fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$" defaulttext="MyListModel" /> + <fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$" defaulttext="MyListModel" placeholdertext="Enter a class name"/> <fielddescription>Class name:</fielddescription> <fielddescription xml:lang="de">Klassenname:</fielddescription> </field> diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index f4d1a76236b9fc3c34afe54e4c6e309a7fc17fd7..72ce236fba5b7f6b46c4b307ed909559eb8f52af 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -153,8 +153,8 @@ void TextFieldCheckBox::slotStateChanged(int cs) \sa ProjectExplorer::CustomWizard */ -CustomWizardFieldPage::LineEditData::LineEditData(QLineEdit* le, const QString &defText) : - lineEdit(le), defaultText(defText) +CustomWizardFieldPage::LineEditData::LineEditData(QLineEdit* le, const QString &defText, const QString &pText) : + lineEdit(le), defaultText(defText), placeholderText(pText) { } @@ -380,7 +380,8 @@ QWidget *CustomWizardFieldPage::registerLineEdit(const QString &fieldName, connect(lineEdit, SIGNAL(textEdited(QString)), SIGNAL(completeChanged())); const QString defaultText = field.controlAttributes.value(QLatin1String("defaulttext")); - m_lineEdits.push_back(LineEditData(lineEdit, defaultText)); + const QString placeholderText = field.controlAttributes.value(QLatin1String("placeholdertext")); + m_lineEdits.push_back(LineEditData(lineEdit, defaultText, placeholderText)); return lineEdit; } @@ -396,6 +397,8 @@ void CustomWizardFieldPage::initializePage() CustomWizardContext::replaceFields(m_context->baseReplacements, &defaultText); led.lineEdit->setText(defaultText); } + if (!led.placeholderText.isEmpty()) + led.lineEdit->setPlaceholderText(led.placeholderText); } foreach (const TextEditData &ted, m_textEdits) { if (!ted.userChange.isNull()) { diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.h b/src/plugins/projectexplorer/customwizard/customwizardpage.h index 766845268d1522fa55aada051b09425aeb4567a7..21ded031c547e13e4b4771a7798f9ca54e971c41 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.h +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.h @@ -128,9 +128,10 @@ protected: void clearError(); private: struct LineEditData { - explicit LineEditData(QLineEdit* le = 0, const QString &defText = QString()); + explicit LineEditData(QLineEdit* le = 0, const QString &defText = QString(), const QString &pText = QString()); QLineEdit* lineEdit; QString defaultText; + QString placeholderText; QString userChange; }; struct TextEditData {