ToolboxHeader.qml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright (c) 2018 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. }
  50. ToolboxTabButton
  51. {
  52. id: installedTabButton
  53. text: catalog.i18nc("@title:tab", "Installed")
  54. active: toolbox.viewCategory == "installed"
  55. enabled: !toolbox.isDownloading
  56. anchors
  57. {
  58. right: parent.right
  59. rightMargin: UM.Theme.getSize("default_margin").width
  60. }
  61. onClicked: toolbox.viewCategory = "installed"
  62. width: UM.Theme.getSize("toolbox_header_tab").width + marketplaceNotificationIcon.width - UM.Theme.getSize("default_margin").width
  63. }
  64. Cura.NotificationIcon
  65. {
  66. id: marketplaceNotificationIcon
  67. visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
  68. anchors.right: installedTabButton.right
  69. anchors.verticalCenter: installedTabButton.verticalCenter
  70. labelText:
  71. {
  72. const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
  73. return itemCount > 9 ? "9+" : itemCount
  74. }
  75. }
  76. ToolboxShadow
  77. {
  78. anchors.top: bar.bottom
  79. }
  80. }