MachinesPage.qml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. onAddObject: Printer.requestAddPrinter()
  25. onRemoveObject: confirmDialog.open();
  26. onRenameObject: renameDialog.open();
  27. onActivateObject: Cura.MachineManager.setActiveMachine(base.currentItem.id)
  28. removeEnabled: base.currentItem != null && model.rowCount() > 1
  29. renameEnabled: base.currentItem != null
  30. activateEnabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMachineId
  31. Flow
  32. {
  33. anchors.fill: parent;
  34. spacing: UM.Theme.getSize("default_margin").height;
  35. Row
  36. {
  37. Repeater
  38. {
  39. id: machineActionRepeater
  40. model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.activeDefinitionId)
  41. Button
  42. {
  43. text: machineActionRepeater.model[index].label;
  44. }
  45. }
  46. }
  47. Label
  48. {
  49. text: base.currentItem && base.currentItem.name ? base.currentItem.name : ""
  50. font: UM.Theme.getFont("large")
  51. width: parent.width
  52. elide: Text.ElideRight
  53. }
  54. Label { text: catalog.i18nc("@label", "Type"); width: parent.width * 0.2; }
  55. Label { text: base.currentItem && base.currentItem.typeName ? base.currentItem.typeName : ""; width: parent.width * 0.7; }
  56. UM.I18nCatalog { id: catalog; name: "uranium"; }
  57. UM.ConfirmRemoveDialog
  58. {
  59. id: confirmDialog;
  60. object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
  61. onYes: Cura.MachineManager.removeMachine(base.currentItem.id);
  62. }
  63. UM.RenameDialog
  64. {
  65. id: renameDialog;
  66. object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
  67. onAccepted:
  68. {
  69. Cura.MachineManager.renameMachine(base.currentItem.id, newName.trim());
  70. //Reselect current item to update details panel
  71. var index = objectList.currentIndex
  72. objectList.currentIndex = -1
  73. objectList.currentIndex = index
  74. }
  75. }
  76. }
  77. }