PreviewMenu.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. UM.I18nCatalog
  14. {
  15. id: catalog
  16. name: "cura"
  17. }
  18. Row
  19. {
  20. anchors.horizontalCenter: parent.horizontalCenter
  21. spacing: UM.Theme.getSize("default_margin").width
  22. height: parent.height
  23. Rectangle
  24. {
  25. color: UM.Theme.getColor("tool_panel_background")
  26. width: viewModeButton.width + 2 * UM.Theme.getSize("default_margin").width
  27. height: parent.height
  28. ComboBox
  29. {
  30. // This item contains the views selector, a combobox that is dynamically created from
  31. // the list of available Views (packages that create different visualizations of the
  32. // scene).
  33. id: viewModeButton
  34. style: UM.Theme.styles.combobox
  35. anchors.centerIn: parent
  36. model: UM.ViewModel { }
  37. textRole: "name"
  38. // update the model's active index
  39. function updateItemActiveFlags()
  40. {
  41. currentIndex = getActiveIndex()
  42. for (var i = 0; i < model.rowCount(); i++)
  43. {
  44. model.getItem(i).active = (i == currentIndex)
  45. }
  46. }
  47. // get the index of the active model item on start
  48. function getActiveIndex()
  49. {
  50. for (var i = 0; i < model.rowCount(); i++)
  51. {
  52. if (model.getItem(i).active)
  53. {
  54. return i;
  55. }
  56. }
  57. return 0
  58. }
  59. onCurrentIndexChanged:
  60. {
  61. if (model.getItem(currentIndex).id != undefined)
  62. {
  63. UM.Controller.setActiveView(model.getItem(currentIndex).id)
  64. }
  65. }
  66. currentIndex: getActiveIndex()
  67. }
  68. }
  69. Loader
  70. {
  71. // TODO: Make this panel collapsable and ensure it has a standardised background.
  72. id: viewPanel
  73. property var buttonTarget: Qt.point(viewModeButton.x + Math.round(viewModeButton.width / 2), viewModeButton.y + Math.round(viewModeButton.height / 2))
  74. height: parent.height
  75. width: childrenRect.width
  76. source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
  77. }
  78. Cura.PrintSetupSelector
  79. {
  80. width: UM.Theme.getSize("print_setup_widget").width
  81. height: parent.height
  82. onShowTooltip: previewMenu.showTooltip(item, location, text)
  83. onHideTooltip: previewMenu.hideTooltip()
  84. }
  85. }
  86. }