SidebarHeader.qml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright (c) 2015 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import UM 1.0 as UM
  8. Column {
  9. id: base;
  10. property variant modesModel;
  11. property alias currentModeIndex: modeMenu.currentIndex;
  12. property Action addMachineAction;
  13. property Action configureMachinesAction;
  14. spacing: UM.Theme.sizes.default_margin.height;
  15. RowLayout {
  16. anchors.horizontalCenter: parent.horizontalCenter;
  17. width: parent.width - UM.Theme.sizes.default_margin.width * 2;
  18. height: UM.Theme.sizes.line.height;
  19. Label {
  20. //: Configuration mode label
  21. text: qsTr("Mode:");
  22. font: UM.Theme.fonts.sidebar_header;
  23. color: UM.Theme.colors.text_inactive;
  24. }
  25. ToolButton {
  26. text: base.modesModel ? base.modesModel.get(modeMenu.currentIndex).text : "";
  27. style: UM.Theme.styles.sidebar_header_button;
  28. Layout.preferredWidth: base.width * 0.25;
  29. menu: Menu {
  30. id: modeMenu;
  31. property int currentIndex: 0;
  32. Instantiator {
  33. model: base.modesModel;
  34. MenuItem {
  35. text: model.text;
  36. checkable: true;
  37. checked: modeMenu.currentIndex == index;
  38. exclusiveGroup: modeMenuGroup;
  39. onTriggered: modeMenu.currentIndex = index;
  40. }
  41. onObjectAdded: modeMenu.insertItem(index, object)
  42. onObjectRemoved: modeMenu.removeItem(object)
  43. }
  44. ExclusiveGroup { id: modeMenuGroup; }
  45. }
  46. }
  47. Rectangle {
  48. width: 1;
  49. height: parent.height;
  50. color: UM.Theme.colors.border;
  51. }
  52. Label {
  53. //: Machine selection label
  54. text: qsTr("Machine:");
  55. font: UM.Theme.fonts.sidebar_header;
  56. color: UM.Theme.colors.text_inactive;
  57. }
  58. ToolButton {
  59. id: machineButton;
  60. text: UM.Application.machineName;
  61. tooltip: UM.Application.machineName;
  62. style: UM.Theme.styles.sidebar_header_button;
  63. Layout.fillWidth: true;
  64. menu: Menu {
  65. id: machineMenu;
  66. Instantiator {
  67. model: UM.Models.machinesModel
  68. MenuItem {
  69. text: model.name;
  70. checkable: true;
  71. checked: model.active;
  72. exclusiveGroup: machineMenuGroup;
  73. onTriggered: UM.Models.machinesModel.setActive(index)
  74. }
  75. onObjectAdded: machineMenu.insertItem(index, object)
  76. onObjectRemoved: machineMenu.removeItem(object)
  77. }
  78. ExclusiveGroup { id: machineMenuGroup; }
  79. MenuSeparator { }
  80. MenuItem { action: base.addMachineAction; }
  81. MenuItem { action: base.configureMachinesAction; }
  82. }
  83. }
  84. }
  85. UM.SidebarCategoryHeader {
  86. width: parent.width;
  87. height: UM.Theme.sizes.section.height;
  88. iconSource: UM.Theme.icons.printsetup;
  89. //: Sidebar header label
  90. text: qsTr("Print Setup");
  91. enabled: false;
  92. color: UM.Theme.colors.primary;
  93. }
  94. }