PrintWindow.qml 3.0 KB

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