SelectProjectPage.qml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.6 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 == 2 || manager.retrievingProjectsStatus == 3) // Status is succeeded or 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: Qt.resolvedUrl(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: UM.ScrollBar { id: verticalScrollBar }
  128. Column
  129. {
  130. id: projectsListView
  131. width: verticalScrollBar.visible ? parent.width - verticalScrollBar.width - UM.Theme.getSize("default_margin").width : parent.width
  132. anchors.top: parent.top
  133. spacing: UM.Theme.getSize("narrow_margin").width
  134. Repeater
  135. {
  136. model: manager.digitalFactoryProjectModel
  137. delegate: ProjectSummaryCard
  138. {
  139. id: projectSummaryCard
  140. imageSource: model.thumbnailUrl || "../images/placeholder.svg"
  141. projectNameText: model.displayName
  142. projectUsernameText: model.username
  143. projectLastUpdatedText: "Last updated: " + model.lastUpdated
  144. onClicked:
  145. {
  146. manager.selectedProjectIndex = index
  147. }
  148. }
  149. }
  150. LoadMoreProjectsCard
  151. {
  152. id: loadMoreProjectsCard
  153. height: UM.Theme.getSize("card_icon").height
  154. width: parent.width
  155. visible: manager.digitalFactoryProjectModel.count > 0
  156. hasMoreProjectsToLoad: manager.hasMoreProjectsToLoad
  157. onClicked:
  158. {
  159. manager.loadMoreProjects()
  160. }
  161. }
  162. }
  163. }
  164. }
  165. CreateNewProjectPopup
  166. {
  167. id: createNewProjectPopup
  168. width: 400 * screenScaleFactor
  169. height: 220 * screenScaleFactor
  170. x: Math.round((parent.width - width) / 2)
  171. y: Math.round((parent.height - height) / 2)
  172. }
  173. }