ToolboxHeader.qml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. id: webMarketplaceButtonTooltipArea
  73. width: childrenRect.width
  74. height: parent.height
  75. text: catalog.i18nc("@info:tooltip", "Go to Web Marketplace")
  76. anchors
  77. {
  78. right: parent.right
  79. rightMargin: UM.Theme.getSize("default_margin").width
  80. verticalCenter: parent.verticalCenter
  81. }
  82. acceptedButtons: Qt.LeftButton
  83. onClicked: Qt.openUrlExternally(toolbox.getWebMarketplaceUrl("plugins") + "?utm_source=cura&utm_medium=software&utm_campaign=marketplace-button")
  84. UM.RecolorImage
  85. {
  86. id: cloudMarketplaceButton
  87. source: "../../images/Shop.svg"
  88. color: UM.Theme.getColor(webMarketplaceButtonTooltipArea.containsMouse ? "primary" : "text")
  89. height: parent.height / 2
  90. width: height
  91. anchors.verticalCenter: parent.verticalCenter
  92. sourceSize.width: width
  93. sourceSize.height: height
  94. }
  95. }
  96. ToolboxShadow
  97. {
  98. anchors.top: bar.bottom
  99. }
  100. }