Round coordinates

This would have worked out of the box if this plug-in actually used the theme rather than hard-coding its sizes here. However that is too big of a change for me to make in 5 minutes, so it'll have to wait. Also fixed some missing screen scale factors.

Done as a 5 minute fix to try to amend #7125.
This commit is contained in:
Ghostkeeper 2020-02-25 15:00:41 +01:00
parent b4a646c191
commit 3dbbd17e32
No known key found for this signature in database
GPG key ID: 37E2020986774393

View file

@ -30,22 +30,22 @@ Item
borderColor: printJob && printJob.configurationChanges.length !== 0 ? UM.Theme.getColor("warning") : UM.Theme.getColor("monitor_card_border") borderColor: printJob && printJob.configurationChanges.length !== 0 ? UM.Theme.getColor("warning") : UM.Theme.getColor("monitor_card_border")
headerItem: Row headerItem: Row
{ {
height: 48 * screenScaleFactor // TODO: Theme! height: Math.round(48 * screenScaleFactor) // TODO: Theme!
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 24 * screenScaleFactor // TODO: Theme! anchors.leftMargin: Math.round(24 * screenScaleFactor) // TODO: Theme!
spacing: 18 * screenScaleFactor // TODO: Theme! spacing: Math.round(18 * screenScaleFactor) // TODO: Theme!
MonitorPrintJobPreview MonitorPrintJobPreview
{ {
printJob: base.printJob printJob: base.printJob
size: 32 * screenScaleFactor // TODO: Theme! size: Math.round(32 * screenScaleFactor) // TODO: Theme!
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
Item Item
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: 18 * screenScaleFactor // TODO: Theme! height: Math.round(18 * screenScaleFactor) // TODO: Theme!
width: UM.Theme.getSize("monitor_column").width width: UM.Theme.getSize("monitor_column").width
Rectangle Rectangle
{ {
@ -74,7 +74,7 @@ Item
Item Item
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: 18 * screenScaleFactor // TODO: Theme! height: Math.round(18 * screenScaleFactor) // TODO: Theme!
width: UM.Theme.getSize("monitor_column").width width: UM.Theme.getSize("monitor_column").width
Rectangle Rectangle
@ -95,7 +95,7 @@ Item
visible: printJob visible: printJob
// FIXED-LINE-HEIGHT: // FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme! height: Math.round(18 * screenScaleFactor) // TODO: Theme!
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
@ -104,13 +104,13 @@ Item
Item Item
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: 18 * screenScaleFactor // TODO: This should be childrenRect.height but QML throws warnings height: Math.round(18 * screenScaleFactor) // TODO: This should be childrenRect.height but QML throws warnings
width: childrenRect.width width: childrenRect.width
Rectangle Rectangle
{ {
color: UM.Theme.getColor("monitor_skeleton_loading") color: UM.Theme.getColor("monitor_skeleton_loading")
width: 72 * screenScaleFactor // TODO: Theme! width: Math.round(72 * screenScaleFactor) // TODO: Theme!
height: parent.height height: parent.height
visible: !printJob visible: !printJob
radius: 2 * screenScaleFactor // TODO: Theme! radius: 2 * screenScaleFactor // TODO: Theme!
@ -124,21 +124,22 @@ Item
elide: Text.ElideRight elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular font: UM.Theme.getFont("medium") // 14pt, regular
text: { text: {
if (printJob !== null) { if (printJob !== null)
{
if (printJob.assignedPrinter == null) if (printJob.assignedPrinter == null)
{ {
if (printJob.state == "error") if (printJob.state == "error")
{ {
return catalog.i18nc("@label", "Unavailable printer") return catalog.i18nc("@label", "Unavailable printer");
} }
return catalog.i18nc("@label", "First available") return catalog.i18nc("@label", "First available");
} }
return printJob.assignedPrinter.name return printJob.assignedPrinter.name;
} }
return "" return "";
} }
visible: printJob visible: printJob
width: 120 * screenScaleFactor // TODO: Theme! width: Math.round(120 * screenScaleFactor) // TODO: Theme!
// FIXED-LINE-HEIGHT: // FIXED-LINE-HEIGHT:
height: parent.height height: parent.height
@ -152,11 +153,11 @@ Item
anchors anchors
{ {
left: printerAssignmentLabel.right; left: printerAssignmentLabel.right;
leftMargin: 12 // TODO: Theme! leftMargin: Math.round(12 * screenScaleFactor) // TODO: Theme!
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
height: childrenRect.height height: childrenRect.height
spacing: 6 // TODO: Theme! spacing: Math.round(6 * screenScaleFactor) // TODO: Theme!
visible: printJob visible: printJob
MonitorPrinterPill MonitorPrinterPill
@ -171,10 +172,10 @@ Item
anchors anchors
{ {
left: parent.left left: parent.left
leftMargin: 74 * screenScaleFactor // TODO: Theme! leftMargin: Math.round(74 * screenScaleFactor) // TODO: Theme!
} }
height: 108 * screenScaleFactor // TODO: Theme! height: Math.round(108 * screenScaleFactor) // TODO: Theme!
spacing: 18 * screenScaleFactor // TODO: Theme! spacing: Math.round(18 * screenScaleFactor) // TODO: Theme!
MonitorPrinterConfiguration MonitorPrinterConfiguration
{ {
@ -182,7 +183,7 @@ Item
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
buildplate: catalog.i18nc("@label", "Glass") buildplate: catalog.i18nc("@label", "Glass")
configurations: base.printJob.configuration.extruderConfigurations configurations: base.printJob.configuration.extruderConfigurations
height: 72 * screenScaleFactor // TODO: Theme! height: Math.round(72 * screenScaleFactor) // TODO: Theme!
} }
Label { Label {
@ -193,7 +194,7 @@ Item
anchors.top: printerConfiguration.top anchors.top: printerConfiguration.top
// FIXED-LINE-HEIGHT: // FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme! height: Math.round(18 * screenScaleFactor) // TODO: Theme!
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
@ -206,21 +207,22 @@ Item
anchors anchors
{ {
right: parent.right right: parent.right
rightMargin: 8 * screenScaleFactor // TODO: Theme! rightMargin: Math.round(8 * screenScaleFactor) // TODO: Theme!
top: parent.top top: parent.top
topMargin: 8 * screenScaleFactor // TODO: Theme! topMargin: Math.round(8 * screenScaleFactor) // TODO: Theme!
} }
width: 32 * screenScaleFactor // TODO: Theme! width: Math.round(32 * screenScaleFactor) // TODO: Theme!
height: 32 * screenScaleFactor // TODO: Theme! height: Math.round(32 * screenScaleFactor) // TODO: Theme!
enabled: OutputDevice.supportsPrintJobActions enabled: OutputDevice.supportsPrintJobActions
onClicked: enabled ? contextMenu.switchPopupState() : {} onClicked: enabled ? contextMenu.switchPopupState() : {}
visible: visible:
{ {
if (!printJob) { if (!printJob)
return false {
return false;
} }
var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"] var states = ["queued", "error", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"];
return states.indexOf(printJob.state) !== -1 return states.indexOf(printJob.state) !== -1;
} }
} }