mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-03 12:03:57 -06:00
Remove almost duplicate file
CURA-11800
This commit is contained in:
parent
a95418f072
commit
b3d3c4d00a
3 changed files with 33 additions and 135 deletions
|
@ -702,32 +702,23 @@ UM.MainWindow
|
||||||
if (hasProjectFile)
|
if (hasProjectFile)
|
||||||
{
|
{
|
||||||
var projectFile = projectFileUrlList[0]
|
var projectFile = projectFileUrlList[0]
|
||||||
var is_ucp = CuraApplication.isProjectUcp(projectFile);
|
// check preference
|
||||||
if (is_ucp)
|
var choice = UM.Preferences.getValue("cura/choice_on_open_project");
|
||||||
|
if (choice == "open_as_project")
|
||||||
{
|
{
|
||||||
askOpenAsProjectOrUcpOrImportModelsDialog.fileUrl = projectFile;
|
openFilesIncludingProjectsDialog.loadProjectFile(projectFile);
|
||||||
askOpenAsProjectOrUcpOrImportModelsDialog.addToRecent = true;
|
|
||||||
askOpenAsProjectOrUcpOrImportModelsDialog.show();
|
|
||||||
}
|
}
|
||||||
else
|
else if (choice == "open_as_model")
|
||||||
{
|
{
|
||||||
// check preference
|
openFilesIncludingProjectsDialog.loadModelFiles([projectFile].slice());
|
||||||
var choice = UM.Preferences.getValue("cura/choice_on_open_project");
|
}
|
||||||
if (choice == "open_as_project")
|
else // always ask
|
||||||
{
|
{
|
||||||
openFilesIncludingProjectsDialog.loadProjectFile(projectFile);
|
// ask whether to open as project or as models
|
||||||
}
|
askOpenAsProjectOrModelsDialog.is_ucp = CuraApplication.isProjectUcp(projectFile);
|
||||||
else if (choice == "open_as_model")
|
askOpenAsProjectOrModelsDialog.fileUrl = projectFile;
|
||||||
{
|
askOpenAsProjectOrModelsDialog.addToRecent = true;
|
||||||
openFilesIncludingProjectsDialog.loadModelFiles([projectFile].slice());
|
askOpenAsProjectOrModelsDialog.show();
|
||||||
}
|
|
||||||
else // always ask
|
|
||||||
{
|
|
||||||
// ask whether to open as project or as models
|
|
||||||
askOpenAsProjectOrModelsDialog.fileUrl = projectFile;
|
|
||||||
askOpenAsProjectOrModelsDialog.addToRecent = true;
|
|
||||||
askOpenAsProjectOrModelsDialog.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -778,30 +769,15 @@ UM.MainWindow
|
||||||
id: askOpenAsProjectOrModelsDialog
|
id: askOpenAsProjectOrModelsDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
AskOpenAsProjectOrUcpOrImportModel
|
|
||||||
{
|
|
||||||
id: askOpenAsProjectOrUcpOrImportModelsDialog
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: CuraApplication
|
target: CuraApplication
|
||||||
function onOpenProjectFile(project_file, add_to_recent_files)
|
function onOpenProjectFile(project_file, add_to_recent_files)
|
||||||
{
|
{
|
||||||
var is_ucp = CuraApplication.isProjectUcp(project_file);
|
askOpenAsProjectOrModelsDialog.is_ucp = CuraApplication.isProjectUcp(project_file);
|
||||||
if (is_ucp)
|
askOpenAsProjectOrModelsDialog.fileUrl = project_file;
|
||||||
{
|
askOpenAsProjectOrModelsDialog.addToRecent = add_to_recent_files;
|
||||||
|
askOpenAsProjectOrModelsDialog.show();
|
||||||
askOpenAsProjectOrUcpOrImportModelsDialog.fileUrl = project_file;
|
|
||||||
askOpenAsProjectOrUcpOrImportModelsDialog.addToRecent = add_to_recent_files;
|
|
||||||
askOpenAsProjectOrUcpOrImportModelsDialog.show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
askOpenAsProjectOrModelsDialog.fileUrl = project_file;
|
|
||||||
askOpenAsProjectOrModelsDialog.addToRecent = add_to_recent_files;
|
|
||||||
askOpenAsProjectOrModelsDialog.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ UM.Dialog
|
||||||
// This dialog asks the user whether he/she wants to open a project file as a project or import models.
|
// This dialog asks the user whether he/she wants to open a project file as a project or import models.
|
||||||
id: base
|
id: base
|
||||||
|
|
||||||
title: catalog.i18nc("@title:window", "Open project file")
|
title: base.is_ucp
|
||||||
|
? catalog.i18nc("@title:window Don't translate 'Universal Cura Project'", "Open Universal Cura Project (UCP) file")
|
||||||
|
: catalog.i18nc("@title:window", "Open project file")
|
||||||
width: UM.Theme.getSize("small_popup_dialog").width
|
width: UM.Theme.getSize("small_popup_dialog").width
|
||||||
height: UM.Theme.getSize("small_popup_dialog").height
|
height: UM.Theme.getSize("small_popup_dialog").height
|
||||||
backgroundColor: UM.Theme.getColor("main_background")
|
backgroundColor: UM.Theme.getColor("main_background")
|
||||||
|
@ -28,6 +30,7 @@ UM.Dialog
|
||||||
|
|
||||||
property var fileUrl
|
property var fileUrl
|
||||||
property var addToRecent: true //Whether to add this file to the recent files list after reading it.
|
property var addToRecent: true //Whether to add this file to the recent files list after reading it.
|
||||||
|
property bool is_ucp: false
|
||||||
|
|
||||||
// load the entire project
|
// load the entire project
|
||||||
function loadProjectFile() {
|
function loadProjectFile() {
|
||||||
|
@ -81,7 +84,9 @@ UM.Dialog
|
||||||
{
|
{
|
||||||
id: questionText
|
id: questionText
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: catalog.i18nc("@text:window", "This is a Cura project file. Would you like to open it as a project or import the models from it?")
|
text: base.is_ucp
|
||||||
|
? catalog.i18nc("@text:window", "This is a Cura Universal project file. Would you like to open it as a Cura project or Cura Universal Project or import the models from it?")
|
||||||
|
: catalog.i18nc("@text:window", "This is a Cura project file. Would you like to open it as a project or import the models from it?")
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,10 +105,18 @@ UM.Dialog
|
||||||
|
|
||||||
rightButtons:
|
rightButtons:
|
||||||
[
|
[
|
||||||
|
Cura.PrimaryButton
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:button", "Open as UCP")
|
||||||
|
iconSource: UM.Theme.getIcon("CuraShareIcon")
|
||||||
|
onClicked: loadProjectFile()
|
||||||
|
visible: base.is_ucp
|
||||||
|
},
|
||||||
Cura.PrimaryButton
|
Cura.PrimaryButton
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:button", "Open as project")
|
text: catalog.i18nc("@action:button", "Open as project")
|
||||||
onClicked: loadProjectFile()
|
onClicked: loadProjectFile()
|
||||||
|
visible: !base.is_ucp
|
||||||
},
|
},
|
||||||
Cura.SecondaryButton
|
Cura.SecondaryButton
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
// Copyright (c) 2022 Ultimaker B.V.
|
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
|
||||||
|
|
||||||
import QtQuick 2.2
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
import QtQuick.Layouts 1.1
|
|
||||||
|
|
||||||
import UM 1.5 as UM
|
|
||||||
import Cura 1.0 as Cura
|
|
||||||
|
|
||||||
|
|
||||||
UM.Dialog
|
|
||||||
{
|
|
||||||
// This dialog asks the user whether he/she wants to open a project file as a project or import models.
|
|
||||||
id: base
|
|
||||||
|
|
||||||
title: catalog.i18nc("@title:window Don't translate 'Universal Cura Project'", "Open Universal Cura Project (UCP) file")
|
|
||||||
width: UM.Theme.getSize("small_popup_dialog").width
|
|
||||||
height: UM.Theme.getSize("small_popup_dialog").height
|
|
||||||
backgroundColor: UM.Theme.getColor("main_background")
|
|
||||||
|
|
||||||
maximumHeight: height
|
|
||||||
maximumWidth: width
|
|
||||||
minimumHeight: maximumHeight
|
|
||||||
minimumWidth: maximumWidth
|
|
||||||
|
|
||||||
modality: Qt.WindowModal
|
|
||||||
|
|
||||||
property var fileUrl
|
|
||||||
property var addToRecent: true //Whether to add this file to the recent files list after reading it.
|
|
||||||
|
|
||||||
|
|
||||||
// load the project file as separated models
|
|
||||||
function loadModelFiles() {
|
|
||||||
CuraApplication.readLocalFile(base.fileUrl, "open_as_model", base.addToRecent)
|
|
||||||
|
|
||||||
base.hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
// load the project file as Universal cura project
|
|
||||||
function loadUcpFiles() {
|
|
||||||
CuraApplication.readLocalUcpFile(base.fileUrl, base.addToRecent)
|
|
||||||
|
|
||||||
base.hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
// override UM.Dialog accept
|
|
||||||
function accept () {
|
|
||||||
|
|
||||||
// when hitting 'enter', we always open as project unless open_as_model was explicitly stored as preference
|
|
||||||
if (openAsPreference == "open_as_model") {
|
|
||||||
loadModelFiles()
|
|
||||||
} else{
|
|
||||||
loadUcpFiles()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column
|
|
||||||
{
|
|
||||||
anchors.fill: parent
|
|
||||||
spacing: UM.Theme.getSize("default_margin").height
|
|
||||||
|
|
||||||
UM.Label
|
|
||||||
{
|
|
||||||
id: questionText
|
|
||||||
width: parent.width
|
|
||||||
text: catalog.i18nc("@text:window", "This is a Cura Universal project file. Would you like to open it as a Cura project or Cura Universal Project or import the models from it?")
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onAccepted: loadUcpFile()
|
|
||||||
onRejected: loadModelFiles()
|
|
||||||
|
|
||||||
buttonSpacing: UM.Theme.getSize("thin_margin").width
|
|
||||||
|
|
||||||
rightButtons:
|
|
||||||
[
|
|
||||||
Cura.PrimaryButton
|
|
||||||
{
|
|
||||||
text: catalog.i18nc("@action:button", "Open as UCP")
|
|
||||||
iconSource: UM.Theme.getIcon("CuraShareIcon")
|
|
||||||
onClicked: loadUcpFiles()
|
|
||||||
},
|
|
||||||
Cura.SecondaryButton
|
|
||||||
{
|
|
||||||
text: catalog.i18nc("@action:button", "Import models")
|
|
||||||
onClicked: loadModelFiles()
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue