MainWindowHeader.qml 3.9 KB

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