Commit 5a3aa3fc authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: Allow .ui.qml file in component creation

Change-Id: I3ae5822820c365d0cbc7d679c6365a25f34b1637
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 92038622
......@@ -111,6 +111,8 @@ public:
QStringList result;
QStringList sourcePreview;
QString suffix;
if (!m_idName.isEmpty())
sourcePreview.append(QLatin1String(" id: ") + m_idName);
else
......@@ -127,7 +129,7 @@ public:
foreach (const QString &property, sortedPropertiesWithoutId)
sourcePreview.append(QLatin1String(" ") + property + QLatin1String(": ") + propertyReader.readAstValue(property));
bool confirm = ComponentNameDialog::go(&componentName, &path,
const bool confirm = ComponentNameDialog::go(&componentName, &path, &suffix,
sortedPropertiesWithoutId,
sourcePreview,
QFileInfo(currentFileName).fileName(),
......@@ -140,7 +142,7 @@ public:
return;
const QString newFileName = path + QLatin1Char('/') + componentName
+ QLatin1String(".qml");
+ QLatin1String(".") + suffix;
QString imports;
UiProgram *prog = currentFile->qmljsDocument()->qmlProgram();
......
......@@ -51,6 +51,7 @@ ComponentNameDialog::~ComponentNameDialog()
bool ComponentNameDialog::go(QString *proposedName,
QString *proposedPath,
QString *proposedSuffix,
const QStringList &properties,
const QStringList &sourcePreview,
const QString &oldFileName,
......@@ -60,6 +61,8 @@ bool ComponentNameDialog::go(QString *proposedName,
Q_ASSERT(proposedName);
Q_ASSERT(proposedPath);
const bool isUiFile = QFileInfo(oldFileName).completeSuffix() == "ui.qml";
ComponentNameDialog d(parent);
d.ui->componentNameEdit->setNamespacesEnabled(false);
d.ui->componentNameEdit->setLowerCaseFileName(false);
......@@ -71,6 +74,8 @@ bool ComponentNameDialog::go(QString *proposedName,
d.ui->pathEdit->setHistoryCompleter(QLatin1String("QmlJs.Component.History"));
d.ui->pathEdit->setPath(*proposedPath);
d.ui->label->setText(tr("Property assignments for %1:").arg(oldFileName));
d.ui->checkBox->setChecked(isUiFile);
d.ui->checkBox->setVisible(isUiFile);
d.m_sourcePreview = sourcePreview;
d.setProperties(properties);
......@@ -84,6 +89,11 @@ bool ComponentNameDialog::go(QString *proposedName,
*proposedName = d.ui->componentNameEdit->text();
*proposedPath = d.ui->pathEdit->path();
if (d.ui->checkBox->isChecked())
*proposedSuffix = "ui.qml";
else
*proposedSuffix = "qml";
if (result)
*result = d.propertiesToKeep();
return true;
......
......@@ -40,7 +40,7 @@ public:
explicit ComponentNameDialog(QWidget *parent = 0);
~ComponentNameDialog();
static bool go(QString *proposedName, QString *proposedPath,
static bool go(QString *proposedName, QString *proposedPath, QString *proposedSuffix,
const QStringList &properties, const QStringList &sourcePreview, const QString &oldFileName,
QStringList *result,
QWidget *parent = 0);
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>495</width>
<height>311</height>
<height>330</height>
</rect>
</property>
<property name="windowTitle">
......@@ -95,6 +95,13 @@
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>ui.qml file</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment