ToolboxHeader.qml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Toolbox is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.4
  5. import UM 1.1 as UM
  6. Item
  7. {
  8. id: header
  9. width: parent.width
  10. height: UM.Theme.getSize("toolbox_header").height
  11. Row
  12. {
  13. id: bar
  14. spacing: UM.Theme.getSize("default_margin").width
  15. height: childrenRect.height
  16. width: childrenRect.width
  17. anchors
  18. {
  19. left: parent.left
  20. leftMargin: UM.Theme.getSize("default_margin").width
  21. }
  22. ToolboxTabButton
  23. {
  24. id: pluginsTabButton
  25. text: catalog.i18nc("@title:tab", "Plugins")
  26. active: toolbox.viewCategory == "plugin" && enabled
  27. enabled: !toolbox.isDownloading && toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
  28. onClicked:
  29. {
  30. toolbox.filterModelByProp("packages", "type", "plugin")
  31. toolbox.viewCategory = "plugin"
  32. toolbox.viewPage = "overview"
  33. }
  34. }
  35. ToolboxTabButton
  36. {
  37. id: materialsTabButton
  38. text: catalog.i18nc("@title:tab", "Materials")
  39. active: toolbox.viewCategory == "material" && enabled
  40. enabled: !toolbox.isDownloading && toolbox.viewPage != "loading" && toolbox.viewPage != "errored"
  41. onClicked:
  42. {
  43. toolbox.filterModelByProp("authors", "package_types", "material")
  44. toolbox.viewCategory = "material"
  45. toolbox.viewPage = "overview"
  46. }
  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. anchors
  56. {
  57. right: parent.right
  58. rightMargin: UM.Theme.getSize("default_margin").width
  59. }
  60. onClicked: toolbox.viewCategory = "installed"
  61. width: UM.Theme.getSize("toolbox_header_tab").width + marketplaceNotificationIcon.width - UM.Theme.getSize("default_margin").width
  62. }
  63. Rectangle
  64. {
  65. id: marketplaceNotificationIcon
  66. color: UM.Theme.getColor("notification_icon")
  67. width: (installedTabButton.height / 3) | 0
  68. height: width
  69. radius: (0.5 * width) | 0
  70. visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
  71. anchors.right: installedTabButton.right
  72. anchors.verticalCenter: installedTabButton.verticalCenter
  73. Label
  74. {
  75. id: marketplaceNotificationText
  76. anchors.centerIn: parent
  77. anchors.fill: parent
  78. text:
  79. {
  80. if(CuraApplication.getPackageManager().packagesWithUpdate.length > 9)
  81. {
  82. return "9+" // More than 2 characters don't fit.
  83. }
  84. return CuraApplication.getPackageManager().packagesWithUpdate.length
  85. }
  86. color: UM.Theme.getColor("primary_text")
  87. horizontalAlignment: Text.AlignHCenter
  88. verticalAlignment: Text.AlignVCenter
  89. font: UM.Theme.getFont("small")
  90. }
  91. }
  92. ToolboxShadow
  93. {
  94. anchors.top: bar.bottom
  95. }
  96. }