PrintWindow.qml 2.8 KB

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