PreviewMenu.qml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Layouts 1.1
  5. import QtQuick.Controls 2.3
  6. import UM 1.3 as UM
  7. import Cura 1.1 as Cura
  8. Item
  9. {
  10. id: previewMenu
  11. property real itemHeight: height - 2 * UM.Theme.getSize("default_lining").width
  12. UM.I18nCatalog
  13. {
  14. id: catalog
  15. name: "cura"
  16. }
  17. Row
  18. {
  19. id: stageMenuRow
  20. anchors.centerIn: parent
  21. height: parent.height
  22. width: childrenRect.width
  23. // We want this row to have a preferred with equals to the 85% of the parent
  24. property int preferredWidth: Math.round(0.85 * previewMenu.width)
  25. Cura.ViewsSelector
  26. {
  27. id: viewsSelector
  28. height: parent.height
  29. width: UM.Theme.getSize("views_selector").width
  30. headerCornerSide: Cura.RoundedRectangle.Direction.Left
  31. }
  32. // Separator line
  33. Rectangle
  34. {
  35. height: parent.height
  36. // If there is no viewPanel, we only need a single spacer, so hide this one.
  37. visible: viewPanel.source != ""
  38. width: visible ? UM.Theme.getSize("default_lining").width : 0
  39. color: UM.Theme.getColor("lining")
  40. }
  41. // This component will grow freely up to complete the preferredWidth of the row.
  42. Loader
  43. {
  44. id: viewPanel
  45. height: parent.height
  46. width: source != "" ? (stageMenuRow.preferredWidth - viewsSelector.width - printSetupSelectorItem.width - 2 * UM.Theme.getSize("default_lining").width) : 0
  47. source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
  48. }
  49. // Separator line
  50. Rectangle
  51. {
  52. height: parent.height
  53. width: UM.Theme.getSize("default_lining").width
  54. color: UM.Theme.getColor("lining")
  55. }
  56. Item
  57. {
  58. id: printSetupSelectorItem
  59. // This is a work around to prevent the printSetupSelector from having to be re-loaded every time
  60. // a stage switch is done.
  61. children: [printSetupSelector]
  62. height: childrenRect.height
  63. width: childrenRect.width
  64. }
  65. }
  66. }