MainWindowHeader.qml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. Rectangle
  12. {
  13. id: base
  14. implicitHeight: UM.Theme.getSize("main_window_header").height
  15. implicitWidth: UM.Theme.getSize("main_window_header").width
  16. LinearGradient
  17. {
  18. anchors.fill: parent
  19. start: Qt.point(0, 0)
  20. end: Qt.point(parent.width, 0)
  21. gradient: Gradient
  22. {
  23. GradientStop
  24. {
  25. position: 0.0
  26. color: UM.Theme.getColor("main_window_header_background")
  27. }
  28. GradientStop
  29. {
  30. position: 0.5
  31. color: UM.Theme.getColor("main_window_header_background_gradient")
  32. }
  33. GradientStop
  34. {
  35. position: 1.0
  36. color: UM.Theme.getColor("main_window_header_background")
  37. }
  38. }
  39. }
  40. Image
  41. {
  42. id: logo
  43. anchors.left: parent.left
  44. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  45. anchors.verticalCenter: parent.verticalCenter
  46. source: UM.Theme.getImage("logo")
  47. width: UM.Theme.getSize("logo").width
  48. height: UM.Theme.getSize("logo").height
  49. sourceSize.width: width
  50. sourceSize.height: height
  51. }
  52. Row
  53. {
  54. id: stagesListContainer
  55. spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
  56. anchors
  57. {
  58. horizontalCenter: parent.horizontalCenter
  59. verticalCenter: parent.verticalCenter
  60. leftMargin: UM.Theme.getSize("default_margin").width
  61. }
  62. // The main window header is dynamically filled with all available stages
  63. Repeater
  64. {
  65. id: stagesHeader
  66. model: UM.StageModel { }
  67. delegate: Button
  68. {
  69. text: model.name.toUpperCase()
  70. checkable: true
  71. checked: model.active
  72. anchors.verticalCenter: parent.verticalCenter
  73. exclusiveGroup: mainWindowHeaderMenuGroup
  74. style: UM.Theme.styles.main_window_header_tab
  75. height: UM.Theme.getSize("main_window_header_button").height
  76. onClicked: UM.Controller.setActiveStage(model.id)
  77. iconSource: model.stage.iconSource
  78. property color overlayColor: "transparent"
  79. property string overlayIconSource: ""
  80. }
  81. }
  82. ExclusiveGroup { id: mainWindowHeaderMenuGroup }
  83. }
  84. // Shortcut button to quick access the Toolbox
  85. Controls2.Button
  86. {
  87. id: marketplaceButton
  88. text: catalog.i18nc("@action:button", "Marketplace")
  89. height: Math.round(0.5 * UM.Theme.getSize("main_window_header").height)
  90. onClicked: Cura.Actions.browsePackages.trigger()
  91. hoverEnabled: true
  92. background: Rectangle
  93. {
  94. radius: UM.Theme.getSize("action_button_radius").width
  95. color: marketplaceButton.hovered ? UM.Theme.getColor("primary_text") : UM.Theme.getColor("main_window_header_background")
  96. border.width: UM.Theme.getSize("default_lining").width
  97. border.color: UM.Theme.getColor("primary_text")
  98. }
  99. contentItem: Label
  100. {
  101. id: label
  102. text: marketplaceButton.text
  103. color: marketplaceButton.hovered ? UM.Theme.getColor("main_window_header_background") : UM.Theme.getColor("primary_text")
  104. width: contentWidth
  105. }
  106. anchors
  107. {
  108. right: accountWidget.left
  109. rightMargin: UM.Theme.getSize("default_margin").width
  110. verticalCenter: parent.verticalCenter
  111. }
  112. }
  113. AccountWidget
  114. {
  115. id: accountWidget
  116. anchors
  117. {
  118. right: parent.right
  119. rightMargin: UM.Theme.getSize("default_margin").width
  120. }
  121. }
  122. }