Make the Add Printer dialog less spartan

This commit is contained in:
fieldOfView 2018-10-05 21:41:35 +02:00
parent 88c19aa11d
commit 2fb7d8a253

View file

@ -45,10 +45,46 @@ UM.Dialog
} }
signal machineAdded(string id) signal machineAdded(string id)
function getMachineName() function getMachineName()
{ {
var name = machineList.model.getItem(machineList.currentIndex) != undefined ? machineList.model.getItem(machineList.currentIndex).name : "" return machineList.model.getItem(machineList.currentIndex) != undefined ? machineList.model.getItem(machineList.currentIndex).name : "";
return name }
function getMachineMetaDataEntry(key)
{
var metadata = machineList.model.getItem(machineList.currentIndex) != undefined ? machineList.model.getItem(machineList.currentIndex).metadata : undefined;
if (metadata)
{
return metadata[key];
}
return undefined;
}
Label {
id: titleLabel
anchors {
top: parent.top
left: parent.left
topMargin: UM.Theme.getSize("default_margin")
}
text: catalog.i18nc("@title:tab", "Add a printer to Cura")
font.pointSize: 18
}
Label
{
id: captionLabel
anchors
{
left: parent.left
top: titleLabel.bottom
topMargin: UM.Theme.getSize("default_margin")
}
text: catalog.i18nc("@title:tab", "Select the printer you want to use from the list below.\n\nIf your printer is not in the list, use the \"Custom FFF Printer\" from the \"Custom\" category and match adjust the settings to match your printer in the next dialog.")
width: parent.width
wrapMode: Text.WordWrap
} }
ScrollView ScrollView
@ -57,13 +93,21 @@ UM.Dialog
anchors anchors
{ {
left: parent.left; top: captionLabel.visible ? captionLabel.bottom : parent.top;
top: parent.top; topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0;
right: parent.right; bottom: addPrinterButton.top;
bottom: machineNameRow.top;
bottomMargin: UM.Theme.getSize("default_margin").height bottomMargin: UM.Theme.getSize("default_margin").height
} }
width: Math.round(parent.width * 0.45)
frameVisible: true;
Rectangle {
parent: viewport
anchors.fill: parent
color: palette.light
}
ListView ListView
{ {
id: machineList id: machineList
@ -184,32 +228,76 @@ UM.Dialog
} }
} }
Row Column
{ {
id: machineNameRow anchors
anchors.bottom:parent.bottom
spacing: UM.Theme.getSize("default_margin").width
Label
{ {
text: catalog.i18nc("@label", "Printer Name:") top: machinesHolder.top
anchors.verticalCenter: machineName.verticalCenter left: machinesHolder.right
right: parent.right
leftMargin: UM.Theme.getSize("default_margin").width
} }
TextField spacing: UM.Theme.getSize("default_margin").height
Label
{ {
id: machineName width: parent.width
wrapMode: Text.WordWrap
text: getMachineName() text: getMachineName()
implicitWidth: UM.Theme.getSize("standard_list_input").width font.pointSize: 16
maximumLength: 40 elide: Text.ElideRight
//validator: Cura.MachineNameValidator { } //TODO: Gives a segfault in PyQt5.6. For now, we must use a signal on text changed. }
validator: RegExpValidator Grid
{
width: parent.width
columns: 2
rowSpacing: UM.Theme.getSize("default_lining").height
columnSpacing: UM.Theme.getSize("default_margin").width
verticalItemAlignment: Grid.AlignVCenter
Label
{ {
regExp: { wrapMode: Text.WordWrap
machineName.machine_name_validator.machineNameRegex text: catalog.i18nc("@label", "Manufacturer")
} }
Label
{
width: Math.floor(parent.width * 0.65)
wrapMode: Text.WordWrap
text: getMachineMetaDataEntry("manufacturer")
}
Label
{
wrapMode: Text.WordWrap
text: catalog.i18nc("@label", "Author")
}
Label
{
width: Math.floor(parent.width * 0.75)
wrapMode: Text.WordWrap
text: getMachineMetaDataEntry("author")
}
Label
{
wrapMode: Text.WordWrap
text: catalog.i18nc("@label", "Printer Name")
}
TextField
{
id: machineName
text: getMachineName()
width: Math.floor(parent.width * 0.75)
implicitWidth: UM.Theme.getSize("standard_list_input").width
maximumLength: 40
//validator: Cura.MachineNameValidator { } //TODO: Gives a segfault in PyQt5.6. For now, we must use a signal on text changed.
validator: RegExpValidator
{
regExp: {
machineName.machine_name_validator.machineNameRegex
}
}
property var machine_name_validator: Cura.MachineNameValidator { }
} }
property var machine_name_validator: Cura.MachineNameValidator { }
} }
} }