forked from qt-creator/qt-creator
QmlProject: Add support for setting the environment
This allows setting arbitrary environment variables in the .qmlproject. This is required for example qtquickcontrols2.conf and QT_AUTO_SCREEN_SCALE_FACTOR. Task-number: QTCREATORBUG-19513 Change-Id: I8421a9fc7f85d24b3564f1b60f383be3838f2af4 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -127,6 +127,13 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FileName &fi
|
||||
OtherFileFilterItem *otherFileFilterItem = new OtherFileFilterItem(projectItem);
|
||||
setupFileFilterItem(otherFileFilterItem, childNode);
|
||||
projectItem->appendContent(otherFileFilterItem);
|
||||
} else if (childNode->name() == "Environment") {
|
||||
const auto properties = childNode->properties();
|
||||
auto i = properties.constBegin();
|
||||
while (i != properties.constEnd()) {
|
||||
projectItem->addToEnviroment(i.key(), i.value().toString());
|
||||
++i;
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Unknown type:" << childNode->name();
|
||||
}
|
||||
|
||||
@@ -106,4 +106,14 @@ bool QmlProjectItem::matchesFile(const QString &filePath) const
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<Utils::EnvironmentItem> QmlProjectItem::environment() const
|
||||
{
|
||||
return m_environment;
|
||||
}
|
||||
|
||||
void QmlProjectItem::addToEnviroment(const QString &key, const QString &value)
|
||||
{
|
||||
m_environment.append(Utils::EnvironmentItem(key, value));
|
||||
}
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/environment.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QStringList>
|
||||
@@ -60,6 +62,9 @@ public:
|
||||
|
||||
void appendContent(QmlProjectContentItem *item) { m_content.append(item); }
|
||||
|
||||
QList<Utils::EnvironmentItem> environment() const;
|
||||
void addToEnviroment(const QString &key, const QString &value);
|
||||
|
||||
signals:
|
||||
void qmlFilesChanged(const QSet<QString> &, const QSet<QString> &);
|
||||
|
||||
@@ -69,6 +74,7 @@ protected:
|
||||
QStringList m_importPaths;
|
||||
QStringList m_absoluteImportPaths;
|
||||
QString m_mainFile;
|
||||
QList<Utils::EnvironmentItem> m_environment;
|
||||
QList<QmlProjectContentItem *> m_content; // content property
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user