mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -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
|
minimumHeight: maximumHeight
|
||||||
minimumWidth: maximumWidth
|
minimumWidth: maximumWidth
|
||||||
|
|
||||||
modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
|
modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal
|
||||||
|
|
||||||
property var fileUrl
|
property var fileUrl
|
||||||
|
|
||||||
function loadProjectFile(projectFile)
|
// load the entire project
|
||||||
{
|
function loadProjectFile() {
|
||||||
UM.WorkspaceFileHandler.readLocalFile(projectFile);
|
|
||||||
|
|
||||||
var meshName = backgroundItem.getMeshName(projectFile.toString());
|
// update preference
|
||||||
backgroundItem.hasMesh(decodeURIComponent(meshName));
|
if (rememberChoiceCheckBox.checked) {
|
||||||
|
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_project")
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadModelFiles(fileUrls)
|
UM.WorkspaceFileHandler.readLocalFile(base.fileUrl)
|
||||||
{
|
var meshName = backgroundItem.getMeshName(base.fileUrl.toString())
|
||||||
for (var i in fileUrls)
|
backgroundItem.hasMesh(decodeURIComponent(meshName))
|
||||||
{
|
|
||||||
CuraApplication.readLocalFile(fileUrls[i]);
|
base.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
var meshName = backgroundItem.getMeshName(fileUrls[0].toString());
|
// load the project file as separated models
|
||||||
backgroundItem.hasMesh(decodeURIComponent(meshName));
|
function loadModelFiles() {
|
||||||
|
|
||||||
|
// update preference
|
||||||
|
if (rememberChoiceCheckBox.checked) {
|
||||||
|
UM.Preferences.setValue("cura/choice_on_open_project", "open_as_model")
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged:
|
CuraApplication.readLocalFile(base.fileUrl)
|
||||||
{
|
var meshName = backgroundItem.getMeshName(base.fileUrl.toString())
|
||||||
if (visible)
|
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";
|
var rememberMyChoice = UM.Preferences.getValue("cura/choice_on_open_project") != "always_ask";
|
||||||
rememberChoiceCheckBox.checked = rememberMyChoice;
|
rememberChoiceCheckBox.checked = rememberMyChoice;
|
||||||
}
|
}
|
||||||
|
@ -90,47 +111,26 @@ UM.Dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
Item
|
Item {
|
||||||
{
|
|
||||||
id: buttonBar
|
id: buttonBar
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
||||||
Button
|
Button {
|
||||||
{
|
|
||||||
id: openAsProjectButton
|
id: openAsProjectButton
|
||||||
text: catalog.i18nc("@action:button", "Open as project");
|
text: catalog.i18nc("@action:button", "Open as project")
|
||||||
anchors.right: importModelsButton.left
|
anchors.right: importModelsButton.left
|
||||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
isDefault: true
|
isDefault: true
|
||||||
onClicked:
|
onClicked: loadProjectFile()
|
||||||
{
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Button
|
Button {
|
||||||
{
|
|
||||||
id: importModelsButton
|
id: importModelsButton
|
||||||
text: catalog.i18nc("@action:button", "Import models");
|
text: catalog.i18nc("@action:button", "Import models")
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
onClicked:
|
onClicked: loadModelFiles()
|
||||||
{
|
|
||||||
// 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]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue