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
This commit is contained in:
Tamara Hogenhout 2016-01-15 16:17:12 +01:00
parent 8af00b4195
commit caae63a1d9

View file

@ -53,20 +53,26 @@ Rectangle {
} }
Connections { Connections {
target: openDialog target: backgroundItem
onHasMesh: { onHasMesh: {
if(base.fileBaseName == ''){
base.fileBaseName = name base.fileBaseName = name
base.createFileName()
}
} }
} }
onActivityChanged: { onActivityChanged: {
if (activity == false){ if (activity == true && base.fileBaseName == ''){
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() 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 Rectangle
@ -123,7 +129,12 @@ Rectangle {
property int unremovableSpacing: 5 property int unremovableSpacing: 5
text: '' text: ''
horizontalAlignment: TextInput.AlignRight horizontalAlignment: TextInput.AlignRight
onTextChanged: Printer.setJobName(text) onTextChanged: {
if(text != ''){
//this prevent that is sets an empty string as jobname
Printer.setJobName(text)
}
}
onEditingFinished: { onEditingFinished: {
if (printJobTextfield.text != ''){ if (printJobTextfield.text != ''){
printJobTextfield.focus = false printJobTextfield.focus = false