MainWindowHeader.qml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 2.0 as Controls2
  5. import QtQuick.Controls 1.4
  6. import QtQuick.Controls.Styles 1.1
  7. import UM 1.4 as UM
  8. import Cura 1.0 as Cura
  9. import QtGraphicalEffects 1.0
  10. import "../Account"
  11. Item
  12. {
  13. id: base
  14. implicitHeight: UM.Theme.getSize("main_window_header").height
  15. implicitWidth: UM.Theme.getSize("main_window_header").width
  16. Image
  17. {
  18. id: logo
  19. anchors.left: parent.left
  20. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  21. anchors.verticalCenter: parent.verticalCenter
  22. source: UM.Theme.getImage("logo")
  23. width: UM.Theme.getSize("logo").width
  24. height: UM.Theme.getSize("logo").height
  25. mipmap: true
  26. }
  27. Row
  28. {
  29. id: stagesListContainer
  30. spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
  31. anchors
  32. {
  33. horizontalCenter: parent.horizontalCenter
  34. verticalCenter: parent.verticalCenter
  35. leftMargin: UM.Theme.getSize("default_margin").width
  36. }
  37. // The main window header is dynamically filled with all available stages
  38. Repeater
  39. {
  40. id: stagesHeader
  41. model: UM.StageModel { }
  42. delegate: Button
  43. {
  44. text: model.name.toUpperCase()
  45. checkable: true
  46. checked: UM.Controller.activeStage !== null && model.id == UM.Controller.activeStage.stageId
  47. anchors.verticalCenter: parent.verticalCenter
  48. exclusiveGroup: mainWindowHeaderMenuGroup
  49. style: UM.Theme.styles.main_window_header_tab
  50. height: UM.Theme.getSize("main_window_header_button").height
  51. iconSource: model.stage.iconSource
  52. property color overlayColor: "transparent"
  53. property string overlayIconSource: ""
  54. // This is a trick to assure the activeStage is correctly changed. It doesn't work propertly if done in the onClicked (see CURA-6028)
  55. MouseArea
  56. {
  57. anchors.fill: parent
  58. onClicked: UM.Controller.setActiveStage(model.id)
  59. }
  60. }
  61. }
  62. ExclusiveGroup { id: mainWindowHeaderMenuGroup }
  63. }
  64. // Shortcut button to quick access the Toolbox
  65. Controls2.Button
  66. {
  67. id: marketplaceButton
  68. text: catalog.i18nc("@action:button", "Marketplace")
  69. height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
  70. onClicked: Cura.Actions.browsePackages.trigger()
  71. hoverEnabled: true
  72. background: Rectangle
  73. {
  74. radius: UM.Theme.getSize("action_button_radius").width
  75. color: marketplaceButton.hovered ? UM.Theme.getColor("primary_text") : UM.Theme.getColor("main_window_header_background")
  76. border.width: UM.Theme.getSize("default_lining").width
  77. border.color: UM.Theme.getColor("primary_text")
  78. }
  79. contentItem: Label
  80. {
  81. id: label
  82. text: marketplaceButton.text
  83. color: marketplaceButton.hovered ? UM.Theme.getColor("main_window_header_background") : UM.Theme.getColor("primary_text")
  84. width: contentWidth
  85. verticalAlignment: Text.AlignVCenter
  86. renderType: Text.NativeRendering
  87. }
  88. anchors
  89. {
  90. right: accountWidget.left
  91. rightMargin: UM.Theme.getSize("default_margin").width
  92. verticalCenter: parent.verticalCenter
  93. }
  94. }
  95. AccountWidget
  96. {
  97. id: accountWidget
  98. anchors
  99. {
  100. right: parent.right
  101. rightMargin: UM.Theme.getSize("default_margin").width
  102. }
  103. }
  104. }