SelectProjectPage.qml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. //Copyright (C) 2022 Ultimaker B.V.
  2. //Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Window 2.2
  5. import QtQuick.Controls 2.3
  6. import QtQuick.Layouts 1.1
  7. import UM 1.2 as UM
  8. import Cura 1.7 as Cura
  9. import DigitalFactory 1.0 as DF
  10. Item
  11. {
  12. id: base
  13. width: parent.width
  14. height: parent.height
  15. property bool createNewProjectButtonVisible: true
  16. anchors
  17. {
  18. top: parent.top
  19. bottom: parent.bottom
  20. left: parent.left
  21. right: parent.right
  22. margins: UM.Theme.getSize("default_margin").width
  23. }
  24. RowLayout
  25. {
  26. id: headerRow
  27. anchors
  28. {
  29. top: parent.top
  30. left: parent.left
  31. right: parent.right
  32. }
  33. height: childrenRect.height
  34. spacing: UM.Theme.getSize("default_margin").width
  35. Cura.SearchBar
  36. {
  37. id: searchBar
  38. Layout.fillWidth: true
  39. implicitHeight: createNewProjectButton.height
  40. focus: true
  41. onTextEdited: manager.projectFilter = text //Update the search filter when editing this text field.
  42. }
  43. Cura.SecondaryButton
  44. {
  45. id: createNewProjectButton
  46. text: "New Library project"
  47. visible: createNewProjectButtonVisible && manager.userAccountCanCreateNewLibraryProject && (manager.retrievingProjectsStatus == DF.RetrievalStatus.Success || manager.retrievingProjectsStatus == DF.RetrievalStatus.Failed)
  48. onClicked:
  49. {
  50. createNewProjectPopup.open()
  51. }
  52. busy: manager.creatingNewProjectStatus == DF.RetrievalStatus.InProgress
  53. }
  54. Cura.SecondaryButton
  55. {
  56. id: upgradePlanButton
  57. text: "Upgrade plan"
  58. iconSource: UM.Theme.getIcon("external_link")
  59. visible: createNewProjectButtonVisible && !manager.userAccountCanCreateNewLibraryProject && (manager.retrievingProjectsStatus == DF.RetrievalStatus.Success || manager.retrievingProjectsStatus == DF.RetrievalStatus.Failed)
  60. tooltip: "Maximum number of projects reached. Please upgrade your subscription to create more projects."
  61. onClicked: Qt.openUrlExternally("https://ultimaker.com/software/enterprise-software?utm_source=cura&utm_medium=software&utm_campaign=MaxProjLink")
  62. }
  63. }
  64. Item
  65. {
  66. id: noLibraryProjectsContainer
  67. anchors
  68. {
  69. top: parent.top
  70. bottom: parent.bottom
  71. left: parent.left
  72. right: parent.right
  73. }
  74. visible: manager.digitalFactoryProjectModel.count == 0 && (manager.retrievingProjectsStatus == DF.RetrievalStatus.Success || manager.retrievingProjectsStatus == DF.RetrievalStatus.Failed)
  75. Column
  76. {
  77. anchors.centerIn: parent
  78. spacing: UM.Theme.getSize("thin_margin").height
  79. Image
  80. {
  81. id: digitalFactoryImage
  82. anchors.horizontalCenter: parent.horizontalCenter
  83. source: searchBar.text === "" ? "../images/digital_factory.svg" : "../images/projects_not_found.svg"
  84. fillMode: Image.PreserveAspectFit
  85. width: parent.width - 2 * UM.Theme.getSize("thick_margin").width
  86. }
  87. Label
  88. {
  89. id: noLibraryProjectsLabel
  90. anchors.horizontalCenter: parent.horizontalCenter
  91. text: searchBar.text === "" ? "It appears that you don't have any projects in the Library yet." : "No projects found that match the search query."
  92. font: UM.Theme.getFont("medium")
  93. color: UM.Theme.getColor("text")
  94. }
  95. Cura.TertiaryButton
  96. {
  97. id: visitDigitalLibraryButton
  98. anchors.horizontalCenter: parent.horizontalCenter
  99. text: "Visit Digital Library"
  100. onClicked: Qt.openUrlExternally(CuraApplication.ultimakerDigitalFactoryUrl + "/app/library?utm_source=cura&utm_medium=software&utm_campaign=empty-library")
  101. visible: searchBar.text === "" //Show the link to Digital Library when there are no projects in the user's Library.
  102. }
  103. }
  104. }
  105. Item
  106. {
  107. id: projectListContainer
  108. anchors
  109. {
  110. top: headerRow.bottom
  111. topMargin: UM.Theme.getSize("default_margin").height
  112. bottom: parent.bottom
  113. left: parent.left
  114. right: parent.right
  115. }
  116. visible: manager.digitalFactoryProjectModel.count > 0
  117. // Use a flickable and a column with a repeater instead of a ListView in a ScrollView, because the ScrollView cannot
  118. // have additional children (aside from the view inside it), which wouldn't allow us to add the LoadMoreProjectsCard
  119. // in it.
  120. Flickable
  121. {
  122. id: flickableView
  123. clip: true
  124. contentWidth: parent.width
  125. contentHeight: projectsListView.implicitHeight
  126. anchors.fill: parent
  127. ScrollBar.vertical: ScrollBar
  128. {
  129. // Vertical ScrollBar, styled similarly to the scrollBar in the settings panel
  130. id: verticalScrollBar
  131. visible: flickableView.contentHeight > flickableView.height
  132. background: Rectangle
  133. {
  134. implicitWidth: UM.Theme.getSize("scrollbar").width
  135. radius: Math.round(implicitWidth / 2)
  136. color: UM.Theme.getColor("scrollbar_background")
  137. }
  138. contentItem: Rectangle
  139. {
  140. id: scrollViewHandle
  141. implicitWidth: UM.Theme.getSize("scrollbar").width
  142. radius: Math.round(implicitWidth / 2)
  143. color: verticalScrollBar.pressed ? UM.Theme.getColor("scrollbar_handle_down") : verticalScrollBar.hovered ? UM.Theme.getColor("scrollbar_handle_hover") : UM.Theme.getColor("scrollbar_handle")
  144. Behavior on color { ColorAnimation { duration: 50; } }
  145. }
  146. }
  147. Column
  148. {
  149. id: projectsListView
  150. width: verticalScrollBar.visible ? parent.width - verticalScrollBar.width - UM.Theme.getSize("default_margin").width : parent.width
  151. anchors.top: parent.top
  152. spacing: UM.Theme.getSize("narrow_margin").width
  153. Repeater
  154. {
  155. model: manager.digitalFactoryProjectModel
  156. delegate: ProjectSummaryCard
  157. {
  158. id: projectSummaryCard
  159. imageSource: model.thumbnailUrl || "../images/placeholder.svg"
  160. projectNameText: model.displayName
  161. projectUsernameText: model.username
  162. projectLastUpdatedText: "Last updated: " + model.lastUpdated
  163. onClicked:
  164. {
  165. manager.selectedProjectIndex = index
  166. }
  167. }
  168. }
  169. LoadMoreProjectsCard
  170. {
  171. id: loadMoreProjectsCard
  172. height: UM.Theme.getSize("card_icon").height
  173. width: parent.width
  174. visible: manager.digitalFactoryProjectModel.count > 0
  175. hasMoreProjectsToLoad: manager.hasMoreProjectsToLoad
  176. onClicked:
  177. {
  178. manager.loadMoreProjects()
  179. }
  180. }
  181. }
  182. }
  183. }
  184. CreateNewProjectPopup
  185. {
  186. id: createNewProjectPopup
  187. width: 400 * screenScaleFactor
  188. height: 220 * screenScaleFactor
  189. x: Math.round((parent.width - width) / 2)
  190. y: Math.round((parent.height - height) / 2)
  191. }
  192. }