MachinesPage.qml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Uranium is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.1
  4. import QtQuick.Controls 1.1
  5. import UM 1.2 as UM
  6. import Cura 1.0 as Cura
  7. UM.ManagementPage
  8. {
  9. id: base;
  10. title: catalog.i18nc("@title:tab", "Printers");
  11. model: UM.ContainerStacksModel
  12. {
  13. filter: {"type": "machine"}
  14. }
  15. activeId: Cura.MachineManager.activeMachineId
  16. activeIndex: {
  17. for(var i = 0; i < model.rowCount(); i++) {
  18. if (model.getItem(i).id == Cura.MachineManager.activeMachineId) {
  19. return i;
  20. }
  21. }
  22. return -1;
  23. }
  24. buttons: [
  25. Button
  26. {
  27. text: catalog.i18nc("@action:button", "Activate");
  28. iconName: "list-activate";
  29. enabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMaterialId
  30. onClicked: Cura.MachineManager.setActiveMachine(base.currentItem.id)
  31. },
  32. Button
  33. {
  34. text: catalog.i18nc("@action:button", "Add");
  35. iconName: "list-add";
  36. onClicked: Printer.requestAddPrinter()
  37. },
  38. Button
  39. {
  40. text: catalog.i18nc("@action:button", "Remove");
  41. iconName: "list-remove";
  42. enabled: base.currentItem != null && model.rowCount() > 1
  43. onClicked: confirmDialog.open();
  44. },
  45. Button
  46. {
  47. text: catalog.i18nc("@action:button", "Rename");
  48. iconName: "edit-rename";
  49. enabled: base.currentItem != null
  50. onClicked: renameDialog.open();
  51. }
  52. ]
  53. Item
  54. {
  55. visible: base.currentItem != null
  56. anchors.fill: parent
  57. Label
  58. {
  59. id: machineName
  60. text: base.currentItem && base.currentItem.name ? base.currentItem.name : ""
  61. font: UM.Theme.getFont("large")
  62. width: parent.width
  63. elide: Text.ElideRight
  64. }
  65. Flow
  66. {
  67. id: machineActions
  68. visible: currentItem && currentItem.id == Cura.MachineManager.activeMachineId
  69. anchors.left: parent.left
  70. anchors.right: parent.right
  71. anchors.top: machineName.bottom
  72. anchors.topMargin: UM.Theme.getSize("default_margin").height
  73. Repeater
  74. {
  75. id: machineActionRepeater
  76. model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id))
  77. Button
  78. {
  79. text: machineActionRepeater.model[index].label;
  80. onClicked:
  81. {
  82. actionDialog.content = machineActionRepeater.model[index].displayItem
  83. machineActionRepeater.model[index].displayItem.reset()
  84. actionDialog.show()
  85. }
  86. }
  87. }
  88. }
  89. UM.Dialog
  90. {
  91. id: actionDialog
  92. property var content
  93. onContentChanged:
  94. {
  95. contents = content;
  96. content.onCompleted.connect(hide)
  97. }
  98. }
  99. Row
  100. {
  101. anchors.top: machineActions.visible ? machineActions.bottom : machineActions.anchors.top
  102. anchors.topMargin: UM.Theme.getSize("default_margin").height
  103. anchors.left: parent.left
  104. anchors.right: parent.right
  105. spacing: UM.Theme.getSize("default_margin").height
  106. Label { text: catalog.i18nc("@label", "Type") }
  107. Label { text: base.currentItem ? base.currentItem.metadata.definition_name : "" }
  108. }
  109. UM.I18nCatalog { id: catalog; name: "uranium"; }
  110. UM.ConfirmRemoveDialog
  111. {
  112. id: confirmDialog;
  113. object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
  114. onYes: Cura.MachineManager.removeMachine(base.currentItem.id);
  115. }
  116. UM.RenameDialog
  117. {
  118. id: renameDialog;
  119. object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
  120. onAccepted:
  121. {
  122. Cura.MachineManager.renameMachine(base.currentItem.id, newName.trim());
  123. //Reselect current item to update details panel
  124. var index = objectList.currentIndex
  125. objectList.currentIndex = -1
  126. objectList.currentIndex = index
  127. }
  128. }
  129. }
  130. }