Remove binding loops

Contributes to CL-1051
This commit is contained in:
Ian Paschal 2018-10-22 15:31:38 +02:00
parent 817899686a
commit 34abc48a1a
4 changed files with 21 additions and 24 deletions

View file

@ -39,12 +39,11 @@ Item {
Popup { Popup {
id: popup; id: popup;
background: Item { background: Item {
height: popup.height; anchors.fill: parent;
width: popup.width;
DropShadow { DropShadow {
anchors.fill: pointedRectangle; anchors.fill: pointedRectangle;
color: "#3F000000"; // 25% shadow color: UM.Theme.getColor("monitor_shadow");
radius: UM.Theme.getSize("monitor_shadow_radius").width; radius: UM.Theme.getSize("monitor_shadow_radius").width;
source: pointedRectangle; source: pointedRectangle;
transparentBorder: true; transparentBorder: true;
@ -96,7 +95,8 @@ Item {
top: parent.top; top: parent.top;
topMargin: UM.Theme.getSize("default_margin").height + 10 * screenScaleFactor; // Account for the point of the box topMargin: UM.Theme.getSize("default_margin").height + 10 * screenScaleFactor; // Account for the point of the box
} }
height: childrenRect.height + spacing * popupOptions.children.length + UM.Theme.getSize("default_margin").height; // height: childrenRect.height + spacing * popupOptions.children.length + UM.Theme.getSize("default_margin").height;
height: 200;
spacing: Math.floor(UM.Theme.getSize("default_margin").height / 2); spacing: Math.floor(UM.Theme.getSize("default_margin").height / 2);
width: parent.width; width: parent.width;

View file

@ -10,8 +10,8 @@ import UM 1.3 as UM
Item { Item {
id: root; id: root;
property var shadowRadius: 5; property var shadowRadius: UM.Theme.getSize("monitor_shadow_radius").width;
property var shadowOffset: 2; property var shadowOffset: UM.Theme.getSize("monitor_shadow_offset").width;
property var printer: null; property var printer: null;
property var collapsed: true; property var collapsed: true;
height: childrenRect.height + shadowRadius * 2; // Bubbles upward height: childrenRect.height + shadowRadius * 2; // Bubbles upward
@ -52,21 +52,18 @@ Item {
// Main card // Main card
Item { Item {
id: mainCard; id: mainCard;
// I don't know why the extra height is needed but it is in order to look proportional. height: 60 * screenScaleFactor + 2 * UM.Theme.getSize("default_margin").width;
height: childrenRect.height + 2;
width: parent.width; width: parent.width;
// Machine icon // Machine icon
Item { Item {
id: machineIcon; id: machineIcon;
anchors { anchors {
left: parent.left;
leftMargin: UM.Theme.getSize("wide_margin").width; leftMargin: UM.Theme.getSize("wide_margin").width;
margins: UM.Theme.getSize("default_margin").width; margins: UM.Theme.getSize("default_margin").width;
top: parent.top;
} }
height: 58 * screenScaleFactor; height: parent.height;
width: 58 * screenScaleFactor; width: height;
// Skeleton // Skeleton
Rectangle { Rectangle {
@ -87,6 +84,9 @@ Item {
} }
height: sourceSize.height; height: sourceSize.height;
source: { source: {
if (!printer) {
return "";
}
switch(printer.type) { switch(printer.type) {
case "Ultimaker 3": case "Ultimaker 3":
return "../svg/UM3-icon.svg"; return "../svg/UM3-icon.svg";
@ -104,20 +104,18 @@ Item {
// Printer info // Printer info
Item { Item {
id: printerInfo; id: printerInfo;
height: childrenRect.height
anchors { anchors {
left: machineIcon.right; left: machineIcon.right;
leftMargin: UM.Theme.getSize("default_margin").width;
right: collapseIcon.left; right: collapseIcon.left;
rightMargin: UM.Theme.getSize("default_margin").width;
verticalCenter: machineIcon.verticalCenter; verticalCenter: machineIcon.verticalCenter;
} }
height: childrenRect.height;
// Machine name // Machine name
Item { Item {
id: machineNameLabel; id: machineNameLabel;
height: UM.Theme.getSize("monitor_text_line").height; height: UM.Theme.getSize("monitor_text_line").height;
width: parent.width * 0.3; width: Math.round(parent.width * 0.3);
// Skeleton // Skeleton
Rectangle { Rectangle {
@ -132,7 +130,7 @@ Item {
color: UM.Theme.getColor("text"); color: UM.Theme.getColor("text");
elide: Text.ElideRight; elide: Text.ElideRight;
font: UM.Theme.getFont("default_bold"); font: UM.Theme.getFont("default_bold");
text: printer.name; text: printer ? printer.name : "";
visible: printer; visible: printer;
width: parent.width; width: parent.width;
} }
@ -146,7 +144,7 @@ Item {
topMargin: Math.round(UM.Theme.getSize("default_margin").height / 2); topMargin: Math.round(UM.Theme.getSize("default_margin").height / 2);
} }
height: UM.Theme.getSize("monitor_text_line").height; height: UM.Theme.getSize("monitor_text_line").height;
width: parent.width * 0.75; width: Math.round(parent.width * 0.75);
// Skeleton // Skeleton
Rectangle { Rectangle {
@ -214,9 +212,6 @@ Item {
Connections { Connections {
target: printerList; target: printerList;
onCurrentIndexChanged: { onCurrentIndexChanged: {
if (!model) {
return;
}
root.collapsed = printerList.currentIndex != model.index; root.collapsed = printerList.currentIndex != model.index;
} }
} }

View file

@ -57,8 +57,8 @@ Item {
right: parent.right; right: parent.right;
rightMargin: UM.Theme.getSize("wide_margin").width; rightMargin: UM.Theme.getSize("wide_margin").width;
} }
printJob: root.printer.activePrintJob; printJob: root.printer ? root.printer.activePrintJob : null;
visible: root.printer.activePrintJob; visible: printJob;
} }
} }

View file

@ -340,6 +340,7 @@
"monitor_progress_fill_inactive": [154, 154, 154, 255], "monitor_progress_fill_inactive": [154, 154, 154, 255],
"monitor_progress_fill_text": [255,255,255,255], "monitor_progress_fill_text": [255,255,255,255],
"monitor_progress_fill": [12, 169, 227, 255], "monitor_progress_fill": [12, 169, 227, 255],
"monitor_shadow": [0, 0, 0, 63],
"monitor_skeleton_fill": [245, 245, 245, 255], "monitor_skeleton_fill": [245, 245, 245, 255],
"monitor_text_inactive": [154, 154, 154, 255] "monitor_text_inactive": [154, 154, 154, 255]
}, },
@ -496,6 +497,7 @@
"monitor_text_line": [1.16, 1.16], "monitor_text_line": [1.16, 1.16],
"monitor_thick_lining": [0.16, 0.16], "monitor_thick_lining": [0.16, 0.16],
"monitor_corner_radius": [0.3, 0.3], "monitor_corner_radius": [0.3, 0.3],
"monitor_shadow_radius": [0.4, 0.4] "monitor_shadow_radius": [0.4, 0.4],
"monitor_shadow_offset": [0.15, 0.15]
} }
} }