PreviewMenu.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.Controls 1.4
  5. import UM 1.3 as UM
  6. import Cura 1.1 as Cura
  7. Item
  8. {
  9. id: previewMenu
  10. // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it.
  11. signal showTooltip(Item item, point location, string text)
  12. signal hideTooltip()
  13. property real itemHeight: height - 2 * UM.Theme.getSize("default_lining").width
  14. UM.I18nCatalog
  15. {
  16. id: catalog
  17. name: "cura"
  18. }
  19. Rectangle
  20. {
  21. anchors.fill: stageMenu
  22. anchors.leftMargin: -radius
  23. radius: UM.Theme.getSize("default_radius").width
  24. color: UM.Theme.getColor("toolbar_background")
  25. }
  26. Item
  27. {
  28. id: stageMenu
  29. height: parent.height
  30. width: childrenRect.width + UM.Theme.getSize("default_margin").width
  31. anchors.horizontalCenter: parent.horizontalCenter
  32. Row
  33. {
  34. anchors.centerIn: parent
  35. //spacing: UM.Theme.getSize("default_margin").width
  36. height: parent.height
  37. Item
  38. {
  39. width: viewModeButton.width + 2 * UM.Theme.getSize("default_margin").width
  40. height: parent.height
  41. ComboBox
  42. {
  43. // This item contains the views selector, a combobox that is dynamically created from
  44. // the list of available Views (packages that create different visualizations of the
  45. // scene).
  46. id: viewModeButton
  47. style: UM.Theme.styles.combobox
  48. anchors.centerIn: parent
  49. model: UM.ViewModel { }
  50. textRole: "name"
  51. // update the model's active index
  52. function updateItemActiveFlags()
  53. {
  54. currentIndex = getActiveIndex()
  55. for (var i = 0; i < model.rowCount(); i++)
  56. {
  57. model.getItem(i).active = (i == currentIndex)
  58. }
  59. }
  60. // get the index of the active model item on start
  61. function getActiveIndex()
  62. {
  63. for (var i = 0; i < model.rowCount(); i++)
  64. {
  65. if (model.getItem(i).active)
  66. {
  67. return i;
  68. }
  69. }
  70. return 0
  71. }
  72. onCurrentIndexChanged:
  73. {
  74. if (model.getItem(currentIndex).id != undefined)
  75. {
  76. UM.Controller.setActiveView(model.getItem(currentIndex).id)
  77. }
  78. }
  79. currentIndex: getActiveIndex()
  80. }
  81. }
  82. // Separator line
  83. Rectangle
  84. {
  85. height: parent.height
  86. width: UM.Theme.getSize("default_lining").width
  87. color: UM.Theme.getColor("lining")
  88. }
  89. Loader
  90. {
  91. // TODO: Make this panel collapsable and ensure it has a standardised background.
  92. id: viewPanel
  93. property var buttonTarget: Qt.point(viewModeButton.x + Math.round(viewModeButton.width / 2), viewModeButton.y + Math.round(viewModeButton.height / 2))
  94. height: parent.height
  95. width: childrenRect.width
  96. source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
  97. }
  98. // Separator line
  99. Rectangle
  100. {
  101. height: parent.height
  102. width: UM.Theme.getSize("default_lining").width
  103. color: UM.Theme.getColor("lining")
  104. }
  105. Cura.PrintSetupSelector
  106. {
  107. width: UM.Theme.getSize("print_setup_widget").width
  108. height: parent.height
  109. onShowTooltip: previewMenu.showTooltip(item, location, text)
  110. onHideTooltip: previewMenu.hideTooltip()
  111. }
  112. }
  113. }
  114. }