AddPrinterBySelectionContent.qml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. // Copyright (c) 2019 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 UM 1.3 as UM
  6. import Cura 1.1 as Cura
  7. import "../PrinterSelector"
  8. //
  9. // This component contains the content for the "Add a printer" (network) page of the welcome on-boarding process.
  10. //
  11. Item
  12. {
  13. UM.I18nCatalog { id: catalog; name: "cura" }
  14. Label
  15. {
  16. id: titleLabel
  17. anchors.top: parent.top
  18. anchors.topMargin: 40
  19. anchors.horizontalCenter: parent.horizontalCenter
  20. horizontalAlignment: Text.AlignHCenter
  21. text: catalog.i18nc("@label", "Add a printer")
  22. color: UM.Theme.getColor("primary_button")
  23. font: UM.Theme.getFont("large_bold")
  24. renderType: Text.NativeRendering
  25. }
  26. DropDownWidget
  27. {
  28. id: addNetworkPrinterDropDown
  29. anchors.top: titleLabel.bottom
  30. anchors.left: parent.left
  31. anchors.right: parent.right
  32. anchors.margins: 20
  33. title: catalog.i18nc("@label", "Add a network printer")
  34. onClicked:
  35. {
  36. if (contentShown)
  37. {
  38. addLocalPrinterDropDown.contentShown = false
  39. }
  40. }
  41. contentComponent: networkPrinterListComponent
  42. Component
  43. {
  44. id: networkPrinterListComponent
  45. Item
  46. {
  47. height: networkPrinterScrollView.height + controlsRectangle.height
  48. ScrollView
  49. {
  50. id: networkPrinterScrollView
  51. ScrollBar.horizontal.policy: ScrollBar.AsNeeded
  52. ScrollBar.vertical.policy: ScrollBar.AlwaysOn
  53. property int maxItemCountAtOnce: 8 // show at max 8 items at once, otherwise you need to scroll.
  54. height: maxItemCountAtOnce * (UM.Theme.getSize("action_button").height)
  55. clip: true
  56. ListView
  57. {
  58. id: networkPrinterListView
  59. anchors.fill: parent
  60. model: CuraApplication.getDiscoveredPrinterModel().discovered_printers
  61. visible: model.count > 0
  62. delegate: MachineSelectorButton
  63. {
  64. text: modelData.device.name
  65. anchors.left: parent.left
  66. anchors.right: parent.right
  67. anchors.rightMargin: 10
  68. outputDevice: modelData.device
  69. checked: ListView.view.currentIndex == index
  70. onClicked:
  71. {
  72. ListView.view.currentIndex = index
  73. }
  74. }
  75. }
  76. Label
  77. {
  78. id: noNetworkPrinterLabel
  79. text: catalog.i18nc("@label", "There is no printer found over your network.")
  80. renderType: Text.NativeRendering
  81. visible: !networkPrinterListView.visible
  82. }
  83. }
  84. Cura.RoundedRectangle
  85. {
  86. id: controlsRectangle
  87. anchors.left: parent.left
  88. anchors.right: parent.right
  89. anchors.top: networkPrinterScrollView.bottom
  90. anchors.bottomMargin: -border.width
  91. anchors.leftMargin: -border.width
  92. anchors.rightMargin: -border.width
  93. height: UM.Theme.getSize("message_action_button").height + UM.Theme.getSize("default_margin").height
  94. border.width: UM.Theme.getSize("default_lining").width
  95. border.color: UM.Theme.getColor("lining")
  96. color: "white"
  97. cornerSide: Cura.RoundedRectangle.Direction.Down
  98. Cura.SecondaryButton
  99. {
  100. id: refreshButton
  101. anchors.left: parent.left
  102. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  103. anchors.verticalCenter: parent.verticalCenter
  104. text: catalog.i18nc("@label", "Refresh")
  105. height: UM.Theme.getSize("message_action_button").height
  106. }
  107. Cura.SecondaryButton
  108. {
  109. id: addPrinterByIpButton
  110. anchors.left: refreshButton.right
  111. anchors.leftMargin: UM.Theme.getSize("default_margin").width
  112. anchors.verticalCenter: parent.verticalCenter
  113. text: catalog.i18nc("@label", "Add printer by IP")
  114. height: UM.Theme.getSize("message_action_button").height
  115. }
  116. Item
  117. {
  118. id: troubleshootingButton
  119. anchors.right: parent.right
  120. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  121. anchors.verticalCenter: parent.verticalCenter
  122. height: troubleshoortingLinkIcon.height
  123. width: troubleshoortingLinkIcon.width + troubleshoortingLabel.width + UM.Theme.getSize("default_margin").width
  124. UM.RecolorImage
  125. {
  126. id: troubleshoortingLinkIcon
  127. anchors.right: troubleshoortingLabel.left
  128. anchors.rightMargin: UM.Theme.getSize("default_margin").width
  129. anchors.verticalCenter: parent.verticalCenter
  130. height: troubleshoortingLabel.height
  131. width: height
  132. sourceSize.height: width
  133. color: UM.Theme.getColor("text_link")
  134. source: UM.Theme.getIcon("external_link")
  135. }
  136. Label
  137. {
  138. id: troubleshoortingLabel
  139. anchors.right: parent.right
  140. anchors.verticalCenter: parent.verticalCenter
  141. text: catalog.i18nc("@label", "Troubleshooting")
  142. font: UM.Theme.getFont("default")
  143. color: UM.Theme.getColor("text_link")
  144. linkColor: UM.Theme.getColor("text_link")
  145. renderType: Text.NativeRendering
  146. }
  147. MouseArea
  148. {
  149. anchors.fill: parent
  150. hoverEnabled: true
  151. onClicked:
  152. {
  153. // open the material URL with web browser
  154. var url = "https://ultimaker.com/incoming-links/cura/material-compatibilty" // TODO
  155. Qt.openUrlExternally(url)
  156. }
  157. onEntered:
  158. {
  159. troubleshoortingLabel.font.underline = true
  160. }
  161. onExited:
  162. {
  163. troubleshoortingLabel.font.underline = false
  164. }
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. DropDownWidget
  172. {
  173. id: addLocalPrinterDropDown
  174. anchors.top: addNetworkPrinterDropDown.bottom
  175. anchors.left: parent.left
  176. anchors.right: parent.right
  177. anchors.margins: 20
  178. title: catalog.i18nc("@label", "Add a non-network printer")
  179. onClicked:
  180. {
  181. if (contentShown)
  182. {
  183. addNetworkPrinterDropDown.contentShown = false
  184. }
  185. }
  186. contentComponent: localPrinterListComponent
  187. Component
  188. {
  189. id: localPrinterListComponent
  190. AddPrinterScrollView
  191. {
  192. id: localPrinterView
  193. ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
  194. ScrollBar.vertical.policy: ScrollBar.AlwaysOn
  195. property int maxItemCountAtOnce: 10 // show at max 10 items at once, otherwise you need to scroll.
  196. height: maxItemCountAtOnce * (UM.Theme.getSize("action_button").height)
  197. clip: true
  198. }
  199. }
  200. }
  201. Cura.PrimaryButton
  202. {
  203. id: nextButton
  204. anchors.right: parent.right
  205. anchors.bottom: parent.bottom
  206. anchors.margins: 40
  207. enabled: true // TODO
  208. text: catalog.i18nc("@button", "Next")
  209. width: 140
  210. fixedWidthMode: true
  211. onClicked: base.showNextPage()
  212. }
  213. }