MainWindowHeader.qml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. import "../ApplicationSwitcher"
  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. id: stageSelectorButton
  47. text: model.name.toUpperCase()
  48. checkable: true
  49. checked: UM.Controller.activeStage !== null && model.id == UM.Controller.activeStage.stageId
  50. anchors.verticalCenter: parent.verticalCenter
  51. exclusiveGroup: mainWindowHeaderMenuGroup
  52. style: UM.Theme.styles.main_window_header_tab
  53. height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
  54. iconSource: model.stage.iconSource
  55. property color overlayColor: "transparent"
  56. property string overlayIconSource: ""
  57. // This id is required to find the stage buttons through Squish
  58. property string stageId: model.id
  59. // This is a trick to assure the activeStage is correctly changed. It doesn't work properly if done in the onClicked (see CURA-6028)
  60. MouseArea
  61. {
  62. anchors.fill: parent
  63. onClicked: UM.Controller.setActiveStage(model.id)
  64. }
  65. }
  66. }
  67. ExclusiveGroup { id: mainWindowHeaderMenuGroup }
  68. }
  69. // Shortcut button to quick access the Toolbox
  70. Controls2.Button
  71. {
  72. id: marketplaceButton
  73. text: catalog.i18nc("@action:button", "Marketplace")
  74. height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
  75. onClicked: Cura.Actions.browsePackages.trigger()
  76. hoverEnabled: true
  77. background: Rectangle
  78. {
  79. id: marketplaceButtonBorder
  80. radius: UM.Theme.getSize("action_button_radius").width
  81. color: UM.Theme.getColor("main_window_header_background")
  82. border.width: UM.Theme.getSize("default_lining").width
  83. border.color: UM.Theme.getColor("primary_text")
  84. Rectangle
  85. {
  86. id: marketplaceButtonFill
  87. anchors.fill: parent
  88. radius: parent.radius
  89. color: UM.Theme.getColor("primary_text")
  90. opacity: marketplaceButton.hovered ? 0.2 : 0
  91. Behavior on opacity { NumberAnimation { duration: 100 } }
  92. }
  93. }
  94. contentItem: Label
  95. {
  96. id: label
  97. text: marketplaceButton.text
  98. font: UM.Theme.getFont("default")
  99. color: UM.Theme.getColor("primary_text")
  100. width: contentWidth
  101. verticalAlignment: Text.AlignVCenter
  102. renderType: Text.NativeRendering
  103. }
  104. anchors
  105. {
  106. right: applicationSwitcher.left
  107. rightMargin: UM.Theme.getSize("default_margin").width
  108. verticalCenter: parent.verticalCenter
  109. }
  110. Cura.NotificationIcon
  111. {
  112. id: marketplaceNotificationIcon
  113. anchors
  114. {
  115. top: parent.top
  116. right: parent.right
  117. rightMargin: (-0.5 * width) | 0
  118. topMargin: (-0.5 * height) | 0
  119. }
  120. visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
  121. labelText:
  122. {
  123. const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
  124. return itemCount > 9 ? "9+" : itemCount
  125. }
  126. }
  127. }
  128. ApplicationSwitcher
  129. {
  130. id: applicationSwitcher
  131. anchors
  132. {
  133. verticalCenter: parent.verticalCenter
  134. right: accountWidget.left
  135. rightMargin: UM.Theme.getSize("default_margin").width
  136. }
  137. }
  138. AccountWidget
  139. {
  140. id: accountWidget
  141. anchors
  142. {
  143. verticalCenter: parent.verticalCenter
  144. right: parent.right
  145. rightMargin: UM.Theme.getSize("default_margin").width
  146. }
  147. }
  148. }