PrintWindow.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.5 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. UM.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. }
  74. ComboBox {
  75. id: printerComboBox;
  76. currentIndex: 0;
  77. Behavior on height { NumberAnimation { duration: 100 } }
  78. height: 40 * screenScaleFactor;
  79. model: ListModel {
  80. id: comboBoxPrintersModel;
  81. }
  82. textRole: "name";
  83. width: parent.width;
  84. }
  85. }
  86. }