mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Merge branch 'feature_CURA-3495_open_menu' of github.com:Ultimaker/Cura
This commit is contained in:
commit
dafeab4e8a
1 changed files with 72 additions and 32 deletions
|
@ -755,17 +755,40 @@ UM.MainWindow
|
|||
|
||||
// look for valid project files
|
||||
var projectFileUrlList = [];
|
||||
var hasGcode = false;
|
||||
for (var i in fileUrls)
|
||||
{
|
||||
if (CuraApplication.checkIsValidProjectFile(fileUrls[i]))
|
||||
var endsWithG = /\.g$/;
|
||||
var endsWithGcode = /\.gcode$/;
|
||||
if (endsWithG.test(fileUrls[i]) || endsWithGcode.test(fileUrls[i])) {
|
||||
hasGcode = true;
|
||||
continue;
|
||||
}
|
||||
else if (CuraApplication.checkIsValidProjectFile(fileUrls[i])) {
|
||||
projectFileUrlList.push(fileUrls[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// we only allow opening one project file
|
||||
var selectedMultipleFiles = fileUrls.length > 1;
|
||||
// show a warning if selected multiple files together with Gcode
|
||||
var hasProjectFile = projectFileUrlList.length > 0;
|
||||
var selectedMultipleWithProjectFile = hasProjectFile && selectedMultipleFiles;
|
||||
if (selectedMultipleWithProjectFile)
|
||||
var selectedMultipleFiles = fileUrls.length > 1;
|
||||
if (selectedMultipleFiles && hasGcode) {
|
||||
infoMultipleFilesWithGcodeDialog.selectedMultipleFiles = selectedMultipleFiles;
|
||||
infoMultipleFilesWithGcodeDialog.hasProjectFile = hasProjectFile;
|
||||
infoMultipleFilesWithGcodeDialog.fileUrls = fileUrls;
|
||||
infoMultipleFilesWithGcodeDialog.projectFileUrlList = projectFileUrlList;
|
||||
infoMultipleFilesWithGcodeDialog.open();
|
||||
}
|
||||
else {
|
||||
handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrls, projectFileUrlList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrls, projectFileUrlList)
|
||||
{
|
||||
// we only allow opening one project file
|
||||
if (selectedMultipleFiles && hasProjectFile)
|
||||
{
|
||||
openFilesIncludingProjectsDialog.fileUrls = fileUrls;
|
||||
openFilesIncludingProjectsDialog.show();
|
||||
|
@ -794,6 +817,23 @@ UM.MainWindow
|
|||
openFilesIncludingProjectsDialog.loadModelFiles(fileUrls);
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: infoMultipleFilesWithGcodeDialog
|
||||
title: catalog.i18nc("@title:window", "Open File(s)")
|
||||
icon: StandardIcon.Information
|
||||
standardButtons: StandardButton.Ok
|
||||
text: catalog.i18nc("@text:window", "We have found one or more G-Code files within the files you have selected. You can only open one G-Code file at a time. If you want to open a G-Code file, please just select only one.")
|
||||
|
||||
property var selectedMultipleFiles
|
||||
property var hasProjectFile
|
||||
property var fileUrls
|
||||
property var projectFileUrlList
|
||||
|
||||
onAccepted:
|
||||
{
|
||||
handleOpenFiles(selectedMultipleFiles, hasProjectFile, fileUrls, projectFileUrlList);
|
||||
}
|
||||
}
|
||||
|
||||
Connections
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue