Fix creating print job name

Also fixed up the code style of that bit.

Perhaps this should've been done in Python, but that is for later.

Contributes to issue CURA-1278.
This commit is contained in:
Ghostkeeper 2016-05-24 15:04:08 +02:00
parent 332321b991
commit c80455c6bc
No known key found for this signature in database
GPG Key ID: 701948C5954A7385
2 changed files with 30 additions and 22 deletions

View File

@ -813,7 +813,7 @@ UM.MainWindow
base.visible = true;
restart();
}
else if(UM.MachineManager.activeMachineInstance == "")
else if(Cura.MachineManager.activeMachineName == "")
{
addMachineDialog.firstRun = true;
addMachineDialog.open();

View File

@ -7,15 +7,16 @@ import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import UM 1.1 as UM
import Cura 1.0 as Cura
Rectangle {
id: base;
property bool activity: Printer.getPlatformActivity;
property string fileBaseName
property variant activeMachineInstance: UM.MachineManager.activeMachineInstance
property variant activeMachineName: Cura.MachineManager.activeMachineName
onActiveMachineInstanceChanged:
onActiveMachineNameChanged:
{
base.createFileName()
}
@ -28,27 +29,34 @@ Rectangle {
height: childrenRect.height
color: "transparent"
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){
abbrMachine += 'UM'
}
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]
}
function createFileName()
{
var splitMachineName = Cura.MachineManager.activeMachineName.split(" ");
var abbrMachine = '';
for (var i = 0; i < splitMachineName.length; i++)
{
if (splitMachineName[i].search(/ultimaker/i) != -1)
{
abbrMachine += 'UM';
}
else
{
if (splitMachineName[i].charAt(0).search(/[0-9]/g) == -1)
{
abbrMachine += splitMachineName[i].charAt(0);
}
}
printJobTextfield.text = abbrMachine + '_' + base.fileBaseName
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];
}
}
}
printJobTextfield.text = abbrMachine + '_' + base.fileBaseName;
}
Connections {