PrintWindow.qml 2.8 KB

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