ObjectsList.qml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. // Copyright (c) 2018 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.height: width
  45. color: UM.Theme.getColor("setting_control_text")
  46. source: collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom")
  47. }
  48. label: Label{ }
  49. }
  50. }
  51. Component {
  52. id: buildPlateDelegate
  53. Rectangle
  54. {
  55. height: childrenRect.height
  56. color: multiBuildPlateModel.getItem(index).buildPlateNumber == multiBuildPlateModel.activeBuildPlate ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
  57. width: parent.width
  58. Label
  59. {
  60. id: buildPlateNameLabel
  61. anchors.left: parent.left
  62. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  63. width: parent.width - 2 * UM.Theme.getSize("default_margin").width - 30
  64. text: multiBuildPlateModel.getItem(index) ? multiBuildPlateModel.getItem(index).name : "";
  65. color: multiBuildPlateModel.activeBuildPlate == index ? palette.highlightedText : palette.text
  66. elide: Text.ElideRight
  67. }
  68. MouseArea
  69. {
  70. anchors.fill: parent;
  71. onClicked:
  72. {
  73. Cura.SceneController.setActiveBuildPlate(index);
  74. }
  75. }
  76. }
  77. }
  78. ScrollView
  79. {
  80. id: buildPlateSelection
  81. frameVisible: true
  82. height: UM.Theme.getSize("build_plate_selection_size").height
  83. width: parent.width - 2 * UM.Theme.getSize("default_margin").height
  84. style: UM.Theme.styles.scrollview
  85. anchors
  86. {
  87. top: collapseButton.bottom;
  88. topMargin: UM.Theme.getSize("default_margin").height;
  89. left: parent.left;
  90. leftMargin: UM.Theme.getSize("default_margin").height;
  91. bottomMargin: UM.Theme.getSize("default_margin").height;
  92. }
  93. Rectangle
  94. {
  95. parent: viewport
  96. anchors.fill: parent
  97. color: palette.light
  98. }
  99. ListView
  100. {
  101. id: buildPlateListView
  102. model: multiBuildPlateModel
  103. width: parent.width
  104. delegate: buildPlateDelegate
  105. }
  106. }
  107. Component {
  108. id: objectDelegate
  109. Rectangle
  110. {
  111. height: childrenRect.height
  112. color: Cura.ObjectsModel.getItem(index).isSelected ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
  113. width: parent.width
  114. Label
  115. {
  116. id: nodeNameLabel
  117. anchors.left: parent.left
  118. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  119. width: parent.width - 2 * UM.Theme.getSize("default_margin").width - 30
  120. text: (index >= 0) && Cura.ObjectsModel.getItem(index) ? Cura.ObjectsModel.getItem(index).name : "";
  121. color: Cura.ObjectsModel.getItem(index).isSelected ? palette.highlightedText : (Cura.ObjectsModel.getItem(index).isOutsideBuildArea ? palette.mid : palette.text)
  122. elide: Text.ElideRight
  123. }
  124. Label
  125. {
  126. id: buildPlateNumberLabel
  127. width: 20
  128. anchors.left: nodeNameLabel.right
  129. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  130. anchors.right: parent.right
  131. text: Cura.ObjectsModel.getItem(index).buildPlateNumber != -1 ? Cura.ObjectsModel.getItem(index).buildPlateNumber + 1 : "";
  132. color: Cura.ObjectsModel.getItem(index).isSelected ? palette.highlightedText : palette.text
  133. elide: Text.ElideRight
  134. }
  135. MouseArea
  136. {
  137. anchors.fill: parent;
  138. onClicked:
  139. {
  140. Cura.SceneController.changeSelection(index);
  141. }
  142. }
  143. }
  144. }
  145. // list all the scene nodes
  146. ScrollView
  147. {
  148. id: objectsList
  149. frameVisible: true
  150. visible: !collapsed
  151. width: parent.width - 2 * UM.Theme.getSize("default_margin").height
  152. anchors
  153. {
  154. top: buildPlateSelection.bottom;
  155. topMargin: UM.Theme.getSize("default_margin").height;
  156. left: parent.left;
  157. leftMargin: UM.Theme.getSize("default_margin").height;
  158. bottom: filterBuildPlateCheckbox.top;
  159. bottomMargin: UM.Theme.getSize("default_margin").height;
  160. }
  161. Rectangle
  162. {
  163. parent: viewport
  164. anchors.fill: parent
  165. color: palette.light
  166. }
  167. ListView
  168. {
  169. id: listview
  170. model: Cura.ObjectsModel
  171. width: parent.width
  172. delegate: objectDelegate
  173. }
  174. }
  175. CheckBox
  176. {
  177. id: filterBuildPlateCheckbox
  178. visible: !collapsed
  179. checked: UM.Preferences.getValue("view/filter_current_build_plate")
  180. onClicked: UM.Preferences.setValue("view/filter_current_build_plate", checked)
  181. text: catalog.i18nc("@option:check","See only current build plate");
  182. style: UM.Theme.styles.checkbox;
  183. anchors
  184. {
  185. left: parent.left;
  186. topMargin: UM.Theme.getSize("default_margin").height;
  187. bottomMargin: UM.Theme.getSize("default_margin").height;
  188. leftMargin: UM.Theme.getSize("default_margin").height;
  189. bottom: arrangeAllBuildPlatesButton.top;
  190. }
  191. }
  192. Button
  193. {
  194. id: arrangeAllBuildPlatesButton;
  195. text: catalog.i18nc("@action:button","Arrange to all build plates");
  196. style: UM.Theme.styles.print_setup_action_button
  197. height: UM.Theme.getSize("objects_menu_button").height;
  198. tooltip: '';
  199. anchors
  200. {
  201. topMargin: UM.Theme.getSize("default_margin").height;
  202. left: parent.left;
  203. leftMargin: UM.Theme.getSize("default_margin").height;
  204. right: parent.right;
  205. rightMargin: UM.Theme.getSize("default_margin").height;
  206. bottom: arrangeBuildPlateButton.top;
  207. bottomMargin: UM.Theme.getSize("default_margin").height;
  208. }
  209. action: Cura.Actions.arrangeAllBuildPlates;
  210. }
  211. Button
  212. {
  213. id: arrangeBuildPlateButton;
  214. text: catalog.i18nc("@action:button","Arrange current build plate");
  215. style: UM.Theme.styles.print_setup_action_button
  216. height: UM.Theme.getSize("objects_menu_button").height;
  217. tooltip: '';
  218. anchors
  219. {
  220. topMargin: UM.Theme.getSize("default_margin").height;
  221. left: parent.left;
  222. leftMargin: UM.Theme.getSize("default_margin").height;
  223. right: parent.right;
  224. rightMargin: UM.Theme.getSize("default_margin").height;
  225. bottom: parent.bottom;
  226. bottomMargin: UM.Theme.getSize("default_margin").height;
  227. }
  228. action: Cura.Actions.arrangeAll;
  229. }
  230. }