From caae63a1d95824aaa0bd3fb35bbeb7c118a4bd7c Mon Sep 17 00:00:00 2001 From: Tamara Hogenhout Date: Fri, 15 Jan 2016 16:17:12 +0100 Subject: [PATCH] The fileBaseName can be used from both the hasMesh signal as when the file is opened using the terminal It also fixes the undo problem Contributes to #CURA-707 Contributes to #CURA-620 Contributes to #CURA-687 #591 --- resources/qml/JobSpecs.qml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index b9966cdeea..81df2bb08a 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -53,20 +53,26 @@ Rectangle { } Connections { - target: openDialog + target: backgroundItem onHasMesh: { - if(base.fileBaseName == ''){ - base.fileBaseName = name - base.createFileName() - } + base.fileBaseName = name } } onActivityChanged: { - if (activity == false){ - base.fileBaseName = '' + if (activity == true && base.fileBaseName == ''){ + //this only runs when you open a file from the terminal (or something that works the same way; for example when you drag a file on the icon in MacOS or use 'open with' on Windows) + base.fileBaseName = Printer.jobName //it gets the fileBaseName from CuraApplication.py because this saves the filebase when the file is opened using the terminal (or something alike) base.createFileName() } + if (activity == true && base.fileBaseName != ''){ + //this runs in all other cases where there is a mesh on the buildplate (activity == true). It uses the fileBaseName from the hasMesh signal + base.createFileName() + } + if (activity == false){ + //When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't set an empty string as a jobName (which is later used for saving the file) + printJobTextfield.text = '' + } } Rectangle @@ -123,7 +129,12 @@ Rectangle { property int unremovableSpacing: 5 text: '' horizontalAlignment: TextInput.AlignRight - onTextChanged: Printer.setJobName(text) + onTextChanged: { + if(text != ''){ + //this prevent that is sets an empty string as jobname + Printer.setJobName(text) + } + } onEditingFinished: { if (printJobTextfield.text != ''){ printJobTextfield.focus = false