[ui] convert string paths to urls outside Viewers

* fix external image drop on 2D Viewer
* fix 3D model loading from "Load Model" button
This commit is contained in:
Yann Lanthony 2018-03-09 18:46:35 +01:00
parent ccab9cb663
commit 266f0985d2
4 changed files with 11 additions and 26 deletions

View file

@ -21,7 +21,7 @@ Item {
// retrieve viewpoints inner data
QtObject {
id: _viewpoint
property string source: viewpoint ? viewpoint.get("path").value : ''
property url source: viewpoint ? Filepath.stringToUrl(viewpoint.get("path").value) : ''
property string metadataStr: viewpoint ? viewpoint.get("metadata").value : ''
property var metadata: metadataStr ? JSON.parse(viewpoint.get("metadata").value) : null
}
@ -68,7 +68,7 @@ Item {
Image {
anchors.fill: parent
anchors.margins: 4
source: Filepath.stringToUrl(imageDelegate.source)
source: imageDelegate.source
sourceSize: Qt.size(100, 100)
asynchronous: true
autoTransform: true

View file

@ -8,7 +8,7 @@ FocusScope {
id: root
clip: true
property string source
property url source
property var metadata
// slots
@ -49,7 +49,7 @@ FocusScope {
fillMode: Image.PreserveAspectFit
autoTransform: true
onWidthChanged: if(status==Image.Ready) fit()
source: Filepath.stringToUrl(root.source)
source: root.source
onStatusChanged: {
// update cache source when image is loaded
if(status === Image.Ready)

View file

@ -18,7 +18,7 @@ Item {
property variant reconstruction: _reconstruction
readonly property variant cameraInits: _reconstruction.cameraInits
readonly property string meshFile: _reconstruction.meshFile
readonly property url meshFile: Filepath.stringToUrl(_reconstruction.meshFile)
property bool readOnly: false
implicitWidth: 300
@ -31,17 +31,12 @@ Item {
// Load a 3D media file in the 3D viewer
function load3DMedia(filepath)
{
if(Filepath.extension(filepath) === ".abc")
switch(Filepath.extension(filepath))
{
viewer3D.abcSource = filepath
case ".abc": viewer3D.abcSource = filepath; break;
case ".exr": viewer3D.depthMapSource = filepath; break;
case ".obj": viewer3D.source = filepath; break;
}
else if(Filepath.extension(filepath) === ".exr")
{
// viewer3D.clearDepthMap()
viewer3D.depthMapSource = filepath
}
else
viewer3D.source = filepath
}
Connections {
@ -137,23 +132,13 @@ Item {
background: Rectangle { color: palette.base; opacity: 0.5 }
}
Label {
text: "3D Model not available"
visible: meshFile == ''
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
padding: 6
background: Rectangle { color: palette.base; opacity: 0.5 }
}
// Load reconstructed model
Button {
text: "Load Model"
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
visible: meshFile != '' && (viewer3D.source != meshFile)
visible: meshFile != "" && (viewer3D.source != meshFile)
onClicked: load3DMedia(meshFile)
}
}

View file

@ -391,7 +391,7 @@ ApplicationWindow {
&& attr.desc.type === "File"
&& _3dFileExtensions.indexOf(Filepath.extension(attr.value)) > - 1 )
{
workspaceView.load3DMedia(attr.value)
workspaceView.load3DMedia(Filepath.stringToUrl(attr.value))
break // only load first model found
}
}