forked from qt-creator/qt-creator
QmlPuppet: Move fixResourcePaths to QmlPrivateGate
Change-Id: I9bbd22c19df64d3cfda3bbf02d9c72da5c2a0542 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
c4489a19b4
commit
a02438a44f
@@ -872,7 +872,7 @@ void NodeInstanceServer::setInstancePropertyVariant(const PropertyValueContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (valueContainer.isDynamic() && valueContainer.instanceId() == 0 && engine())
|
if (valueContainer.isDynamic() && valueContainer.instanceId() == 0 && engine())
|
||||||
rootContext()->setContextProperty(name, Internal::ObjectNodeInstance::fixResourcePaths(value));
|
rootContext()->setContextProperty(name, Internal::QmlPrivateGate::fixResourcePaths(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -377,56 +377,6 @@ QVariant ObjectNodeInstance::convertSpecialCharacter(const QVariant& value) cons
|
|||||||
return specialCharacterConvertedValue;
|
return specialCharacterConvertedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant ObjectNodeInstance::fixResourcePaths(const QVariant &value)
|
|
||||||
{
|
|
||||||
if (value.type() == QVariant::Url)
|
|
||||||
{
|
|
||||||
const QUrl url = value.toUrl();
|
|
||||||
if (url.scheme() == QLatin1String("qrc")) {
|
|
||||||
const QString path = QLatin1String("qrc:") + url.path();
|
|
||||||
QString qrcSearchPath = qgetenv("QMLDESIGNER_RC_PATHS");
|
|
||||||
if (!qrcSearchPath.isEmpty()) {
|
|
||||||
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
|
|
||||||
foreach (const QString &qrcPath, searchPaths) {
|
|
||||||
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
|
|
||||||
if (qrcDefintion.count() == 2) {
|
|
||||||
QString fixedPath = path;
|
|
||||||
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
|
|
||||||
if (QFileInfo(fixedPath).exists()) {
|
|
||||||
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
|
|
||||||
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
|
||||||
return QUrl(fixedPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (value.type() == QVariant::String) {
|
|
||||||
const QString str = value.toString();
|
|
||||||
if (str.contains(QLatin1String("qrc:"))) {
|
|
||||||
QString qrcSearchPath = qgetenv("QMLDESIGNER_RC_PATHS");
|
|
||||||
if (!qrcSearchPath.isEmpty()) {
|
|
||||||
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
|
|
||||||
foreach (const QString &qrcPath, searchPaths) {
|
|
||||||
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
|
|
||||||
if (qrcDefintion.count() == 2) {
|
|
||||||
QString fixedPath = str;
|
|
||||||
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
|
|
||||||
if (QFileInfo(fixedPath).exists()) {
|
|
||||||
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
|
|
||||||
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
|
||||||
return fixedPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectNodeInstance::updateAllDirtyNodesRecursive()
|
void ObjectNodeInstance::updateAllDirtyNodesRecursive()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -469,7 +419,7 @@ void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVar
|
|||||||
if (value.canConvert<Enumeration>())
|
if (value.canConvert<Enumeration>())
|
||||||
adjustedValue = convertEnumToValue(value, name);
|
adjustedValue = convertEnumToValue(value, name);
|
||||||
else
|
else
|
||||||
adjustedValue = fixResourcePaths(value);
|
adjustedValue = QmlPrivateGate::fixResourcePaths(value);
|
||||||
|
|
||||||
|
|
||||||
QVariant oldValue = property.read();
|
QVariant oldValue = property.read();
|
||||||
|
|||||||
@@ -184,8 +184,6 @@ public:
|
|||||||
|
|
||||||
virtual void setNodeSource(const QString &source);
|
virtual void setNodeSource(const QString &source);
|
||||||
|
|
||||||
static QVariant fixResourcePaths(const QVariant &value);
|
|
||||||
|
|
||||||
virtual void updateAllDirtyNodesRecursive();
|
virtual void updateAllDirtyNodesRecursive();
|
||||||
|
|
||||||
virtual PropertyNameList ignoredProperties() const;
|
virtual PropertyNameList ignoredProperties() const;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QQmlComponent>
|
#include <QQmlComponent>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include <private/qquicktransition_p.h>
|
#include <private/qquicktransition_p.h>
|
||||||
#include <private/qquickanimation_p.h>
|
#include <private/qquickanimation_p.h>
|
||||||
@@ -233,7 +234,7 @@ static void fixResourcePathsForObject(QObject *object)
|
|||||||
QQmlProperty property(object, propertyName, QQmlEngine::contextForObject(object));
|
QQmlProperty property(object, propertyName, QQmlEngine::contextForObject(object));
|
||||||
|
|
||||||
const QVariant value = property.read();
|
const QVariant value = property.read();
|
||||||
const QVariant fixedValue = ObjectNodeInstance::fixResourcePaths(value);
|
const QVariant fixedValue = fixResourcePaths(value);
|
||||||
if (value != fixedValue) {
|
if (value != fixedValue) {
|
||||||
property.write(fixedValue);
|
property.write(fixedValue);
|
||||||
}
|
}
|
||||||
@@ -370,6 +371,56 @@ QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumb
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant fixResourcePaths(const QVariant &value)
|
||||||
|
{
|
||||||
|
if (value.type() == QVariant::Url)
|
||||||
|
{
|
||||||
|
const QUrl url = value.toUrl();
|
||||||
|
if (url.scheme() == QLatin1String("qrc")) {
|
||||||
|
const QString path = QLatin1String("qrc:") + url.path();
|
||||||
|
QString qrcSearchPath = qgetenv("QMLDESIGNER_RC_PATHS");
|
||||||
|
if (!qrcSearchPath.isEmpty()) {
|
||||||
|
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
|
||||||
|
foreach (const QString &qrcPath, searchPaths) {
|
||||||
|
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
|
||||||
|
if (qrcDefintion.count() == 2) {
|
||||||
|
QString fixedPath = path;
|
||||||
|
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
|
||||||
|
if (QFileInfo(fixedPath).exists()) {
|
||||||
|
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
|
||||||
|
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
||||||
|
return QUrl(fixedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value.type() == QVariant::String) {
|
||||||
|
const QString str = value.toString();
|
||||||
|
if (str.contains(QLatin1String("qrc:"))) {
|
||||||
|
QString qrcSearchPath = qgetenv("QMLDESIGNER_RC_PATHS");
|
||||||
|
if (!qrcSearchPath.isEmpty()) {
|
||||||
|
const QStringList searchPaths = qrcSearchPath.split(QLatin1Char(';'));
|
||||||
|
foreach (const QString &qrcPath, searchPaths) {
|
||||||
|
const QStringList qrcDefintion = qrcPath.split(QLatin1Char('='));
|
||||||
|
if (qrcDefintion.count() == 2) {
|
||||||
|
QString fixedPath = str;
|
||||||
|
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
|
||||||
|
if (QFileInfo(fixedPath).exists()) {
|
||||||
|
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
|
||||||
|
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
||||||
|
return fixedPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QObject *createComponent(const QUrl &componentUrl, QQmlContext *context)
|
QObject *createComponent(const QUrl &componentUrl, QQmlContext *context)
|
||||||
{
|
{
|
||||||
ComponentCompleteDisabler disableComponentComplete;
|
ComponentCompleteDisabler disableComponentComplete;
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
void readPropertyValue(QObject *object, const QByteArray &propertyName, QQmlContext *qmlContext, bool *ok);
|
void readPropertyValue(QObject *object, const QByteArray &propertyName, QQmlContext *qmlContext, bool *ok);
|
||||||
void createNewDynamicProperty(const ObjectNodeInstancePointer &nodeInstance, const QString &name);
|
void createNewDynamicProperty(const ObjectNodeInstancePointer &nodeInstance, const QString &name);
|
||||||
void registerNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance);
|
void registerNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance);
|
||||||
|
QVariant fixResourcePaths(const QVariant &value);
|
||||||
QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context);
|
QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context);
|
||||||
QObject *createComponent(const QUrl &componentUrl, QQmlContext *context);
|
QObject *createComponent(const QUrl &componentUrl, QQmlContext *context);
|
||||||
void tweakObjects(QObject *object);
|
void tweakObjects(QObject *object);
|
||||||
@@ -78,7 +79,6 @@ public:
|
|||||||
const PropertyName &baseName = PropertyName(),
|
const PropertyName &baseName = PropertyName(),
|
||||||
QObjectList *inspectedObjects = 0);
|
QObjectList *inspectedObjects = 0);
|
||||||
|
|
||||||
|
|
||||||
} // namespace QmlPrivateGate
|
} // namespace QmlPrivateGate
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|||||||
Reference in New Issue
Block a user