PreviewMenu.qml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. // This is a trick to make sure that the borders of the two adjacent buttons' borders overlap. Otherwise
  31. // there will be double border (one from each button)
  32. spacing: -UM.Theme.getSize("default_lining").width
  33. Cura.ViewsSelector
  34. {
  35. id: viewsSelector
  36. height: parent.height
  37. width: UM.Theme.getSize("views_selector").width
  38. headerBackgroundBorder.width: UM.Theme.getSize("default_lining").width
  39. headerBackgroundBorder.color: UM.Theme.getColor("lining")
  40. enableHeaderShadow: false
  41. headerCornerSide: Cura.RoundedRectangle.Direction.Left
  42. }
  43. // This component will grow freely up to complete the width of the row.
  44. Loader
  45. {
  46. id: viewPanel
  47. height: parent.height
  48. width: source != "" ? (previewMenu.width - viewsSelector.width - printSetupSelectorItem.width - 2 * (UM.Theme.getSize("wide_margin").width + UM.Theme.getSize("default_lining").width)) : 0
  49. source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
  50. }
  51. Item
  52. {
  53. id: printSetupSelectorItem
  54. // This is a work around to prevent the printSetupSelector from having to be re-loaded every time
  55. // a stage switch is done.
  56. children: [printSetupSelector]
  57. height: childrenRect.height
  58. width: childrenRect.width
  59. }
  60. }
  61. }