SelectProjectPage.qml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. // Copyright (C) 2021 Ultimaker B.V.
  2. import QtQuick 2.10
  3. import QtQuick.Window 2.2
  4. 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
  5. import QtQuick.Controls 2.3
  6. import QtQuick.Controls.Styles 1.4
  7. import UM 1.2 as UM
  8. import Cura 1.6 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 alias createNewProjectButtonVisible: createNewProjectButton.visible
  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. Label
  25. {
  26. id: selectProjectLabel
  27. text: "Select Project"
  28. font: UM.Theme.getFont("medium")
  29. color: UM.Theme.getColor("small_button_text")
  30. anchors.top: parent.top
  31. anchors.left: parent.left
  32. visible: projectListContainer.visible
  33. }
  34. Cura.SecondaryButton
  35. {
  36. id: createNewProjectButton
  37. anchors.verticalCenter: selectProjectLabel.verticalCenter
  38. anchors.right: parent.right
  39. text: "New Library project"
  40. onClicked:
  41. {
  42. createNewProjectPopup.open()
  43. }
  44. busy: manager.creatingNewProjectStatus == DF.RetrievalStatus.InProgress
  45. }
  46. Item
  47. {
  48. id: noLibraryProjectsContainer
  49. anchors
  50. {
  51. top: parent.top
  52. bottom: parent.bottom
  53. left: parent.left
  54. right: parent.right
  55. }
  56. visible: manager.digitalFactoryProjectModel.count == 0 && (manager.retrievingProjectsStatus == DF.RetrievalStatus.Success || manager.retrievingProjectsStatus == DF.RetrievalStatus.Failed)
  57. Column
  58. {
  59. anchors.centerIn: parent
  60. spacing: UM.Theme.getSize("thin_margin").height
  61. Image
  62. {
  63. id: digitalFactoryImage
  64. anchors.horizontalCenter: parent.horizontalCenter
  65. source: "../images/digital_factory.svg"
  66. fillMode: Image.PreserveAspectFit
  67. width: parent.width - 2 * UM.Theme.getSize("thick_margin").width
  68. sourceSize.width: width
  69. sourceSize.height: height
  70. }
  71. Label
  72. {
  73. id: noLibraryProjectsLabel
  74. anchors.horizontalCenter: parent.horizontalCenter
  75. text: "It appears that you don't have any projects in the Library yet."
  76. font: UM.Theme.getFont("medium")
  77. }
  78. Cura.TertiaryButton
  79. {
  80. id: visitDigitalLibraryButton
  81. anchors.horizontalCenter: parent.horizontalCenter
  82. text: "Visit Digital Library"
  83. onClicked: Qt.openUrlExternally(CuraApplication.ultimakerDigitalFactoryUrl + "/app/library")
  84. }
  85. }
  86. }
  87. Item
  88. {
  89. id: projectListContainer
  90. anchors
  91. {
  92. top: selectProjectLabel.bottom
  93. topMargin: UM.Theme.getSize("default_margin").height
  94. bottom: parent.bottom
  95. left: parent.left
  96. right: parent.right
  97. }
  98. visible: manager.digitalFactoryProjectModel.count > 0
  99. // Use a flickable and a column with a repeater instead of a ListView in a ScrollView, because the ScrollView cannot
  100. // have additional children (aside from the view inside it), which wouldn't allow us to add the LoadMoreProjectsCard
  101. // in it.
  102. Flickable
  103. {
  104. id: flickableView
  105. clip: true
  106. contentWidth: parent.width
  107. contentHeight: projectsListView.implicitHeight
  108. anchors.fill: parent
  109. ScrollBar.vertical: ScrollBar
  110. {
  111. // Vertical ScrollBar, styled similarly to the scrollBar in the settings panel
  112. id: verticalScrollBar
  113. visible: flickableView.contentHeight > flickableView.height
  114. background: Rectangle
  115. {
  116. implicitWidth: UM.Theme.getSize("scrollbar").width
  117. radius: Math.round(implicitWidth / 2)
  118. color: UM.Theme.getColor("scrollbar_background")
  119. }
  120. contentItem: Rectangle
  121. {
  122. id: scrollViewHandle
  123. implicitWidth: UM.Theme.getSize("scrollbar").width
  124. radius: Math.round(implicitWidth / 2)
  125. color: verticalScrollBar.pressed ? UM.Theme.getColor("scrollbar_handle_down") : verticalScrollBar.hovered ? UM.Theme.getColor("scrollbar_handle_hover") : UM.Theme.getColor("scrollbar_handle")
  126. Behavior on color { ColorAnimation { duration: 50; } }
  127. }
  128. }
  129. Column
  130. {
  131. id: projectsListView
  132. width: verticalScrollBar.visible ? parent.width - verticalScrollBar.width - UM.Theme.getSize("default_margin").width : parent.width
  133. anchors.top: parent.top
  134. spacing: UM.Theme.getSize("narrow_margin").width
  135. Repeater
  136. {
  137. model: manager.digitalFactoryProjectModel
  138. delegate: ProjectSummaryCard
  139. {
  140. id: projectSummaryCard
  141. imageSource: model.thumbnailUrl || "../images/placeholder.svg"
  142. projectNameText: model.displayName
  143. projectUsernameText: model.username
  144. projectLastUpdatedText: "Last updated: " + model.lastUpdated
  145. onClicked:
  146. {
  147. manager.selectedProjectIndex = index
  148. }
  149. }
  150. }
  151. LoadMoreProjectsCard
  152. {
  153. id: loadMoreProjectsCard
  154. height: UM.Theme.getSize("toolbox_thumbnail_small").height
  155. width: parent.width
  156. visible: manager.digitalFactoryProjectModel.count > 0
  157. hasMoreProjectsToLoad: manager.hasMoreProjectsToLoad
  158. onClicked:
  159. {
  160. manager.loadMoreProjects()
  161. }
  162. }
  163. }
  164. }
  165. }
  166. CreateNewProjectPopup
  167. {
  168. id: createNewProjectPopup
  169. width: 400 * screenScaleFactor
  170. height: 220 * screenScaleFactor
  171. x: Math.round((parent.width - width) / 2)
  172. y: Math.round((parent.height - height) / 2)
  173. }
  174. }