AddCloudPrintersView.qml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. UM.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. }
  44. // Component that contains a busy indicator and a message, while it waits for Cura to discover a cloud printer
  45. Item
  46. {
  47. id: waitingContent
  48. width: parent.width
  49. height: childrenRect.height
  50. anchors.verticalCenter: parent.verticalCenter
  51. anchors.horizontalCenter: parent.horizontalCenter
  52. BusyIndicator
  53. {
  54. id: waitingIndicator
  55. anchors.horizontalCenter: parent.horizontalCenter
  56. running: searchingForCloudPrinters
  57. palette.dark: UM.Theme.getColor("text")
  58. }
  59. UM.Label
  60. {
  61. id: waitingLabel
  62. anchors.top: waitingIndicator.bottom
  63. anchors.horizontalCenter: parent.horizontalCenter
  64. horizontalAlignment: Text.AlignHCenter
  65. text: catalog.i18nc("@label", "Waiting for Cloud response")
  66. font: UM.Theme.getFont("large")
  67. }
  68. UM.Label
  69. {
  70. id: noPrintersFoundLabel
  71. anchors.top: waitingLabel.bottom
  72. anchors.topMargin: 2 * UM.Theme.getSize("wide_margin").height
  73. anchors.horizontalCenter: parent.horizontalCenter
  74. horizontalAlignment: Text.AlignHCenter
  75. text: catalog.i18nc("@label", "No printers found in your account?")
  76. font: UM.Theme.getFont("medium")
  77. }
  78. UM.Label
  79. {
  80. text: "Sign in with a different account"
  81. anchors.top: noPrintersFoundLabel.bottom
  82. anchors.horizontalCenter: parent.horizontalCenter
  83. font: UM.Theme.getFont("medium")
  84. color: UM.Theme.getColor("text_link")
  85. MouseArea {
  86. anchors.fill: parent;
  87. onClicked: Cura.API.account.login(true)
  88. hoverEnabled: true
  89. onEntered:
  90. {
  91. parent.font.underline = true
  92. }
  93. onExited:
  94. {
  95. parent.font.underline = false
  96. }
  97. }
  98. }
  99. visible: discoveredCloudPrintersModel.count == 0
  100. }
  101. // Label displayed when a new cloud printer is discovered
  102. UM.Label
  103. {
  104. anchors.top: titleLabel.bottom
  105. anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height
  106. id: cloudPrintersAddedTitle
  107. font: UM.Theme.getFont("medium")
  108. text: catalog.i18nc("@label", "The following printers in your account have been added in Cura:")
  109. height: contentHeight + 2 * UM.Theme.getSize("default_margin").height
  110. visible: discoveredCloudPrintersModel.count > 0
  111. }
  112. // The scrollView that contains the list of newly discovered Ultimaker Cloud printers. Visible only when
  113. // there is at least a new cloud printer.
  114. ListView
  115. {
  116. id: discoveredCloudPrintersList
  117. anchors
  118. {
  119. top: cloudPrintersAddedTitle.bottom
  120. topMargin: UM.Theme.getSize("default_margin").height
  121. left: parent.left
  122. leftMargin: UM.Theme.getSize("default_margin").width
  123. right: parent.right
  124. bottom: parent.bottom
  125. }
  126. ScrollBar.vertical: UM.ScrollBar {}
  127. clip : true
  128. visible: discoveredCloudPrintersModel.count > 0
  129. spacing: UM.Theme.getSize("wide_margin").height
  130. model: discoveredCloudPrintersModel
  131. delegate: Item
  132. {
  133. width: discoveredCloudPrintersList.width
  134. height: contentColumn.height
  135. Column
  136. {
  137. id: contentColumn
  138. UM.Label
  139. {
  140. id: cloudPrinterNameLabel
  141. leftPadding: UM.Theme.getSize("default_margin").width
  142. text: model.name ? model.name : ""
  143. font: UM.Theme.getFont("large_bold")
  144. elide: Text.ElideRight
  145. }
  146. UM.Label
  147. {
  148. id: cloudPrinterTypeLabel
  149. leftPadding: 2 * UM.Theme.getSize("default_margin").width
  150. topPadding: UM.Theme.getSize("thin_margin").height
  151. text: "Type: " + model.machine_type
  152. font: UM.Theme.getFont("medium")
  153. elide: Text.ElideRight
  154. }
  155. UM.Label
  156. {
  157. id: cloudPrinterFirmwareVersionLabel
  158. leftPadding: 2 * UM.Theme.getSize("default_margin").width
  159. text: "Firmware version: " + model.firmware_version
  160. font: UM.Theme.getFont("medium")
  161. elide: Text.ElideRight
  162. }
  163. }
  164. }
  165. }
  166. }
  167. Cura.SecondaryButton
  168. {
  169. id: backButton
  170. anchors.left: parent.left
  171. anchors.bottom: parent.bottom
  172. text: catalog.i18nc("@button", "Add printer manually")
  173. onClicked:
  174. {
  175. discoveredCloudPrintersModel.clear()
  176. base.showPreviousPage()
  177. }
  178. visible: discoveredCloudPrintersModel.count == 0
  179. }
  180. Cura.PrimaryButton
  181. {
  182. id: finishButton
  183. anchors.right: parent.right
  184. anchors.bottom: parent.bottom
  185. text: base.currentItem.next_page_button_text
  186. onClicked:
  187. {
  188. discoveredCloudPrintersModel.clear()
  189. base.showNextPage()
  190. }
  191. enabled: !waitingContent.visible
  192. }
  193. }