PrintWindow.qml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright (c) 2018 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.2
  6. import UM 1.1 as UM
  7. UM.Dialog {
  8. id: base;
  9. height: minimumHeight;
  10. leftButtons: [
  11. Button {
  12. enabled: true;
  13. onClicked: {
  14. base.visible = false;
  15. printerSelectionCombobox.currentIndex = 0;
  16. OutputDevice.cancelPrintSelection();
  17. }
  18. text: catalog.i18nc("@action:button","Cancel");
  19. }
  20. ]
  21. maximumHeight: minimumHeight;
  22. maximumWidth: minimumWidth;
  23. minimumHeight: 140 * screenScaleFactor;
  24. minimumWidth: 500 * screenScaleFactor;
  25. modality: Qt.ApplicationModal;
  26. onVisibleChanged: {
  27. if (visible) {
  28. resetPrintersModel();
  29. } else {
  30. OutputDevice.cancelPrintSelection();
  31. }
  32. }
  33. rightButtons: [
  34. Button {
  35. enabled: true;
  36. onClicked: {
  37. base.visible = false;
  38. OutputDevice.selectPrinter(printerSelectionCombobox.model.get(printerSelectionCombobox.currentIndex).key);
  39. // reset to defaults
  40. printerSelectionCombobox.currentIndex = 0;
  41. }
  42. text: catalog.i18nc("@action:button","Print");
  43. }
  44. ]
  45. title: catalog.i18nc("@title:window", "Print over network");
  46. visible: true;
  47. width: minimumWidth;
  48. Column {
  49. id: printerSelection;
  50. anchors {
  51. fill: parent;
  52. leftMargin: UM.Theme.getSize("default_margin").width;
  53. rightMargin: UM.Theme.getSize("default_margin").width;
  54. top: parent.top;
  55. topMargin: UM.Theme.getSize("default_margin").height;
  56. }
  57. height: 50 * screenScaleFactor;
  58. SystemPalette {
  59. id: palette;
  60. }
  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. ComboBox {
  78. id: printerSelectionCombobox;
  79. Behavior on height { NumberAnimation { duration: 100 } }
  80. height: 40 * screenScaleFactor;
  81. model: ListModel {
  82. id: printersModel;
  83. }
  84. textRole: "name";
  85. width: parent.width;
  86. }
  87. }
  88. // Utils
  89. function resetPrintersModel() {
  90. printersModel.clear();
  91. printersModel.append({ name: "Automatic", key: ""});
  92. for (var index in OutputDevice.printers) {
  93. printersModel.append({name: OutputDevice.printers[index].name, key: OutputDevice.printers[index].key});
  94. }
  95. }
  96. }