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; base.visible = true;
restart(); restart();
} }
else if(UM.MachineManager.activeMachineInstance == "") else if(Cura.MachineManager.activeMachineName == "")
{ {
addMachineDialog.firstRun = true; addMachineDialog.firstRun = true;
addMachineDialog.open(); addMachineDialog.open();

View File

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