PreviewMenu.qml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. anchors
  18. {
  19. left: parent.left
  20. right: parent.right
  21. leftMargin: UM.Theme.getSize("wide_margin").width
  22. rightMargin: UM.Theme.getSize("wide_margin").width
  23. }
  24. Row
  25. {
  26. id: stageMenuRow
  27. anchors.horizontalCenter: parent.horizontalCenter
  28. width: parent.width - 2 * UM.Theme.getSize("wide_margin").width
  29. height: parent.height
  30. Cura.ViewsSelector
  31. {
  32. id: viewsSelector
  33. height: parent.height
  34. width: UM.Theme.getSize("views_selector").width
  35. headerCornerSide: Cura.RoundedRectangle.Direction.Left
  36. }
  37. // Separator line
  38. Rectangle
  39. {
  40. height: parent.height
  41. // If there is no viewPanel, we only need a single spacer, so hide this one.
  42. visible: viewPanel.source != ""
  43. width: visible ? UM.Theme.getSize("default_lining").width : 0
  44. color: UM.Theme.getColor("lining")
  45. }
  46. // This component will grow freely up to complete the width of the row.
  47. Loader
  48. {
  49. id: viewPanel
  50. height: parent.height
  51. width: source != "" ? (previewMenu.width - viewsSelector.width - printSetupSelectorItem.width - 2 * (UM.Theme.getSize("wide_margin").width + UM.Theme.getSize("default_lining").width)) : 0
  52. source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
  53. }
  54. // Separator line
  55. Rectangle
  56. {
  57. height: parent.height
  58. width: UM.Theme.getSize("default_lining").width
  59. color: UM.Theme.getColor("lining")
  60. }
  61. Item
  62. {
  63. id: printSetupSelectorItem
  64. // This is a work around to prevent the printSetupSelector from having to be re-loaded every time
  65. // a stage switch is done.
  66. children: [printSetupSelector]
  67. height: childrenRect.height
  68. width: childrenRect.width
  69. }
  70. }
  71. }