AddCloudPrintersView.qml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.Controls 2.3
  5. import QtQuick.Layouts 1.3
  6. import UM 1.5 as UM
  7. import Cura 1.7 as Cura
  8. //
  9. // This component gets activated when the user presses the "Add cloud printers" button from the "Add a Printer" page.
  10. // It contains a busy indicator that remains active until the user logs in and adds a cloud printer in his/her account.
  11. // Once a cloud printer is added in digitalfactory.ultimaker.com, Cura discovers it (in a time window of 30 sec) and displays
  12. // the newly added printers in this page.
  13. //
  14. Item
  15. {
  16. UM.I18nCatalog { id: catalog; name: "cura" }
  17. property bool searchingForCloudPrinters: true
  18. property var discoveredCloudPrintersModel: CuraApplication.getDiscoveredCloudPrintersModel()
  19. // The area where either the discoveredCloudPrintersList or the busyIndicator will be displayed
  20. Item
  21. {
  22. id: cloudPrintersContent
  23. width: parent.width
  24. height: parent.height
  25. anchors
  26. {
  27. top: parent.top
  28. left: parent.left
  29. leftMargin: UM.Theme.getSize("default_margin").width
  30. right: parent.right
  31. bottom: finishButton.top
  32. bottomMargin: UM.Theme.getSize("default_margin").height
  33. }
  34. Label
  35. {
  36. id: titleLabel
  37. anchors.top: parent.top
  38. anchors.horizontalCenter: parent.horizontalCenter
  39. horizontalAlignment: Text.AlignHCenter
  40. text: catalog.i18nc("@label", "Add a Cloud printer")
  41. color: UM.Theme.getColor("primary_button")
  42. font: UM.Theme.getFont("huge")
  43. renderType: Text.NativeRendering
  44. }
  45. // Component that contains a busy indicator and a message, while it waits for Cura to discover a cloud printer
  46. Item
  47. {
  48. id: waitingContent
  49. width: parent.width
  50. height: childrenRect.height
  51. anchors.verticalCenter: parent.verticalCenter
  52. anchors.horizontalCenter: parent.horizontalCenter
  53. BusyIndicator
  54. {
  55. id: waitingIndicator
  56. anchors.horizontalCenter: parent.horizontalCenter
  57. running: searchingForCloudPrinters
  58. palette.dark: UM.Theme.getColor("text")
  59. }
  60. Label
  61. {
  62. id: waitingLabel
  63. anchors.top: waitingIndicator.bottom
  64. anchors.horizontalCenter: parent.horizontalCenter
  65. horizontalAlignment: Text.AlignHCenter
  66. text: catalog.i18nc("@label", "Waiting for Cloud response")
  67. font: UM.Theme.getFont("large")
  68. renderType: Text.NativeRendering
  69. color: UM.Theme.getColor("text")
  70. }
  71. Label
  72. {
  73. id: noPrintersFoundLabel
  74. anchors.top: waitingLabel.bottom
  75. anchors.topMargin: 2 * UM.Theme.getSize("wide_margin").height
  76. anchors.horizontalCenter: parent.horizontalCenter
  77. horizontalAlignment: Text.AlignHCenter
  78. text: catalog.i18nc("@label", "No printers found in your account?")
  79. font: UM.Theme.getFont("medium")
  80. color: UM.Theme.getColor("text")
  81. }
  82. Label
  83. {
  84. text: "Sign in with a different account"
  85. anchors.top: noPrintersFoundLabel.bottom
  86. anchors.horizontalCenter: parent.horizontalCenter
  87. font: UM.Theme.getFont("medium")
  88. color: UM.Theme.getColor("text_link")
  89. MouseArea {
  90. anchors.fill: parent;
  91. onClicked: Cura.API.account.login(true)
  92. hoverEnabled: true
  93. onEntered:
  94. {
  95. parent.font.underline = true
  96. }
  97. onExited:
  98. {
  99. parent.font.underline = false
  100. }
  101. }
  102. }
  103. visible: discoveredCloudPrintersModel.count == 0
  104. }
  105. // Label displayed when a new cloud printer is discovered
  106. Label
  107. {
  108. anchors.top: titleLabel.bottom
  109. anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height
  110. id: cloudPrintersAddedTitle
  111. font: UM.Theme.getFont("medium")
  112. text: catalog.i18nc("@label", "The following printers in your account have been added in Cura:")
  113. height: contentHeight + 2 * UM.Theme.getSize("default_margin").height
  114. visible: discoveredCloudPrintersModel.count > 0
  115. color: UM.Theme.getColor("text")
  116. }
  117. // The scrollView that contains the list of newly discovered Ultimaker Cloud printers. Visible only when
  118. // there is at least a new cloud printer.
  119. ListView
  120. {
  121. id: discoveredCloudPrintersList
  122. anchors
  123. {
  124. top: cloudPrintersAddedTitle.bottom
  125. topMargin: UM.Theme.getSize("default_margin").height
  126. left: parent.left
  127. leftMargin: UM.Theme.getSize("default_margin").width
  128. right: parent.right
  129. bottom: parent.bottom
  130. }
  131. ScrollBar.vertical: UM.ScrollBar {}
  132. clip : true
  133. visible: discoveredCloudPrintersModel.count > 0
  134. spacing: UM.Theme.getSize("wide_margin").height
  135. model: discoveredCloudPrintersModel
  136. delegate: Item
  137. {
  138. width: discoveredCloudPrintersList.width
  139. height: contentColumn.height
  140. Column
  141. {
  142. id: contentColumn
  143. Label
  144. {
  145. id: cloudPrinterNameLabel
  146. leftPadding: UM.Theme.getSize("default_margin").width
  147. text: model.name ? model.name : ""
  148. font: UM.Theme.getFont("large_bold")
  149. color: UM.Theme.getColor("text")
  150. elide: Text.ElideRight
  151. }
  152. Label
  153. {
  154. id: cloudPrinterTypeLabel
  155. leftPadding: 2 * UM.Theme.getSize("default_margin").width
  156. topPadding: UM.Theme.getSize("thin_margin").height
  157. text: {"Type: " + model.machine_type}
  158. font: UM.Theme.getFont("medium")
  159. color: UM.Theme.getColor("text")
  160. elide: Text.ElideRight
  161. }
  162. Label
  163. {
  164. id: cloudPrinterFirmwareVersionLabel
  165. leftPadding: 2 * UM.Theme.getSize("default_margin").width
  166. text: {"Firmware version: " + model.firmware_version}
  167. font: UM.Theme.getFont("medium")
  168. color: UM.Theme.getColor("text")
  169. elide: Text.ElideRight
  170. }
  171. }
  172. }
  173. }
  174. }
  175. Cura.SecondaryButton
  176. {
  177. id: backButton
  178. anchors.left: parent.left
  179. anchors.bottom: parent.bottom
  180. text: catalog.i18nc("@button", "Add printer manually")
  181. onClicked:
  182. {
  183. discoveredCloudPrintersModel.clear()
  184. base.showPreviousPage()
  185. }
  186. visible: discoveredCloudPrintersModel.count == 0
  187. }
  188. Cura.PrimaryButton
  189. {
  190. id: finishButton
  191. anchors.right: parent.right
  192. anchors.bottom: parent.bottom
  193. text: base.currentItem.next_page_button_text
  194. onClicked:
  195. {
  196. discoveredCloudPrintersModel.clear()
  197. base.showNextPage()
  198. }
  199. enabled: !waitingContent.visible
  200. }
  201. }