PreviewMenu.qml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 * 2
  22. rightMargin: UM.Theme.getSize("wide_margin").width * 2
  23. }
  24. Row
  25. {
  26. id: stageMenuRow
  27. anchors.fill: parent
  28. // This is a trick to make sure that the borders of the two adjacent buttons' borders overlap. Otherwise
  29. // there will be double border (one from each button)
  30. spacing: -UM.Theme.getSize("default_lining").width
  31. Cura.ViewsSelector
  32. {
  33. id: viewsSelector
  34. height: parent.height
  35. width: Math.max(Math.round((parent.width - printSetupSelectorItem.width) / 3), UM.Theme.getSize("views_selector").width)
  36. headerCornerSide: Cura.RoundedRectangle.Direction.Left
  37. }
  38. // This component will grow freely up to complete the width of the row.
  39. Loader
  40. {
  41. id: viewPanel
  42. height: parent.height
  43. width: source != "" ? (parent.width - viewsSelector.width - printSetupSelectorItem.width) : 0
  44. source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
  45. }
  46. Item
  47. {
  48. id: printSetupSelectorItem
  49. // This is a work around to prevent the printSetupSelector from having to be re-loaded every time
  50. // a stage switch is done.
  51. children: [printSetupSelector]
  52. height: childrenRect.height
  53. width: childrenRect.width
  54. }
  55. }
  56. }