mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 19:49:00 +08:00
Add msg dialog for ignoring gcode in multiple file selection
CURA-3495
This commit is contained in:
parent
ef0a502dcf
commit
7ad5a64b91
@ -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…
x
Reference in New Issue
Block a user