PrinterInfoBlock.qml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.3
  4. import QtQuick.Dialogs 1.1
  5. import QtQuick.Controls 2.0
  6. import QtQuick.Controls.Styles 1.3
  7. import QtGraphicalEffects 1.0
  8. import QtQuick.Controls 1.4 as LegacyControls
  9. import UM 1.3 as UM
  10. // Includes printer type pill and extuder configurations
  11. Item {
  12. id: root;
  13. property var printer: null;
  14. property var printJob: null;
  15. width: parent.width;
  16. height: childrenRect.height;
  17. // Printer family pills
  18. Row {
  19. id: printerFamilyPills;
  20. anchors {
  21. left: parent.left;
  22. right: parent.right;
  23. }
  24. height: childrenRect.height;
  25. spacing: Math.round(0.5 * UM.Theme.getSize("default_margin").width);
  26. width: parent.width;
  27. Repeater {
  28. id: compatiblePills;
  29. delegate: PrinterFamilyPill {
  30. text: modelData;
  31. }
  32. model: printJob ? printJob.compatibleMachineFamilies : [];
  33. visible: printJob;
  34. }
  35. PrinterFamilyPill {
  36. text: printer ? printer.type : "";
  37. visible: !compatiblePills.visible && printer;
  38. }
  39. }
  40. // Extruder info
  41. Row {
  42. id: extrudersInfo;
  43. anchors {
  44. left: parent.left;
  45. right: parent.right;
  46. rightMargin: UM.Theme.getSize("default_margin").width;
  47. top: printerFamilyPills.bottom;
  48. topMargin: UM.Theme.getSize("default_margin").height;
  49. }
  50. height: childrenRect.height;
  51. spacing: UM.Theme.getSize("default_margin").width;
  52. width: parent.width;
  53. PrintCoreConfiguration {
  54. width: Math.round(parent.width / 2) * screenScaleFactor;
  55. printCoreConfiguration: getExtruderConfig(0);
  56. }
  57. PrintCoreConfiguration {
  58. width: Math.round(parent.width / 2) * screenScaleFactor;
  59. printCoreConfiguration: getExtruderConfig(1);
  60. }
  61. }
  62. function getExtruderConfig( i ) {
  63. if (root.printJob) {
  64. // Use more-specific print job if possible
  65. return root.printJob.configuration.extruderConfigurations[i];
  66. }
  67. if (root.printer) {
  68. return root.printer.printerConfiguration.extruderConfigurations[i];
  69. }
  70. return null;
  71. }
  72. }