PrintWindow.qml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Window 2.2
  5. import QtQuick.Controls 2.15
  6. import UM 1.1 as UM
  7. UM.Dialog {
  8. id: base;
  9. title: catalog.i18nc("@title:window", "Print over network");
  10. width: minimumWidth;
  11. height: minimumHeight;
  12. maximumHeight: minimumHeight;
  13. maximumWidth: minimumWidth;
  14. minimumHeight: 140 * screenScaleFactor;
  15. minimumWidth: 500 * screenScaleFactor;
  16. modality: Qt.ApplicationModal;
  17. Component.onCompleted: {
  18. populateComboBox()
  19. }
  20. // populates the combo box with the correct printer values
  21. function populateComboBox() {
  22. comboBoxPrintersModel.clear();
  23. comboBoxPrintersModel.append({ name: "Automatic", key: "" }); // Connect will just do it's thing
  24. for (var i in OutputDevice.printers) {
  25. comboBoxPrintersModel.append({
  26. name: OutputDevice.printers[i].name,
  27. key: OutputDevice.printers[i].uniqueName
  28. });
  29. }
  30. }
  31. leftButtons: [
  32. Button {
  33. enabled: true;
  34. onClicked: {
  35. base.close();
  36. }
  37. text: catalog.i18nc("@action:button","Cancel");
  38. }
  39. ]
  40. rightButtons: [
  41. Button {
  42. enabled: true;
  43. onClicked: {
  44. OutputDevice.selectTargetPrinter(printerComboBox.model.get(printerComboBox.currentIndex).key);
  45. base.close();
  46. }
  47. text: catalog.i18nc("@action:button","Print");
  48. }
  49. ]
  50. Column {
  51. id: printerSelection;
  52. anchors {
  53. fill: parent;
  54. leftMargin: UM.Theme.getSize("default_margin").width;
  55. rightMargin: UM.Theme.getSize("default_margin").width;
  56. top: parent.top;
  57. topMargin: UM.Theme.getSize("default_margin").height;
  58. }
  59. height: 50 * screenScaleFactor;
  60. UM.I18nCatalog {
  61. id: catalog;
  62. name: "cura";
  63. }
  64. Label {
  65. id: manualPrinterSelectionLabel;
  66. anchors {
  67. left: parent.left;
  68. right: parent.right;
  69. topMargin: UM.Theme.getSize("default_margin").height;
  70. }
  71. height: 20 * screenScaleFactor;
  72. text: catalog.i18nc("@label", "Printer selection");
  73. wrapMode: Text.Wrap;
  74. renderType: Text.NativeRendering;
  75. }
  76. ComboBox {
  77. id: printerComboBox;
  78. currentIndex: 0;
  79. Behavior on height { NumberAnimation { duration: 100 } }
  80. height: 40 * screenScaleFactor;
  81. model: ListModel {
  82. id: comboBoxPrintersModel;
  83. }
  84. textRole: "name";
  85. width: parent.width;
  86. }
  87. }
  88. }