ObjectsList.qml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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.2 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: false;
  27. SystemPalette { id: palette }
  28. Button {
  29. id: collapseButton
  30. anchors.top: parent.top
  31. anchors.topMargin: Math.floor(UM.Theme.getSize("default_margin").height + (UM.Theme.getSize("layerview_row").height - UM.Theme.getSize("default_margin").height) / 2)
  32. anchors.right: parent.right
  33. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  34. width: UM.Theme.getSize("standard_arrow").width
  35. height: UM.Theme.getSize("standard_arrow").height
  36. onClicked: collapsed = !collapsed
  37. style: ButtonStyle
  38. {
  39. background: UM.RecolorImage
  40. {
  41. width: control.width
  42. height: control.height
  43. sourceSize.width: width
  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: Cura.BuildPlateModel.getItem(index).buildPlateNumber == Cura.BuildPlateModel.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: Cura.BuildPlateModel.getItem(index) ? Cura.BuildPlateModel.getItem(index).name : "";
  65. color: Cura.BuildPlateModel.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. //bottom: objectsList.top;
  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: Cura.BuildPlateModel
  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: 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. //top: buildPlateSelection.bottom;
  203. topMargin: UM.Theme.getSize("default_margin").height;
  204. left: parent.left;
  205. leftMargin: UM.Theme.getSize("default_margin").height;
  206. right: parent.right;
  207. rightMargin: UM.Theme.getSize("default_margin").height;
  208. bottom: arrangeBuildPlateButton.top;
  209. bottomMargin: UM.Theme.getSize("default_margin").height;
  210. }
  211. action: Cura.Actions.arrangeAllBuildPlates;
  212. }
  213. Button
  214. {
  215. id: arrangeBuildPlateButton;
  216. text: catalog.i18nc("@action:button","Arrange current build plate");
  217. style: UM.Theme.styles.sidebar_action_button
  218. height: UM.Theme.getSize("objects_menu_button").height;
  219. tooltip: '';
  220. anchors
  221. {
  222. topMargin: UM.Theme.getSize("default_margin").height;
  223. left: parent.left;
  224. leftMargin: UM.Theme.getSize("default_margin").height;
  225. right: parent.right;
  226. rightMargin: UM.Theme.getSize("default_margin").height;
  227. bottom: parent.bottom;
  228. bottomMargin: UM.Theme.getSize("default_margin").height;
  229. }
  230. action: Cura.Actions.arrangeAll;
  231. }
  232. }