SidebarHeader.qml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 UM 1.1 as UM
  7. Item
  8. {
  9. id: base;
  10. // Machine Setup
  11. property Action addMachineAction;
  12. property Action configureMachinesAction;
  13. UM.I18nCatalog { id: catalog; name:"cura"}
  14. property int totalHeightHeader: childrenRect.height
  15. Rectangle {
  16. id: sidebarTabRow
  17. width: base.width
  18. height: 0
  19. anchors.top: parent.top
  20. color: UM.Theme.getColor("sidebar_header_bar")
  21. }
  22. Label{
  23. id: printjobTabLabel
  24. text: catalog.i18nc("@label:listbox","Print Job");
  25. anchors.left: parent.left
  26. anchors.leftMargin: UM.Theme.getSize("default_margin").width;
  27. anchors.top: sidebarTabRow.bottom
  28. anchors.topMargin: UM.Theme.getSize("default_margin").height
  29. width: parent.width/100*45
  30. font: UM.Theme.getFont("large");
  31. color: UM.Theme.getColor("text")
  32. }
  33. Rectangle {
  34. id: machineSelectionRow
  35. width: base.width
  36. height: UM.Theme.getSize("sidebar_setup").height
  37. anchors.top: printjobTabLabel.bottom
  38. anchors.topMargin: UM.Theme.getSize("default_margin").height
  39. anchors.horizontalCenter: parent.horizontalCenter
  40. Label{
  41. id: machineSelectionLabel
  42. //: Machine selection label
  43. text: catalog.i18nc("@label:listbox","Printer:");
  44. anchors.left: parent.left
  45. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  46. anchors.verticalCenter: parent.verticalCenter
  47. font: UM.Theme.getFont("default");
  48. color: UM.Theme.getColor("text");
  49. }
  50. ToolButton {
  51. id: machineSelection
  52. text: UM.MachineManager.activeMachineInstance;
  53. width: parent.width/100*55
  54. height: UM.Theme.getSize("setting_control").height
  55. tooltip: UM.MachineManager.activeMachineInstance;
  56. anchors.right: parent.right
  57. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  58. anchors.verticalCenter: parent.verticalCenter
  59. style: UM.Theme.styles.sidebar_header_button
  60. menu: Menu
  61. {
  62. id: machineSelectionMenu
  63. Instantiator
  64. {
  65. // model: UM.MachineInstancesModel { }
  66. MenuItem
  67. {
  68. text: model.name;
  69. checkable: true;
  70. checked: model.active;
  71. exclusiveGroup: machineSelectionMenuGroup;
  72. onTriggered: UM.MachineManager.setActiveMachineInstance(model.name);
  73. }
  74. onObjectAdded: machineSelectionMenu.insertItem(index, object)
  75. onObjectRemoved: machineSelectionMenu.removeItem(object)
  76. }
  77. ExclusiveGroup { id: machineSelectionMenuGroup; }
  78. MenuSeparator { }
  79. MenuItem { action: base.addMachineAction; }
  80. MenuItem { action: base.configureMachinesAction; }
  81. }
  82. }
  83. }
  84. Rectangle {
  85. id: variantRow
  86. anchors.top: machineSelectionRow.bottom
  87. anchors.topMargin: visible ? UM.Theme.getSize("default_margin").height : 0
  88. width: base.width
  89. height: visible ? UM.Theme.getSize("sidebar_setup").height : 0
  90. visible: UM.MachineManager.hasVariants || UM.MachineManager.hasMaterials
  91. Label{
  92. id: variantLabel
  93. text: (UM.MachineManager.hasVariants && UM.MachineManager.hasMaterials) ? catalog.i18nc("@label","Nozzle & Material:"):
  94. UM.MachineManager.hasVariants ? catalog.i18nc("@label","Nozzle:") : catalog.i18nc("@label","Material:");
  95. anchors.left: parent.left
  96. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  97. anchors.verticalCenter: parent.verticalCenter
  98. width: parent.width/100*45
  99. font: UM.Theme.getFont("default");
  100. color: UM.Theme.getColor("text");
  101. }
  102. Rectangle {
  103. anchors.right: parent.right
  104. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  105. anchors.verticalCenter: parent.verticalCenter
  106. width: parent.width/100*55
  107. height: UM.Theme.getSize("setting_control").height
  108. ToolButton {
  109. id: variantSelection
  110. text: UM.MachineManager.activeMachineVariant
  111. tooltip: UM.MachineManager.activeMachineVariant;
  112. visible: UM.MachineManager.hasVariants
  113. height: UM.Theme.getSize("setting_control").height
  114. width: materialSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  115. anchors.left: parent.left
  116. style: UM.Theme.styles.sidebar_header_button
  117. menu: Menu
  118. {
  119. id: variantsSelectionMenu
  120. Instantiator
  121. {
  122. id: variantSelectionInstantiator
  123. // model: UM.MachineVariantsModel { id: variantsModel }
  124. MenuItem
  125. {
  126. text: model.name;
  127. checkable: true;
  128. checked: model.active;
  129. exclusiveGroup: variantSelectionMenuGroup;
  130. onTriggered:
  131. {
  132. UM.MachineManager.setActiveMachineVariant(variantsModel.getItem(index).name);
  133. if (typeof(model) !== "undefined" && !model.active) {
  134. //Selecting a variant was canceled; undo menu selection
  135. variantSelectionInstantiator.model.setProperty(index, "active", false);
  136. var activeMachineVariantName = UM.MachineManager.activeMachineVariant;
  137. var activeMachineVariantIndex = variantSelectionInstantiator.model.find("name", activeMachineVariantName);
  138. variantSelectionInstantiator.model.setProperty(activeMachineVariantIndex, "active", true);
  139. }
  140. }
  141. }
  142. onObjectAdded: variantsSelectionMenu.insertItem(index, object)
  143. onObjectRemoved: variantsSelectionMenu.removeItem(object)
  144. }
  145. ExclusiveGroup { id: variantSelectionMenuGroup; }
  146. }
  147. }
  148. ToolButton {
  149. id: materialSelection
  150. text: UM.MachineManager.activeMaterial
  151. tooltip: UM.MachineManager.activeMaterial
  152. visible: UM.MachineManager.hasMaterials
  153. height: UM.Theme.getSize("setting_control").height
  154. width: variantSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width
  155. anchors.right: parent.right
  156. style: UM.Theme.styles.sidebar_header_button
  157. menu: Menu
  158. {
  159. id: materialSelectionMenu
  160. Instantiator
  161. {
  162. id: materialSelectionInstantiator
  163. // model: UM.MachineMaterialsModel { id: machineMaterialsModel }
  164. MenuItem
  165. {
  166. text: model.name;
  167. checkable: true;
  168. checked: model.active;
  169. exclusiveGroup: materialSelectionMenuGroup;
  170. onTriggered:
  171. {
  172. UM.MachineManager.setActiveMaterial(machineMaterialsModel.getItem(index).name);
  173. if (typeof(model) !== "undefined" && !model.active) {
  174. //Selecting a material was canceled; undo menu selection
  175. materialSelectionInstantiator.model.setProperty(index, "active", false);
  176. var activeMaterialName = UM.MachineManager.activeMaterial;
  177. var activeMaterialIndex = materialSelectionInstantiator.model.find("name", activeMaterialName);
  178. materialSelectionInstantiator.model.setProperty(activeMaterialIndex, "active", true);
  179. }
  180. }
  181. }
  182. onObjectAdded: materialSelectionMenu.insertItem(index, object)
  183. onObjectRemoved: materialSelectionMenu.removeItem(object)
  184. }
  185. ExclusiveGroup { id: materialSelectionMenuGroup; }
  186. }
  187. }
  188. }
  189. }
  190. }