mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-03 17:24:21 +08:00
Merge pull request #4709 from fieldOfView/fix_add_printer_layout
Add Printer dialog codestyle and readability
This commit is contained in:
commit
b6e35df030
@ -25,7 +25,8 @@ UM.Dialog
|
|||||||
width: minimumWidth
|
width: minimumWidth
|
||||||
height: minimumHeight
|
height: minimumHeight
|
||||||
|
|
||||||
flags: {
|
flags:
|
||||||
|
{
|
||||||
var window_flags = Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint;
|
var window_flags = Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint;
|
||||||
if (Cura.MachineManager.activeDefinitionId !== "") //Disallow closing the window if we have no active printer yet. You MUST add a printer.
|
if (Cura.MachineManager.activeDefinitionId !== "") //Disallow closing the window if we have no active printer yet. You MUST add a printer.
|
||||||
{
|
{
|
||||||
@ -48,22 +49,28 @@ UM.Dialog
|
|||||||
|
|
||||||
function getMachineName()
|
function getMachineName()
|
||||||
{
|
{
|
||||||
return machineList.model.getItem(machineList.currentIndex) != undefined ? machineList.model.getItem(machineList.currentIndex).name : "";
|
if (machineList.model.getItem(machineList.currentIndex) != undefined)
|
||||||
|
{
|
||||||
|
return machineList.model.getItem(machineList.currentIndex).name;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMachineMetaDataEntry(key)
|
function getMachineMetaDataEntry(key)
|
||||||
{
|
{
|
||||||
var metadata = machineList.model.getItem(machineList.currentIndex) != undefined ? machineList.model.getItem(machineList.currentIndex).metadata : undefined;
|
if (machineList.model.getItem(machineList.currentIndex) != undefined)
|
||||||
if (metadata)
|
|
||||||
{
|
{
|
||||||
return metadata[key];
|
return machineList.model.getItem(machineList.currentIndex).metadata[key];
|
||||||
}
|
}
|
||||||
return undefined;
|
return "";
|
||||||
}
|
}
|
||||||
Label {
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
id: titleLabel
|
id: titleLabel
|
||||||
|
|
||||||
anchors {
|
anchors
|
||||||
|
{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: parent.left
|
left: parent.left
|
||||||
topMargin: UM.Theme.getSize("default_margin")
|
topMargin: UM.Theme.getSize("default_margin")
|
||||||
@ -102,7 +109,8 @@ UM.Dialog
|
|||||||
width: Math.round(parent.width * 0.45)
|
width: Math.round(parent.width * 0.45)
|
||||||
|
|
||||||
frameVisible: true;
|
frameVisible: true;
|
||||||
Rectangle {
|
Rectangle
|
||||||
|
{
|
||||||
parent: viewport
|
parent: viewport
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: palette.light
|
color: palette.light
|
||||||
@ -159,11 +167,14 @@ UM.Dialog
|
|||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
base.activeCategory = section;
|
base.activeCategory = section;
|
||||||
if (machineList.model.getItem(machineList.currentIndex).section != section) {
|
if (machineList.model.getItem(machineList.currentIndex).section != section)
|
||||||
|
{
|
||||||
// Find the first machine from this section
|
// Find the first machine from this section
|
||||||
for(var i = 0; i < machineList.model.rowCount(); i++) {
|
for(var i = 0; i < machineList.model.rowCount(); i++)
|
||||||
|
{
|
||||||
var item = machineList.model.getItem(i);
|
var item = machineList.model.getItem(i);
|
||||||
if (item.section == section) {
|
if (item.section == section)
|
||||||
|
{
|
||||||
machineList.currentIndex = i;
|
machineList.currentIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user