This commit is contained in:
Jaime van Kessel 2015-09-02 14:49:53 +02:00
commit 34a31bc61a
2 changed files with 66 additions and 18 deletions

View File

@ -16,6 +16,8 @@ UM.MainWindow
//: Cura application window title //: Cura application window title
title: catalog.i18nc("@title:window","Cura"); title: catalog.i18nc("@title:window","Cura");
Item Item
{ {
id: backgroundItem; id: backgroundItem;
@ -32,7 +34,9 @@ UM.MainWindow
//: File menu //: File menu
title: catalog.i18nc("@title:menu","&File"); title: catalog.i18nc("@title:menu","&File");
MenuItem { action: actions.open; } MenuItem {
action: actions.open;
}
Menu Menu
{ {
@ -52,7 +56,10 @@ UM.MainWindow
var path = modelData.toString() var path = modelData.toString()
return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1); return (index + 1) + ". " + path.slice(path.lastIndexOf("/") + 1);
} }
onTriggered: UM.MeshFileHandler.readLocalFile(modelData); onTriggered: {
UM.MeshFileHandler.readLocalFile(modelData);
openDialog.sendMeshName(modelData.toString())
}
} }
onObjectAdded: recentFilesMenu.insertItem(index, object) onObjectAdded: recentFilesMenu.insertItem(index, object)
onObjectRemoved: recentFilesMenu.removeItem(object) onObjectRemoved: recentFilesMenu.removeItem(object)
@ -563,11 +570,19 @@ UM.MainWindow
//TODO: Support multiple file selection, workaround bug in KDE file dialog //TODO: Support multiple file selection, workaround bug in KDE file dialog
//selectMultiple: true //selectMultiple: true
signal hasMesh(string name)
function sendMeshName(path){
var fileName = path.slice(path.lastIndexOf("/") + 1)
var fileBase = fileName.slice(0, fileName.lastIndexOf("."))
openDialog.hasMesh(fileBase)
}
nameFilters: UM.MeshFileHandler.supportedReadFileTypes; nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
onAccepted: onAccepted:
{ {
UM.MeshFileHandler.readLocalFile(fileUrl) UM.MeshFileHandler.readLocalFile(fileUrl)
openDialog.sendMeshName(fileUrl.toString())
} }
} }

View File

@ -21,6 +21,29 @@ Rectangle {
property variant printDuration: PrintInformation.currentPrintTime; property variant printDuration: PrintInformation.currentPrintTime;
property real printMaterialAmount: PrintInformation.materialAmount; property real printMaterialAmount: PrintInformation.materialAmount;
function createFileName(baseName){
var splitMachineName = UM.Application.machineName.split(" ")
var abbrMachine = ''
for (var i = 0; i < splitMachineName.length; i++){
if (splitMachineName[i].search(/ultimaker/i) != -1)
abbrMachine += 'UM'
else
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] }
}
}
printJobTextfield.text = abbrMachine + '_' + baseName
}
Connections {
target: openDialog
onHasMesh: base.createFileName(name)
}
Rectangle{ Rectangle{
id: printJobRow id: printJobRow
implicitWidth: base.width; implicitWidth: base.width;
@ -44,14 +67,14 @@ Rectangle {
width: parent.width/100*55 width: parent.width/100*55
height: UM.Theme.sizes.sidebar_inputFields.height height: UM.Theme.sizes.sidebar_inputFields.height
property int unremovableSpacing: 5 property int unremovableSpacing: 5
text: "UM2" + "_" + "filename" ///TODO KOMT NOG text: ''
onEditingFinished: { onEditingFinished: {
if (printJobTextfield.text != ''){ if (printJobTextfield.text != ''){
printJobTextfield.focus = false printJobTextfield.focus = false
} }
} }
validator: RegExpValidator { validator: RegExpValidator {
regExp: /^[0-9a-zA-Z\_\-]*$/ regExp: /^[^\\ \/ \.]*$/
} }
style: TextFieldStyle{ style: TextFieldStyle{
textColor: UM.Theme.colors.setting_control_text; textColor: UM.Theme.colors.setting_control_text;
@ -130,31 +153,40 @@ Rectangle {
} }
} }
Item{ Rectangle{
id: saveRow id: saveRow
implicitWidth: base.width / 100 * 55 width: base.width
implicitHeight: saveToButton.height + (UM.Theme.sizes.default_margin.height / 2) // height + bottomMargin height: saveToButton.height + (UM.Theme.sizes.default_margin.height / 2) // height + bottomMargin
anchors.top: specsRow.bottom anchors.top: specsRow.bottom
anchors.right: parent.right anchors.left: parent.left
anchors.rightMargin: UM.Theme.sizes.default_margin.width
Button { Button {
id: saveToButton id: saveToButton
anchors.left: parent.left property int resizedWidth
x: base.width - saveToButton.resizedWidth - UM.Theme.sizes.default_margin.width - UM.Theme.sizes.save_button_save_to_button.height
tooltip: UM.OutputDeviceManager.activeDeviceDescription; tooltip: UM.OutputDeviceManager.activeDeviceDescription;
enabled: progress > 0.99 && base.activity == true enabled: progress > 0.99 && base.activity == true
width: parent.width - UM.Theme.sizes.save_button_save_to_button.height - 2
height: UM.Theme.sizes.save_button_save_to_button.height height: UM.Theme.sizes.save_button_save_to_button.height
anchors.top:parent.top
text: UM.OutputDeviceManager.activeDeviceShortDescription; text: UM.OutputDeviceManager.activeDeviceShortDescription
onClicked: UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice)
style: ButtonStyle { style: ButtonStyle {
background: Rectangle { background: Rectangle {
color: control.hovered ? UM.Theme.colors.load_save_button_hover : UM.Theme.colors.load_save_button color: control.hovered ? UM.Theme.colors.load_save_button_hover : UM.Theme.colors.load_save_button
Behavior on color { ColorAnimation { duration: 50; } } Behavior on color { ColorAnimation { duration: 50; } }
width: {
if (base.width*0.55 > actualLabel.width + (UM.Theme.sizes.default_margin.width * 2)){
saveToButton.resizedWidth = base.width*0.55
return base.width*0.55
}
else {
saveToButton.resizedWidth = actualLabel.width + (UM.Theme.sizes.default_margin.width * 2)
return actualLabel.width + (UM.Theme.sizes.default_margin.width * 2)
}
}
Label { Label {
id: actualLabel
anchors.centerIn: parent anchors.centerIn: parent
color: UM.Theme.colors.load_save_button_text color: UM.Theme.colors.load_save_button_text
font: UM.Theme.fonts.default font: UM.Theme.fonts.default
@ -163,13 +195,14 @@ Rectangle {
} }
label: Item { } label: Item { }
} }
onClicked: UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice)
} }
Button { Button {
id: deviceSelectionMenu; id: deviceSelectionMenu
tooltip: catalog.i18nc("@info:tooltip","Select the active output device"); tooltip: catalog.i18nc("@info:tooltip","Select the active output device");
anchors.top:parent.top
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: UM.Theme.sizes.default_margin.width
width: UM.Theme.sizes.save_button_save_to_button.height width: UM.Theme.sizes.save_button_save_to_button.height
height: UM.Theme.sizes.save_button_save_to_button.height height: UM.Theme.sizes.save_button_save_to_button.height
//iconSource: UM.Theme.icons[UM.OutputDeviceManager.activeDeviceIconName]; //iconSource: UM.Theme.icons[UM.OutputDeviceManager.activeDeviceIconName];