forked from qt-creator/qt-creator
QmlDesigner: Fix project file getter/setter issues
Task-number: QDS-9781 Change-Id: I2df8cca1c4e5cd10563621b849fb54b29c0d155d Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -135,7 +135,7 @@ QString jsonToQmlProject(const QJsonObject &rootObject)
|
||||
appendBreak();
|
||||
appendString("qdsVersion", versionConfig["designStudio"].toString());
|
||||
appendString("quickVersion", versionConfig["qtQuick"].toString());
|
||||
appendBool("qt6Project", versionConfig["qtQuick"].toString().startsWith("6."));
|
||||
appendBool("qt6Project", versionConfig["qt"].toString() == "6");
|
||||
appendBool("qtForMCUs", rootObject["mcuConfig"].toObject().isEmpty());
|
||||
appendBreak();
|
||||
appendBool("multilanguageSupport", languageConfig["multiLanguageSupport"].toBool());
|
||||
@@ -217,6 +217,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
||||
for (const QString &propName : rootNode->propertyNames()) {
|
||||
QJsonObject *currentObj = &rootObject;
|
||||
QString objKey = propName;
|
||||
QJsonValue value = rootNode->property(propName).value.toJsonValue();
|
||||
|
||||
if (propName.contains("language", Qt::CaseInsensitive)) {
|
||||
currentObj = &languageObject;
|
||||
@@ -240,11 +241,12 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
||||
currentObj = &mcuObject;
|
||||
objKey = "mcuEnabled";
|
||||
} else if (propName.contains("qt6project", Qt::CaseInsensitive)) {
|
||||
// we are skipping these ones in the new json format
|
||||
continue;
|
||||
currentObj = &versionObject;
|
||||
objKey = "qt";
|
||||
value = rootNode->property(propName).value.toBool() ? "6" : "5";
|
||||
}
|
||||
|
||||
currentObj->insert(objKey, rootNode->property(propName).value.toJsonValue());
|
||||
currentObj->insert(objKey, value);
|
||||
}
|
||||
|
||||
// add missing non-object props if any
|
||||
@@ -252,6 +254,10 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
||||
runConfigObject.insert("fileSelectors", QJsonArray{});
|
||||
}
|
||||
|
||||
if (!versionObject.contains("qt")) {
|
||||
versionObject.insert("qt", "5");
|
||||
}
|
||||
|
||||
// convert the the object props
|
||||
for (const QmlJS::SimpleReaderNode::Ptr &childNode : rootNode->children()) {
|
||||
if (childNode->name().contains("files", Qt::CaseInsensitive)) {
|
||||
|
||||
@@ -131,9 +131,40 @@ QJsonObject QmlProjectItem::project() const
|
||||
return m_project;
|
||||
}
|
||||
|
||||
bool QmlProjectItem::isQt6Project() const
|
||||
QString QmlProjectItem::versionQt() const
|
||||
{
|
||||
return m_project["versions"].toObject()["qtQuick"].toString().startsWith("6.");
|
||||
return m_project["versions"].toObject()["qt"].toString();
|
||||
}
|
||||
|
||||
void QmlProjectItem::setVersionQt(const QString &version)
|
||||
{
|
||||
QJsonObject targetObj = m_project["versions"].toObject();
|
||||
targetObj["qt"] = version;
|
||||
insertAndUpdateProjectFile("versions", targetObj);
|
||||
}
|
||||
|
||||
QString QmlProjectItem::versionQtQuick() const
|
||||
{
|
||||
return m_project["versions"].toObject()["qtQuick"].toString();
|
||||
}
|
||||
|
||||
void QmlProjectItem::setVersionQtQuick(const QString &version)
|
||||
{
|
||||
QJsonObject targetObj = m_project["versions"].toObject();
|
||||
targetObj["qtQuick"] = version;
|
||||
insertAndUpdateProjectFile("versions", targetObj);
|
||||
}
|
||||
|
||||
QString QmlProjectItem::versionDesignStudio() const
|
||||
{
|
||||
return m_project["versions"].toObject()["designStudio"].toString();
|
||||
}
|
||||
|
||||
void QmlProjectItem::setVersionDesignStudio(const QString &version)
|
||||
{
|
||||
QJsonObject targetObj = m_project["versions"].toObject();
|
||||
targetObj["designStudio"] = version;
|
||||
insertAndUpdateProjectFile("versions", targetObj);
|
||||
}
|
||||
|
||||
QStringList QmlProjectItem::importPaths() const
|
||||
|
||||
@@ -29,7 +29,16 @@ public:
|
||||
explicit QmlProjectItem(const Utils::FilePath &filePath);
|
||||
|
||||
bool isQt4McuProject() const;
|
||||
bool isQt6Project() const;
|
||||
|
||||
|
||||
QString versionQt() const;
|
||||
void setVersionQt(const QString &version);
|
||||
|
||||
QString versionQtQuick() const;
|
||||
void setVersionQtQuick(const QString &version);
|
||||
|
||||
QString versionDesignStudio() const;
|
||||
void setVersionDesignStudio(const QString &version);
|
||||
|
||||
Utils::FilePath sourceDirectory() const;
|
||||
QString targetDirectory() const;
|
||||
|
||||
@@ -484,7 +484,7 @@ bool QmlBuildSystem::qtForMCUs() const
|
||||
|
||||
bool QmlBuildSystem::qt6Project() const
|
||||
{
|
||||
return m_projectItem->isQt6Project();
|
||||
return m_projectItem->versionQt() == "6";
|
||||
}
|
||||
|
||||
Utils::EnvironmentItems QmlBuildSystem::environment() const
|
||||
@@ -547,4 +547,19 @@ Utils::FilePaths QmlBuildSystem::files() const
|
||||
return m_projectItem->files();
|
||||
}
|
||||
|
||||
QString QmlBuildSystem::versionQt() const
|
||||
{
|
||||
return m_projectItem->versionQt();
|
||||
}
|
||||
|
||||
QString QmlBuildSystem::versionQtQuick() const
|
||||
{
|
||||
return m_projectItem->versionQtQuick();
|
||||
}
|
||||
|
||||
QString QmlBuildSystem::versionDesignStudio() const
|
||||
{
|
||||
return m_projectItem->versionDesignStudio();
|
||||
}
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -81,6 +81,10 @@ public:
|
||||
QStringList importPaths() const;
|
||||
Utils::FilePaths files() const;
|
||||
|
||||
QString versionQt() const;
|
||||
QString versionQtQuick() const;
|
||||
QString versionDesignStudio() const;
|
||||
|
||||
bool addFiles(const QStringList &filePaths);
|
||||
void refreshProjectFile();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user