Merge pull request #6456 from Ultimaker/CURA-6824

Consider user preference when opening project files from cli.
This commit is contained in:
Lipu Fei 2019-10-07 13:46:44 +02:00 committed by GitHub
commit 121315cbf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 41 deletions

View file

@ -53,7 +53,7 @@ UM.Dialog
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model")
}
CuraApplication.readLocalFile(base.fileUrl, true)
CuraApplication.readLocalFile(base.fileUrl, "open_as_model")
var meshName = backgroundItem.getMeshName(base.fileUrl.toString())
backgroundItem.hasMesh(decodeURIComponent(meshName))

View file

@ -42,7 +42,7 @@ UM.Dialog
{
for (var i in fileUrls)
{
CuraApplication.readLocalFile(fileUrls[i], true);
CuraApplication.readLocalFile(fileUrls[i], "open_as_model");
}
var meshName = backgroundItem.getMeshName(fileUrls[0].toString());

View file

@ -29,42 +29,8 @@ Menu
}
onTriggered:
{
var toShowDialog = false;
var toOpenAsProject = false;
var toOpenAsModel = false;
CuraApplication.readLocalFile(modelData);
if (CuraApplication.checkIsValidProjectFile(modelData)) {
// check preference
var choice = UM.Preferences.getValue("cura/choice_on_open_project");
if (choice == "open_as_project")
{
toOpenAsProject = true;
}else if (choice == "open_as_model"){
toOpenAsModel = true;
}else{
toShowDialog = true;
}
}
else {
toOpenAsModel = true;
}
if (toShowDialog) {
askOpenAsProjectOrModelsDialog.fileUrl = modelData;
askOpenAsProjectOrModelsDialog.show();
return;
}
// open file in the prefered way
if (toOpenAsProject)
{
UM.WorkspaceFileHandler.readLocalFile(modelData);
}
else if (toOpenAsModel)
{
CuraApplication.readLocalFile(modelData, true);
}
var meshName = backgroundItem.getMeshName(modelData.toString())
backgroundItem.hasMesh(decodeURIComponent(meshName))
}