diff --git a/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml b/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml index 571fac50002..832350ef177 100644 --- a/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml +++ b/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml @@ -19,5 +19,19 @@ Row { actionIndicatorVisible: false onAbsoluteFilePathChanged: uniformValue = absoluteFilePath + + function defaultAsString() { + let urlStr = uniformDefaultValue.toString() + urlStr = urlStr.replace(/^(file:\/{3})/, "") + + // Prepend slash if there is no drive letter + if (urlStr.length > 1 && urlStr[1] !== ':') + urlStr = '/' + urlStr; + + return urlStr + } + + defaultItems: [uniformDefaultValue.split('/').pop()] + defaultPaths: [defaultAsString(uniformDefaultValue)] } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml index 485640bcf84..9b0252c02c0 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/UrlChooser.qml @@ -22,6 +22,10 @@ Row { // by QtQuick3D to add built-in primitives to the model. property var defaultItems + // These paths will be used for default items if they are defined. Otherwise, default item + // itself is used as the path. + property var defaultPaths + // Current item property string absoluteFilePath: "" @@ -422,8 +426,10 @@ Row { if (root.defaultItems !== undefined) { for (var i = 0; i < root.defaultItems.length; ++i) { comboBox.listModel.append({ - absoluteFilePath: "", - relativeFilePath: root.defaultItems[i], + absoluteFilePath: root.defaultPaths ? root.defaultPaths[i] + : "", + relativeFilePath: root.defaultPaths ? root.defaultPaths[i] + : root.defaultItems[i], name: root.defaultItems[i], group: 0 }) @@ -454,6 +460,7 @@ Row { } onDefaultItemsChanged: root.createModel() + onDefaultPathsChanged: root.createModel() Component.onCompleted: { root.createModel() diff --git a/src/plugins/effectmakernew/uniform.h b/src/plugins/effectmakernew/uniform.h index f5731af00a8..943942639c9 100644 --- a/src/plugins/effectmakernew/uniform.h +++ b/src/plugins/effectmakernew/uniform.h @@ -25,6 +25,7 @@ class Uniform : public QObject Q_PROPERTY(QVariant uniformBackendValue READ backendValue NOTIFY uniformBackendValueChanged) Q_PROPERTY(QVariant uniformMinValue MEMBER m_minValue CONSTANT) Q_PROPERTY(QVariant uniformMaxValue MEMBER m_maxValue CONSTANT) + Q_PROPERTY(QVariant uniformDefaultValue MEMBER m_defaultValue CONSTANT) public: enum class Type diff --git a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp index aae0867c915..3c419a3e82d 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/fileresourcesmodel.cpp @@ -158,6 +158,13 @@ QString FileResourcesModel::resolve(const QString &relative) const if (!QUrl::fromUserInput(relative, m_docPath.path()).isLocalFile()) return relative; + const QUrl relUrl(relative); + if (relUrl.isLocalFile()) { + QString localFile = relUrl.toLocalFile(); + if (QDir::isAbsolutePath(localFile)) + return localFile; + } + return QFileInfo(m_docPath, relative).absoluteFilePath(); }