Commit 12c65d26 authored by Tim Jenssen's avatar Tim Jenssen

QmlDesigner: improve fixResourcePath()

Change-Id: I675dfe507dbe2989b0a015baf75d0423ba088993
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent 83b74699
......@@ -235,9 +235,17 @@ static void allSubObject(QObject *object, QObjectList &objectList)
}
}
static QString qmlDesignerRCPath()
{
static const QString qmlDesignerRcPathsString = QString::fromLocal8Bit(
qgetenv("QMLDESIGNER_RC_PATHS"));
return qmlDesignerRcPathsString;
}
static void fixResourcePathsForObject(QObject *object)
{
if (qEnvironmentVariableIsEmpty("QMLDESIGNER_RC_PATHS"))
static const bool qmlDesignerRcPathsIsEmpty = qmlDesignerRCPath().isEmpty();
if (qmlDesignerRcPathsIsEmpty)
return;
PropertyNameList propertyNameList = propertyNameListForWritableProperties(object);
......@@ -376,14 +384,12 @@ QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumb
QVariant fixResourcePaths(const QVariant &value)
{
if (value.type() == QVariant::Url)
{
if (value.type() == QVariant::Url) {
const QUrl url = value.toUrl();
if (url.scheme() == QLatin1String("qrc")) {
const QString path = QLatin1String("qrc:") + url.path();
QString qrcSearchPath = QString::fromLocal8Bit(qgetenv("QMLDESIGNER_RC_PATHS"));
if (!qrcSearchPath.isEmpty()) {
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
if (!qmlDesignerRCPath().isEmpty()) {
const QStringList searchPaths = qmlDesignerRCPath().split(QLatin1Char(';'));
foreach (const QString &qrcPath, searchPaths) {
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
if (qrcDefintion.count() == 2) {
......@@ -402,9 +408,8 @@ QVariant fixResourcePaths(const QVariant &value)
if (value.type() == QVariant::String) {
const QString str = value.toString();
if (str.contains(QLatin1String("qrc:"))) {
QString qrcSearchPath = QString::fromLocal8Bit(qgetenv("QMLDESIGNER_RC_PATHS"));
if (!qrcSearchPath.isEmpty()) {
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
if (!qmlDesignerRCPath().isEmpty()) {
const QStringList searchPaths = qmlDesignerRCPath().split(QLatin1Char(';'));
foreach (const QString &qrcPath, searchPaths) {
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
if (qrcDefintion.count() == 2) {
......
......@@ -87,6 +87,13 @@ QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumb
return QQuickDesignerSupportItems::createPrimitive(typeName, majorNumber, minorNumber, context);
}
static QString qmlDesignerRCPath()
{
static const QString qmlDesignerRcPathsString = QString::fromLocal8Bit(
qgetenv("QMLDESIGNER_RC_PATHS"));
return qmlDesignerRcPathsString;
}
QVariant fixResourcePaths(const QVariant &value)
{
if (value.type() == QVariant::Url)
......@@ -94,9 +101,8 @@ QVariant fixResourcePaths(const QVariant &value)
const QUrl url = value.toUrl();
if (url.scheme() == QLatin1String("qrc")) {
const QString path = QLatin1String("qrc:") + url.path();
QString qrcSearchPath = QString::fromLocal8Bit(qgetenv("QMLDESIGNER_RC_PATHS"));
if (!qrcSearchPath.isEmpty()) {
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
if (!qmlDesignerRCPath().isEmpty()) {
const QStringList searchPaths = qmlDesignerRCPath().split(QLatin1Char(';'));
foreach (const QString &qrcPath, searchPaths) {
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
if (qrcDefintion.count() == 2) {
......@@ -115,9 +121,8 @@ QVariant fixResourcePaths(const QVariant &value)
if (value.type() == QVariant::String) {
const QString str = value.toString();
if (str.contains(QLatin1String("qrc:"))) {
QString qrcSearchPath = QString::fromLocal8Bit(qgetenv("QMLDESIGNER_RC_PATHS"));
if (!qrcSearchPath.isEmpty()) {
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
if (!qmlDesignerRCPath().isEmpty()) {
const QStringList searchPaths = qmlDesignerRCPath().split(QLatin1Char(';'));
foreach (const QString &qrcPath, searchPaths) {
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
if (qrcDefintion.count() == 2) {
......@@ -136,10 +141,9 @@ QVariant fixResourcePaths(const QVariant &value)
return value;
}
void fixResourcePathsForObject(QObject *object)
static void fixResourcePathsForObject(QObject *object)
{
if (qEnvironmentVariableIsEmpty("QMLDESIGNER_RC_PATHS"))
if (qmlDesignerRCPath().isEmpty())
return;
PropertyNameList propertyNameList = propertyNameListForWritableProperties(object);
......
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