ObjectsList.qml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. // Copyright (c) 2017 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 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 QtQuick.Dialogs 1.1
  8. import UM 1.3 as UM
  9. import Cura 1.0 as Cura
  10. import "Menus"
  11. Rectangle
  12. {
  13. id: base;
  14. color: UM.Theme.getColor("tool_panel_background")
  15. width: UM.Theme.getSize("objects_menu_size").width
  16. height: {
  17. if (collapsed) {
  18. return UM.Theme.getSize("objects_menu_size_collapsed").height;
  19. } else {
  20. return UM.Theme.getSize("objects_menu_size").height;
  21. }
  22. }
  23. Behavior on height { NumberAnimation { duration: 100 } }
  24. border.width: UM.Theme.getSize("default_lining").width
  25. border.color: UM.Theme.getColor("lining")
  26. property bool collapsed: true
  27. property var multiBuildPlateModel: CuraApplication.getMultiBuildPlateModel()
  28. SystemPalette { id: palette }
  29. Button {
  30. id: collapseButton
  31. anchors.top: parent.top
  32. anchors.topMargin: Math.round(UM.Theme.getSize("default_margin").height + (UM.Theme.getSize("layerview_row").height - UM.Theme.getSize("default_margin").height) / 2)
  33. anchors.right: parent.right
  34. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  35. width: UM.Theme.getSize("standard_arrow").width
  36. height: UM.Theme.getSize("standard_arrow").height
  37. onClicked: collapsed = !collapsed
  38. style: ButtonStyle
  39. {
  40. background: UM.RecolorImage
  41. {
  42. width: control.width
  43. height: control.height
  44. sourceSize.width: width
  45. sourceSize.height: width
  46. color: UM.Theme.getColor("setting_control_text")
  47. source: collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom")
  48. }
  49. label: Label{ }
  50. }
  51. }
  52. Component {
  53. id: buildPlateDelegate
  54. Rectangle
  55. {
  56. height: childrenRect.height
  57. color: multiBuildPlateModel.getItem(index).buildPlateNumber == multiBuildPlateModel.activeBuildPlate ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
  58. width: parent.width
  59. Label
  60. {
  61. id: buildPlateNameLabel
  62. anchors.left: parent.left
  63. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  64. width: parent.width - 2 * UM.Theme.getSize("default_margin").width - 30
  65. text: multiBuildPlateModel.getItem(index) ? multiBuildPlateModel.getItem(index).name : "";
  66. color: multiBuildPlateModel.activeBuildPlate == index ? palette.highlightedText : palette.text
  67. elide: Text.ElideRight
  68. }
  69. MouseArea
  70. {
  71. anchors.fill: parent;
  72. onClicked:
  73. {
  74. Cura.SceneController.setActiveBuildPlate(index);
  75. }
  76. }
  77. }
  78. }
  79. ScrollView
  80. {
  81. id: buildPlateSelection
  82. frameVisible: true
  83. height: UM.Theme.getSize("build_plate_selection_size").height
  84. width: parent.width - 2 * UM.Theme.getSize("default_margin").height
  85. style: UM.Theme.styles.scrollview
  86. anchors
  87. {
  88. top: collapseButton.bottom;
  89. topMargin: UM.Theme.getSize("default_margin").height;
  90. left: parent.left;
  91. leftMargin: UM.Theme.getSize("default_margin").height;
  92. bottomMargin: UM.Theme.getSize("default_margin").height;
  93. }
  94. Rectangle
  95. {
  96. parent: viewport
  97. anchors.fill: parent
  98. color: palette.light
  99. }
  100. ListView
  101. {
  102. id: buildPlateListView
  103. model: multiBuildPlateModel
  104. width: parent.width
  105. delegate: buildPlateDelegate
  106. }
  107. }
  108. Component {
  109. id: objectDelegate
  110. Rectangle
  111. {
  112. height: childrenRect.height
  113. color: Cura.ObjectsModel.getItem(index).isSelected ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
  114. width: parent.width
  115. Label
  116. {
  117. id: nodeNameLabel
  118. anchors.left: parent.left
  119. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  120. width: parent.width - 2 * UM.Theme.getSize("default_margin").width - 30
  121. text: (index >= 0) && Cura.ObjectsModel.getItem(index) ? Cura.ObjectsModel.getItem(index).name : "";
  122. color: Cura.ObjectsModel.getItem(index).isSelected ? palette.highlightedText : (Cura.ObjectsModel.getItem(index).isOutsideBuildArea ? palette.mid : palette.text)
  123. elide: Text.ElideRight
  124. }
  125. Label
  126. {
  127. id: buildPlateNumberLabel
  128. width: 20
  129. anchors.left: nodeNameLabel.right
  130. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  131. anchors.right: parent.right
  132. text: Cura.ObjectsModel.getItem(index).buildPlateNumber != -1 ? Cura.ObjectsModel.getItem(index).buildPlateNumber + 1 : "";
  133. color: Cura.ObjectsModel.getItem(index).isSelected ? palette.highlightedText : palette.text
  134. elide: Text.ElideRight
  135. }
  136. MouseArea
  137. {
  138. anchors.fill: parent;
  139. onClicked:
  140. {
  141. Cura.SceneController.changeSelection(index);
  142. }
  143. }
  144. }
  145. }
  146. // list all the scene nodes
  147. ScrollView
  148. {
  149. id: objectsList
  150. frameVisible: true
  151. visible: !collapsed
  152. width: parent.width - 2 * UM.Theme.getSize("default_margin").height
  153. anchors
  154. {
  155. top: buildPlateSelection.bottom;
  156. topMargin: UM.Theme.getSize("default_margin").height;
  157. left: parent.left;
  158. leftMargin: UM.Theme.getSize("default_margin").height;
  159. bottom: filterBuildPlateCheckbox.top;
  160. bottomMargin: UM.Theme.getSize("default_margin").height;
  161. }
  162. Rectangle
  163. {
  164. parent: viewport
  165. anchors.fill: parent
  166. color: palette.light
  167. }
  168. ListView
  169. {
  170. id: listview
  171. model: Cura.ObjectsModel
  172. width: parent.width
  173. delegate: objectDelegate
  174. }
  175. }
  176. CheckBox
  177. {
  178. id: filterBuildPlateCheckbox
  179. visible: !collapsed
  180. checked: UM.Preferences.getValue("view/filter_current_build_plate")
  181. onClicked: UM.Preferences.setValue("view/filter_current_build_plate", checked)
  182. text: catalog.i18nc("@option:check","See only current build plate");
  183. style: UM.Theme.styles.checkbox;
  184. anchors
  185. {
  186. left: parent.left;
  187. topMargin: UM.Theme.getSize("default_margin").height;
  188. bottomMargin: UM.Theme.getSize("default_margin").height;
  189. leftMargin: UM.Theme.getSize("default_margin").height;
  190. bottom: arrangeAllBuildPlatesButton.top;
  191. }
  192. }
  193. Button
  194. {
  195. id: arrangeAllBuildPlatesButton;
  196. text: catalog.i18nc("@action:button","Arrange to all build plates");
  197. style: UM.Theme.styles.sidebar_action_button
  198. height: UM.Theme.getSize("objects_menu_button").height;
  199. tooltip: '';
  200. anchors
  201. {
  202. topMargin: UM.Theme.getSize("default_margin").height;
  203. left: parent.left;
  204. leftMargin: UM.Theme.getSize("default_margin").height;
  205. right: parent.right;
  206. rightMargin: UM.Theme.getSize("default_margin").height;
  207. bottom: arrangeBuildPlateButton.top;
  208. bottomMargin: UM.Theme.getSize("default_margin").height;
  209. }
  210. action: Cura.Actions.arrangeAllBuildPlates;
  211. }
  212. Button
  213. {
  214. id: arrangeBuildPlateButton;
  215. text: catalog.i18nc("@action:button","Arrange current build plate");
  216. style: UM.Theme.styles.sidebar_action_button
  217. height: UM.Theme.getSize("objects_menu_button").height;
  218. tooltip: '';
  219. anchors
  220. {
  221. topMargin: UM.Theme.getSize("default_margin").height;
  222. left: parent.left;
  223. leftMargin: UM.Theme.getSize("default_margin").height;
  224. right: parent.right;
  225. rightMargin: UM.Theme.getSize("default_margin").height;
  226. bottom: parent.bottom;
  227. bottomMargin: UM.Theme.getSize("default_margin").height;
  228. }
  229. action: Cura.Actions.arrangeAll;
  230. }
  231. }