Browse Source

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
Tamara Hogenhout 9 years ago
parent
commit
caae63a1d9
1 changed files with 19 additions and 8 deletions
  1. 19 8
      resources/qml/JobSpecs.qml

+ 19 - 8
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