MainWindowHeader.qml 3.4 KB

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