PrintWindow.qml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. {
  9. id: base;
  10. minimumWidth: 500 * screenScaleFactor
  11. minimumHeight: 140 * screenScaleFactor
  12. maximumWidth: minimumWidth
  13. maximumHeight: minimumHeight
  14. width: minimumWidth
  15. height: minimumHeight
  16. visible: true
  17. modality: Qt.ApplicationModal
  18. onVisibleChanged:
  19. {
  20. if(visible)
  21. {
  22. resetPrintersModel()
  23. }
  24. }
  25. title: catalog.i18nc("@title:window", "Print over network")
  26. property var printersModel: ListModel{}
  27. function resetPrintersModel() {
  28. printersModel.clear()
  29. printersModel.append({ name: "Automatic", key: ""})
  30. for (var index in OutputDevice.printers)
  31. {
  32. printersModel.append({name: OutputDevice.printers[index].name, key: OutputDevice.printers[index].key})
  33. }
  34. }
  35. Column
  36. {
  37. id: printerSelection
  38. anchors.fill: parent
  39. anchors.top: parent.top
  40. anchors.topMargin: UM.Theme.getSize("default_margin").height
  41. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  42. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  43. height: 50 * screenScaleFactor
  44. Label
  45. {
  46. id: manualPrinterSelectionLabel
  47. anchors
  48. {
  49. left: parent.left
  50. topMargin: UM.Theme.getSize("default_margin").height
  51. right: parent.right
  52. }
  53. text: catalog.i18nc("@label", "Printer selection")
  54. wrapMode: Text.Wrap
  55. height: 20 * screenScaleFactor
  56. }
  57. ComboBox
  58. {
  59. id: printerSelectionCombobox
  60. model: base.printersModel
  61. textRole: "name"
  62. width: parent.width
  63. height: 40 * screenScaleFactor
  64. Behavior on height { NumberAnimation { duration: 100 } }
  65. }
  66. SystemPalette
  67. {
  68. id: palette
  69. }
  70. UM.I18nCatalog { id: catalog; name: "cura"; }
  71. }
  72. leftButtons: [
  73. Button
  74. {
  75. text: catalog.i18nc("@action:button","Cancel")
  76. enabled: true
  77. onClicked: {
  78. base.visible = false;
  79. printerSelectionCombobox.currentIndex = 0
  80. }
  81. }
  82. ]
  83. rightButtons: [
  84. Button
  85. {
  86. text: catalog.i18nc("@action:button","Print")
  87. enabled: true
  88. onClicked: {
  89. base.visible = false;
  90. OutputDevice.selectPrinter(printerSelectionCombobox.model.get(printerSelectionCombobox.currentIndex).key)
  91. // reset to defaults
  92. printerSelectionCombobox.currentIndex = 0
  93. }
  94. }
  95. ]
  96. }