MachinesPage.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. anchors.left: parent.left
  69. anchors.right: parent.right
  70. anchors.top: machineName.bottom
  71. anchors.topMargin: UM.Theme.getSize("default_margin").height
  72. Repeater
  73. {
  74. id: machineActionRepeater
  75. model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id))
  76. Button
  77. {
  78. text: machineActionRepeater.model[index].label;
  79. onClicked:
  80. {
  81. actionDialog.content = machineActionRepeater.model[index].displayItem
  82. machineActionRepeater.model[index].displayItem.reset()
  83. actionDialog.show()
  84. }
  85. }
  86. }
  87. }
  88. UM.Dialog
  89. {
  90. id: actionDialog
  91. property var content
  92. onContentChanged:
  93. {
  94. contents = content;
  95. content.onCompleted.connect(hide)
  96. }
  97. }
  98. Row
  99. {
  100. anchors.top: machineActions.visible ? machineActions.bottom : machineActions.anchors.top
  101. anchors.topMargin: UM.Theme.getSize("default_margin").height
  102. anchors.left: parent.left
  103. anchors.right: parent.right
  104. spacing: UM.Theme.getSize("default_margin").height
  105. Label { text: catalog.i18nc("@label", "Type") }
  106. Label { text: base.currentItem ? base.currentItem.metadata.definition_name : "" }
  107. }
  108. UM.I18nCatalog { id: catalog; name: "uranium"; }
  109. UM.ConfirmRemoveDialog
  110. {
  111. id: confirmDialog;
  112. object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
  113. onYes: Cura.MachineManager.removeMachine(base.currentItem.id);
  114. }
  115. UM.RenameDialog
  116. {
  117. id: renameDialog;
  118. object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
  119. onAccepted:
  120. {
  121. Cura.MachineManager.renameMachine(base.currentItem.id, newName.trim());
  122. //Reselect current item to update details panel
  123. var index = objectList.currentIndex
  124. objectList.currentIndex = -1
  125. objectList.currentIndex = index
  126. }
  127. }
  128. }
  129. }