SelectProjectPage.qml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. UM.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. }
  94. Cura.TertiaryButton
  95. {
  96. id: visitDigitalLibraryButton
  97. anchors.horizontalCenter: parent.horizontalCenter
  98. text: "Visit Digital Library"
  99. onClicked: Qt.openUrlExternally(CuraApplication.ultimakerDigitalFactoryUrl + "/app/library?utm_source=cura&utm_medium=software&utm_campaign=empty-library")
  100. visible: searchBar.text === "" //Show the link to Digital Library when there are no projects in the user's Library.
  101. }
  102. }
  103. }
  104. Item
  105. {
  106. id: projectListContainer
  107. anchors
  108. {
  109. top: headerRow.bottom
  110. topMargin: UM.Theme.getSize("default_margin").height
  111. bottom: parent.bottom
  112. left: parent.left
  113. right: parent.right
  114. }
  115. visible: manager.digitalFactoryProjectModel.count > 0
  116. // Use a flickable and a column with a repeater instead of a ListView in a ScrollView, because the ScrollView cannot
  117. // have additional children (aside from the view inside it), which wouldn't allow us to add the LoadMoreProjectsCard
  118. // in it.
  119. Flickable
  120. {
  121. id: flickableView
  122. clip: true
  123. contentWidth: parent.width
  124. contentHeight: projectsListView.implicitHeight
  125. anchors.fill: parent
  126. ScrollBar.vertical: UM.ScrollBar { id: verticalScrollBar }
  127. Column
  128. {
  129. id: projectsListView
  130. width: verticalScrollBar.visible ? parent.width - verticalScrollBar.width - UM.Theme.getSize("default_margin").width : parent.width
  131. anchors.top: parent.top
  132. spacing: UM.Theme.getSize("narrow_margin").width
  133. Repeater
  134. {
  135. model: manager.digitalFactoryProjectModel
  136. delegate: ProjectSummaryCard
  137. {
  138. id: projectSummaryCard
  139. imageSource: model.thumbnailUrl || "../images/placeholder.svg"
  140. projectNameText: model.displayName
  141. projectUsernameText: model.username
  142. projectLastUpdatedText: "Last updated: " + model.lastUpdated
  143. onClicked:
  144. {
  145. manager.selectedProjectIndex = index
  146. }
  147. }
  148. }
  149. LoadMoreProjectsCard
  150. {
  151. id: loadMoreProjectsCard
  152. height: UM.Theme.getSize("card_icon").height
  153. width: parent.width
  154. visible: manager.digitalFactoryProjectModel.count > 0
  155. hasMoreProjectsToLoad: manager.hasMoreProjectsToLoad
  156. onClicked:
  157. {
  158. manager.loadMoreProjects()
  159. }
  160. }
  161. }
  162. }
  163. }
  164. CreateNewProjectPopup
  165. {
  166. id: createNewProjectPopup
  167. width: 400 * screenScaleFactor
  168. height: 220 * screenScaleFactor
  169. x: Math.round((parent.width - width) / 2)
  170. y: Math.round((parent.height - height) / 2)
  171. }
  172. }