SelectProjectPage.qml 7.1 KB

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