T466: Only one gcode file can be loaded at a time, and deleting previous gcode file when loading non-gcode file

Merge changes : Only call backgroundItem.hasMesh if/on an imported model (skips if only curaprofiles get loaded)
This commit is contained in:
Victor Larchenko 2016-10-23 14:53:25 +06:00 committed by Youness Alaoui
parent 1f84ad7084
commit b4a7173a61
4 changed files with 67 additions and 12 deletions

View file

@ -269,16 +269,16 @@ UM.MainWindow
if(drop.urls.length > 0)
{
// Import models
var imported_model = -1;
for(var i in drop.urls)
{
// There is no endsWith in this version of JS...
if ((drop.urls[i].length <= 12) || (drop.urls[i].substring(drop.urls[i].length-12) !== ".curaprofile")) {
// Drop an object
UM.MeshFileHandler.readLocalFile(drop.urls[i]);
if (i == drop.urls.length - 1)
Printer.loadFile(drop.urls[i]);
if (imported_model == -1)
{
var meshName = backgroundItem.getMeshName(drop.urls[i].toString());
backgroundItem.hasMesh(decodeURIComponent(meshName));
imported_model = i;
}
}
}
@ -297,6 +297,11 @@ UM.MainWindow
}
messageDialog.open()
}
if (imported_model != -1)
{
var meshName = backgroundItem.getMeshName(drop.urls[imported_model].toString())
backgroundItem.hasMesh(decodeURIComponent(meshName))
}
}
}
}
@ -732,14 +737,11 @@ UM.MainWindow
for(var i in fileUrls)
{
UM.MeshFileHandler.readLocalFile(fileUrls[i])
if (i == fileUrls.length - 1)
{
var meshName = backgroundItem.getMeshName(fileUrls.toString())
backgroundItem.hasMesh(decodeURIComponent(meshName))
}
Printer.loadFile(fileUrls[i])
}
var meshName = backgroundItem.getMeshName(fileUrls[0].toString())
backgroundItem.hasMesh(decodeURIComponent(meshName))
}
}

View file

@ -26,7 +26,7 @@ Menu
return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
}
onTriggered: {
UM.MeshFileHandler.readLocalFile(modelData);
Printer.loadFile(modelData);
var meshName = backgroundItem.getMeshName(modelData.toString())
backgroundItem.hasMesh(decodeURIComponent(meshName))
}