mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
Hitting enter on project loading dialog now loads the project instead of just closing the dialog - CURA-4735
This commit is contained in:
parent
ce709bf24a
commit
99c40d09e9
1 changed files with 47 additions and 47 deletions
|
@ -26,33 +26,54 @@ UM.Dialog
|
|||
minimumHeight: maximumHeight
|
||||
minimumWidth: maximumWidth
|
||||
|
||||
modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
|
||||
modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal
|
||||
|
||||
property var fileUrl
|
||||
|
||||
function loadProjectFile(projectFile)
|
||||
{
|
||||
UM.WorkspaceFileHandler.readLocalFile(projectFile);
|
||||
// load the entire project
|
||||
function loadProjectFile() {
|
||||
|
||||
var meshName = backgroundItem.getMeshName(projectFile.toString());
|
||||
backgroundItem.hasMesh(decodeURIComponent(meshName));
|
||||
// update preference
|
||||
if (rememberChoiceCheckBox.checked) {
|
||||
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_project")
|
||||
}
|
||||
|
||||
function loadModelFiles(fileUrls)
|
||||
{
|
||||
for (var i in fileUrls)
|
||||
{
|
||||
CuraApplication.readLocalFile(fileUrls[i]);
|
||||
UM.WorkspaceFileHandler.readLocalFile(base.fileUrl)
|
||||
var meshName = backgroundItem.getMeshName(base.fileUrl.toString())
|
||||
backgroundItem.hasMesh(decodeURIComponent(meshName))
|
||||
|
||||
base.hide()
|
||||
}
|
||||
|
||||
var meshName = backgroundItem.getMeshName(fileUrls[0].toString());
|
||||
backgroundItem.hasMesh(decodeURIComponent(meshName));
|
||||
// load the project file as separated models
|
||||
function loadModelFiles() {
|
||||
|
||||
// update preference
|
||||
if (rememberChoiceCheckBox.checked) {
|
||||
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model")
|
||||
}
|
||||
|
||||
onVisibleChanged:
|
||||
{
|
||||
if (visible)
|
||||
{
|
||||
CuraApplication.readLocalFile(base.fileUrl)
|
||||
var meshName = backgroundItem.getMeshName(base.fileUrl.toString())
|
||||
backgroundItem.hasMesh(decodeURIComponent(meshName))
|
||||
|
||||
base.hide()
|
||||
}
|
||||
|
||||
// override UM.Dialog accept
|
||||
function accept () {
|
||||
var openAsPreference = UM.Preferences.getValue("cura/choice_on_open_project")
|
||||
|
||||
// when hitting 'enter', we always open as project unless open_as_model was explicitly stored as preference
|
||||
if (openAsPreference == "open_as_model") {
|
||||
loadModelFiles()
|
||||
} else {
|
||||
loadProjectFile()
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
var rememberMyChoice = UM.Preferences.getValue("cura/choice_on_open_project") != "always_ask";
|
||||
rememberChoiceCheckBox.checked = rememberMyChoice;
|
||||
}
|
||||
|
@ -90,47 +111,26 @@ UM.Dialog
|
|||
}
|
||||
|
||||
// Buttons
|
||||
Item
|
||||
{
|
||||
Item {
|
||||
id: buttonBar
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
height: childrenRect.height
|
||||
|
||||
Button
|
||||
{
|
||||
Button {
|
||||
id: openAsProjectButton
|
||||
text: catalog.i18nc("@action:button", "Open as project");
|
||||
text: catalog.i18nc("@action:button", "Open as project")
|
||||
anchors.right: importModelsButton.left
|
||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||
isDefault: true
|
||||
onClicked:
|
||||
{
|
||||
// update preference
|
||||
if (rememberChoiceCheckBox.checked)
|
||||
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_project");
|
||||
|
||||
// load this file as project
|
||||
base.hide();
|
||||
loadProjectFile(base.fileUrl);
|
||||
}
|
||||
onClicked: loadProjectFile()
|
||||
}
|
||||
|
||||
Button
|
||||
{
|
||||
Button {
|
||||
id: importModelsButton
|
||||
text: catalog.i18nc("@action:button", "Import models");
|
||||
text: catalog.i18nc("@action:button", "Import models")
|
||||
anchors.right: parent.right
|
||||
onClicked:
|
||||
{
|
||||
// update preference
|
||||
if (rememberChoiceCheckBox.checked)
|
||||
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model");
|
||||
|
||||
// load models from this project file
|
||||
base.hide();
|
||||
loadModelFiles([base.fileUrl]);
|
||||
}
|
||||
onClicked: loadModelFiles()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue