MainWindowHeader.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 "../Account"
  10. Item
  11. {
  12. id: base
  13. implicitHeight: UM.Theme.getSize("main_window_header").height
  14. implicitWidth: UM.Theme.getSize("main_window_header").width
  15. Image
  16. {
  17. id: logo
  18. anchors.left: parent.left
  19. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  20. anchors.verticalCenter: parent.verticalCenter
  21. source: UM.Theme.getImage("logo")
  22. width: UM.Theme.getSize("logo").width
  23. height: UM.Theme.getSize("logo").height
  24. fillMode: Image.PreserveAspectFit
  25. sourceSize.width: width
  26. sourceSize.height: height
  27. }
  28. Row
  29. {
  30. id: stagesListContainer
  31. spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
  32. anchors
  33. {
  34. horizontalCenter: parent.horizontalCenter
  35. verticalCenter: parent.verticalCenter
  36. leftMargin: UM.Theme.getSize("default_margin").width
  37. }
  38. // The main window header is dynamically filled with all available stages
  39. Repeater
  40. {
  41. id: stagesHeader
  42. model: UM.StageModel { }
  43. delegate: Button
  44. {
  45. id: stageSelectorButton
  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: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
  53. iconSource: model.stage.iconSource
  54. property color overlayColor: "transparent"
  55. property string overlayIconSource: ""
  56. // This id is required to find the stage buttons through Squish
  57. property string stageId: model.id
  58. // This is a trick to assure the activeStage is correctly changed. It doesn't work propertly if done in the onClicked (see CURA-6028)
  59. MouseArea
  60. {
  61. anchors.fill: parent
  62. onClicked: UM.Controller.setActiveStage(model.id)
  63. }
  64. }
  65. }
  66. ExclusiveGroup { id: mainWindowHeaderMenuGroup }
  67. }
  68. // Shortcut button to quick access the Toolbox
  69. Controls2.Button
  70. {
  71. id: marketplaceButton
  72. text: catalog.i18nc("@action:button", "Marketplace")
  73. height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
  74. onClicked: Cura.Actions.browsePackages.trigger()
  75. hoverEnabled: true
  76. background: Rectangle
  77. {
  78. radius: UM.Theme.getSize("action_button_radius").width
  79. color: marketplaceButton.hovered ? UM.Theme.getColor("primary_text") : UM.Theme.getColor("main_window_header_background")
  80. border.width: UM.Theme.getSize("default_lining").width
  81. border.color: UM.Theme.getColor("primary_text")
  82. }
  83. contentItem: Label
  84. {
  85. id: label
  86. text: marketplaceButton.text
  87. font: UM.Theme.getFont("default")
  88. color: marketplaceButton.hovered ? UM.Theme.getColor("main_window_header_background") : UM.Theme.getColor("primary_text")
  89. width: contentWidth
  90. verticalAlignment: Text.AlignVCenter
  91. renderType: Text.NativeRendering
  92. }
  93. anchors
  94. {
  95. right: accountWidget.left
  96. rightMargin: UM.Theme.getSize("default_margin").width
  97. verticalCenter: parent.verticalCenter
  98. }
  99. Cura.NotificationIcon
  100. {
  101. id: marketplaceNotificationIcon
  102. anchors
  103. {
  104. top: parent.top
  105. right: parent.right
  106. rightMargin: (-0.5 * width) | 0
  107. topMargin: (-0.5 * height) | 0
  108. }
  109. visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
  110. labelText:
  111. {
  112. const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
  113. return itemCount > 9 ? "9+" : itemCount
  114. }
  115. }
  116. }
  117. AccountWidget
  118. {
  119. id: accountWidget
  120. anchors
  121. {
  122. verticalCenter: parent.verticalCenter
  123. right: parent.right
  124. rightMargin: UM.Theme.getSize("default_margin").width
  125. }
  126. }
  127. }