Files
qt-creator/share/qtcreator/qmldesigner/effectComposerQmlSources/ValueImage.qml
Shrief Gabr 836c0a11e4 EffectComposer: Open effectComposerNodes/images by default in UrlChooser
Task-number: QDS-11464
Change-Id: I96bb7e359bd41637f0b1906a523c8a5de190981d
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
2024-03-08 13:56:22 +00:00

57 lines
1.9 KiB
QML

// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import QtQuick
import HelperWidgets as HelperWidgets
import StudioTheme as StudioTheme
import EffectComposerBackend
Row {
id: itemPane
spacing: 5
HelperWidgets.UrlChooser {
backendValue: uniformBackendValue
resourcesPath: EffectComposerBackend.rootView.imagesPath()
actionIndicatorVisible: false
comboBox.width: Math.min(parent.width - 70, 300)
onAbsoluteFilePathChanged: uniformValue = absoluteFilePath
function defaultAsString(defaultPath) {
if (!defaultPath)
return undefined
let urlStr = defaultPath.toString()
urlStr = urlStr.replace(/^(file:\/{3})/, "")
// Prepend slash if there is no drive letter
if (urlStr.length > 1 && urlStr[1] !== ':')
urlStr = '/' + urlStr;
return urlStr
}
Component.onCompleted: {
let originalPath = defaultAsString(
EffectComposerBackend.rootView.uniformDefaultImage(nodeName, uniformName))
let originalName = originalPath ? originalPath.split('/').pop() : undefined
if (originalName) {
defaultItems = [originalName]
defaultPaths = [originalPath]
} else {
let currentPath = uniformDefaultValue ? defaultAsString(uniformDefaultValue) : undefined
let currentName = currentPath ? currentPath.split('/').pop() : undefined
if (currentName) {
defaultItems = [currentName]
defaultPaths = [currentPath]
} else {
defaultItems = []
defaultPaths = []
}
}
}
}
}