ToolboxHeader.qml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Copyright (c) 2020 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 1.4
  5. import UM 1.4 as UM
  6. import Cura 1.0 as Cura
  7. Item
  8. {
  9. id: header
  10. width: parent.width
  11. height: UM.Theme.getSize("toolbox_header").height
  12. Row
  13. {
  14. id: bar
  15. spacing: UM.Theme.getSize("default_margin").width
  16. height: childrenRect.height
  17. width: childrenRect.width
  18. anchors
  19. {
  20. left: parent.left
  21. leftMargin: UM.Theme.getSize("default_margin").width
  22. }
  23. ToolboxTabButton
  24. {
  25. id: pluginsTabButton
  26. text: catalog.i18nc("@title:tab", "Plugins")
  27. active: toolbox.viewCategory == "plugin" && enabled
  28. enabled: !toolbox.isDownloading && toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
  29. onClicked:
  30. {
  31. toolbox.filterModelByProp("packages", "type", "plugin")
  32. toolbox.viewCategory = "plugin"
  33. toolbox.viewPage = "overview"
  34. }
  35. }
  36. ToolboxTabButton
  37. {
  38. id: materialsTabButton
  39. text: catalog.i18nc("@title:tab", "Materials")
  40. active: toolbox.viewCategory == "material" && enabled
  41. enabled: !toolbox.isDownloading && toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
  42. onClicked:
  43. {
  44. toolbox.filterModelByProp("authors", "package_types", "material")
  45. toolbox.viewCategory = "material"
  46. toolbox.viewPage = "overview"
  47. }
  48. }
  49. ToolboxTabButton
  50. {
  51. id: installedTabButton
  52. text: catalog.i18nc("@title:tab", "Installed")
  53. active: toolbox.viewCategory == "installed"
  54. enabled: !toolbox.isDownloading
  55. onClicked: toolbox.viewCategory = "installed"
  56. width: UM.Theme.getSize("toolbox_header_tab").width + marketplaceNotificationIcon.width - UM.Theme.getSize("default_margin").width
  57. }
  58. }
  59. Cura.NotificationIcon
  60. {
  61. id: marketplaceNotificationIcon
  62. visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
  63. anchors.right: bar.right
  64. labelText:
  65. {
  66. const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
  67. return itemCount > 9 ? "9+" : itemCount
  68. }
  69. }
  70. UM.TooltipArea
  71. {
  72. width: childrenRect.width
  73. height: parent.height
  74. text: catalog.i18nc("@info:tooltip", "Go to Web Marketplace")
  75. anchors
  76. {
  77. right: parent.right
  78. rightMargin: UM.Theme.getSize("default_margin").width
  79. verticalCenter: parent.verticalCenter
  80. }
  81. onClicked: Qt.openUrlExternally(toolbox.getWebMarketplaceUrl)
  82. UM.RecolorImage
  83. {
  84. id: cloudMarketplaceButton
  85. source: "../../images/shop.svg"
  86. color: UM.Theme.getColor("text")
  87. height: parent.height / 2
  88. width: height
  89. anchors.verticalCenter: parent.verticalCenter
  90. sourceSize.width: width
  91. sourceSize.height: height
  92. }
  93. }
  94. ToolboxShadow
  95. {
  96. anchors.top: bar.bottom
  97. }
  98. }