Marketplace.qml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.15
  4. import QtQuick.Controls 2.15
  5. import QtQuick.Layouts 1.15
  6. import QtQuick.Window 2.2
  7. import UM 1.2 as UM
  8. import Cura 1.6 as Cura
  9. Window
  10. {
  11. id: marketplaceDialog
  12. property variant catalog: UM.I18nCatalog { name: "cura" }
  13. signal searchStringChanged(string new_search)
  14. minimumWidth: UM.Theme.getSize("modal_window_minimum").width
  15. minimumHeight: UM.Theme.getSize("modal_window_minimum").height
  16. width: minimumWidth
  17. height: minimumHeight
  18. // Set and unset the content. No need to keep things in memory if it's not visible.
  19. onVisibleChanged: content.source = visible ? "Plugins.qml" : ""
  20. Connections
  21. {
  22. target: Cura.API.account
  23. function onLoginStateChanged()
  24. {
  25. close();
  26. }
  27. }
  28. title: "Marketplace" //Seen by Ultimaker as a brand name, so this doesn't get translated.
  29. modality: Qt.NonModal
  30. // Background color
  31. Rectangle
  32. {
  33. anchors.fill: parent
  34. anchors.topMargin: UM.Theme.getSize("default_margin").height
  35. color: UM.Theme.getColor("main_background")
  36. ColumnLayout
  37. {
  38. anchors.fill: parent
  39. spacing: UM.Theme.getSize("default_margin").height
  40. OnboardBanner
  41. {
  42. visible: content.item && content.item.bannerVisible
  43. text: content.item && content.item.bannerText
  44. icon: content.item && content.item.bannerIcon
  45. onRemove: content.item && content.item.onRemoveBanner
  46. readMoreUrl: content.item && content.item.bannerReadMoreUrl
  47. }
  48. // Page title.
  49. Item
  50. {
  51. Layout.preferredWidth: parent.width
  52. Layout.preferredHeight: childrenRect.height
  53. Label
  54. {
  55. id: pageTitle
  56. anchors
  57. {
  58. left: parent.left
  59. leftMargin: UM.Theme.getSize("default_margin").width
  60. right: parent.right
  61. rightMargin: UM.Theme.getSize("default_margin").width
  62. }
  63. font: UM.Theme.getFont("large")
  64. color: UM.Theme.getColor("text")
  65. text: content.item ? content.item.pageTitle: catalog.i18nc("@title", "Loading...")
  66. }
  67. }
  68. // Search & Top-Level Tabs
  69. Item
  70. {
  71. Layout.preferredHeight: childrenRect.height
  72. Layout.preferredWidth: parent.width - 2 * UM.Theme.getSize("thin_margin").width
  73. RowLayout
  74. {
  75. width: parent.width
  76. height: UM.Theme.getSize("button_icon").height + UM.Theme.getSize("default_margin").height
  77. spacing: UM.Theme.getSize("thin_margin").width
  78. Rectangle
  79. {
  80. color: "transparent"
  81. Layout.preferredHeight: parent.height
  82. Layout.preferredWidth: searchBar.visible ? UM.Theme.getSize("thin_margin").width : 0
  83. Layout.fillWidth: ! searchBar.visible
  84. }
  85. Cura.SearchBar
  86. {
  87. id: searchBar
  88. Layout.preferredHeight: UM.Theme.getSize("button_icon").height
  89. Layout.fillWidth: true
  90. onTextEdited: searchStringChanged(text)
  91. }
  92. // Page selection.
  93. TabBar
  94. {
  95. id: pageSelectionTabBar
  96. anchors.right: parent.right
  97. height: UM.Theme.getSize("button_icon").height
  98. spacing: 0
  99. background: Rectangle { color: "transparent" }
  100. PackageTypeTab
  101. {
  102. id: pluginTabText
  103. width: implicitWidth
  104. text: catalog.i18nc("@button", "Plugins")
  105. onClicked:
  106. {
  107. searchBar.text = ""
  108. searchBar.visible = true
  109. content.source = "Plugins.qml"
  110. }
  111. }
  112. PackageTypeTab
  113. {
  114. id: materialsTabText
  115. width: implicitWidth
  116. text: catalog.i18nc("@button", "Materials")
  117. onClicked:
  118. {
  119. searchBar.text = ""
  120. searchBar.visible = true
  121. content.source = "Materials.qml"
  122. }
  123. }
  124. ManagePackagesButton
  125. {
  126. onClicked: content.source = "ManagedPackages.qml"
  127. }
  128. }
  129. TextMetrics
  130. {
  131. id: pluginTabTextMetrics
  132. text: pluginTabText.text
  133. font: pluginTabText.font
  134. }
  135. TextMetrics
  136. {
  137. id: materialsTabTextMetrics
  138. text: materialsTabText.text
  139. font: materialsTabText.font
  140. }
  141. }
  142. }
  143. Cura.TertiaryButton
  144. {
  145. text: catalog.i18nc("@info", "Search in the browser")
  146. iconSource: UM.Theme.getIcon("LinkExternal")
  147. isIconOnRightSide: true
  148. font: UM.Theme.getFont("default")
  149. onClicked: content.item && Qt.openUrlExternally(content.item.searchInBrowserUrl)
  150. }
  151. // Page contents.
  152. Rectangle
  153. {
  154. Layout.preferredWidth: parent.width
  155. Layout.fillHeight: true
  156. color: UM.Theme.getColor("detail_background")
  157. // Page contents.
  158. Loader
  159. {
  160. id: content
  161. anchors.fill: parent
  162. anchors.margins: UM.Theme.getSize("default_margin").width
  163. source: "Plugins.qml"
  164. Connections
  165. {
  166. target: content
  167. function onLoaded()
  168. {
  169. pageTitle.text = content.item.pageTitle
  170. searchStringChanged.connect(handleSearchStringChanged)
  171. }
  172. function handleSearchStringChanged(new_search)
  173. {
  174. content.item.model.searchString = new_search
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }