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)
function getMachineName()
{
var name = machineList.model.getItem(machineList.currentIndex) != undefined ? machineList.model.getItem(machineList.currentIndex).name : ""
return name
return machineList.model.getItem(machineList.currentIndex) != undefined ? machineList.model.getItem(machineList.currentIndex).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
@ -57,13 +93,21 @@ UM.Dialog
anchors
{
left: parent.left;
top: parent.top;
right: parent.right;
bottom: machineNameRow.top;
top: captionLabel.visible ? captionLabel.bottom : parent.top;
topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0;
bottom: addPrinterButton.top;
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
{
id: machineList
@ -184,32 +228,76 @@ UM.Dialog
}
}
Row
Column
{
id: machineNameRow
anchors.bottom:parent.bottom
spacing: UM.Theme.getSize("default_margin").width
Label
anchors
{
text: catalog.i18nc("@label", "Printer Name:")
anchors.verticalCenter: machineName.verticalCenter
top: machinesHolder.top
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()
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
font.pointSize: 16
elide: Text.ElideRight
}
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: {
machineName.machine_name_validator.machineNameRegex
}
wrapMode: Text.WordWrap
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 { }
}
}