mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 07:35:59 +08:00
Also asks when opening a recent project file
CURA-3495
This commit is contained in:
parent
9e5513ade6
commit
2d48809214
@ -4,7 +4,7 @@
|
|||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
|
|
||||||
import UM 1.2 as UM
|
import UM 1.3 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.0 as Cura
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
@ -25,8 +25,38 @@ Menu
|
|||||||
var path = modelData.toString()
|
var path = modelData.toString()
|
||||||
return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
|
return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
|
||||||
}
|
}
|
||||||
onTriggered: {
|
onTriggered:
|
||||||
Printer.readLocalFile(modelData);
|
{
|
||||||
|
var toShowDialog = false;
|
||||||
|
var toOpenAsProject = false;
|
||||||
|
var toOpenAsModel = false;
|
||||||
|
|
||||||
|
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)
|
||||||
|
Printer.readLocalFile(modelData);
|
||||||
var meshName = backgroundItem.getMeshName(modelData.toString())
|
var meshName = backgroundItem.getMeshName(modelData.toString())
|
||||||
backgroundItem.hasMesh(decodeURIComponent(meshName))
|
backgroundItem.hasMesh(decodeURIComponent(meshName))
|
||||||
}
|
}
|
||||||
@ -34,4 +64,9 @@ Menu
|
|||||||
onObjectAdded: menu.insertItem(index, object)
|
onObjectAdded: menu.insertItem(index, object)
|
||||||
onObjectRemoved: menu.removeItem(object)
|
onObjectRemoved: menu.removeItem(object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cura.AskOpenAsProjectOrModelsDialog
|
||||||
|
{
|
||||||
|
id: askOpenAsProjectOrModelsDialog
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user