From a83937183256bde5f68562369d6120dc512846f1 Mon Sep 17 00:00:00 2001 From: Tamara Hogenhout Date: Wed, 2 Sep 2015 17:59:20 +0200 Subject: [PATCH] 15.10 rework of the automatic filename functionality Contributes to: issue CURA-60 --- resources/qml/SaveButton.qml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/resources/qml/SaveButton.qml b/resources/qml/SaveButton.qml index 5154af2b74..36404cd991 100644 --- a/resources/qml/SaveButton.qml +++ b/resources/qml/SaveButton.qml @@ -15,33 +15,48 @@ Rectangle { property bool activity: Printer.getPlatformActivity; Behavior on progress { NumberAnimation { duration: 250; } } property int totalHeight: childrenRect.height + property string fileBaseName + property variant activeMachineInstance: UM.MachineManager.activeMachineInstance + + onActiveMachineInstanceChanged: + { + base.createFileName() + } UM.I18nCatalog { id: catalog; name:"cura"} property variant printDuration: PrintInformation.currentPrintTime; property real printMaterialAmount: PrintInformation.materialAmount; - function createFileName(baseName){ - var splitMachineName = UM.Application.machineName.split(" ") + function createFileName(){ + var splitMachineName = UM.MachineManager.activeMachineInstance.split(" ") var abbrMachine = '' for (var i = 0; i < splitMachineName.length; i++){ - if (splitMachineName[i].search(/ultimaker/i) != -1) + if (splitMachineName[i].search(/ultimaker/i) != -1){ abbrMachine += 'UM' - else - abbrMachine += splitMachineName[i].charAt(0) - + } + else{ + if (splitMachineName[i].charAt(0).search(/[0-9]/g) == -1) + abbrMachine += splitMachineName[i].charAt(0) + } var regExpAdditives = /[0-9\+]/g; var resultAdditives = splitMachineName[i].match(regExpAdditives); if (resultAdditives != null){ - for (var j = 0; j < resultAdditives.length; j++){ abbrMachine += resultAdditives[j] } + for (var j = 0; j < resultAdditives.length; j++){ + abbrMachine += resultAdditives[j] + + } } } - printJobTextfield.text = abbrMachine + '_' + baseName + printJobTextfield.text = abbrMachine + '_' + base.fileBaseName } Connections { target: openDialog - onHasMesh: base.createFileName(name) + onHasMesh: { + base.fileBaseName = name + base.createFileName() + } } Rectangle{