MonitorMain.qml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.0
  5. import UM 1.5 as UM
  6. import Cura 1.0 as Cura
  7. // We show a nice overlay on the 3D viewer when the current output device has no monitor view
  8. Rectangle
  9. {
  10. id: viewportOverlay
  11. property bool isConnected: Cura.MachineManager.activeMachineHasNetworkConnection || Cura.MachineManager.activeMachineHasCloudConnection
  12. property bool isNetworkConfigurable:
  13. {
  14. if(Cura.MachineManager.activeMachine === null)
  15. {
  16. return false
  17. }
  18. return Cura.MachineManager.activeMachine.supportsNetworkConnection
  19. }
  20. property bool isNetworkConfigured:
  21. {
  22. // Readability:
  23. var connectedTypes = [2, 3];
  24. var types = Cura.MachineManager.activeMachine.configuredConnectionTypes
  25. // Check if configured connection types includes either 2 or 3 (LAN or cloud)
  26. for (var i = 0; i < types.length; i++)
  27. {
  28. if (connectedTypes.indexOf(types[i]) >= 0)
  29. {
  30. return true
  31. }
  32. }
  33. return false
  34. }
  35. color: UM.Theme.getColor("viewport_overlay")
  36. anchors.fill: parent
  37. UM.I18nCatalog
  38. {
  39. id: catalog
  40. name: "cura"
  41. }
  42. // This mouse area is to prevent mouse clicks to be passed onto the scene.
  43. MouseArea
  44. {
  45. anchors.fill: parent
  46. acceptedButtons: Qt.AllButtons
  47. onWheel: wheel.accepted = true
  48. }
  49. // Disable dropping files into Cura when the monitor page is active
  50. DropArea
  51. {
  52. anchors.fill: parent
  53. }
  54. // CASE 1: CAN MONITOR & CONNECTED
  55. Loader
  56. {
  57. id: monitorViewComponent
  58. anchors.fill: parent
  59. height: parent.height
  60. property real maximumWidth: parent.width
  61. property real maximumHeight: parent.height
  62. sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem : null
  63. }
  64. // CASE 2 & 3: Empty states
  65. Column
  66. {
  67. anchors
  68. {
  69. top: parent.top
  70. topMargin: UM.Theme.getSize("monitor_empty_state_offset").height
  71. horizontalCenter: parent.horizontalCenter
  72. }
  73. width: UM.Theme.getSize("monitor_empty_state_size").width
  74. spacing: UM.Theme.getSize("default_margin").height
  75. visible: monitorViewComponent.sourceComponent == null
  76. // CASE 2: CAN MONITOR & NOT CONNECTED
  77. UM.Label
  78. {
  79. anchors
  80. {
  81. horizontalCenter: parent.horizontalCenter
  82. }
  83. visible: isNetworkConfigured && !isConnected
  84. text: catalog.i18nc("@info", "Please make sure your printer has a connection:\n- Check if the printer is turned on.\n- Check if the printer is connected to the network.\n- Check if you are signed in to discover cloud-connected printers.")
  85. font: UM.Theme.getFont("medium")
  86. width: contentWidth
  87. }
  88. UM.Label
  89. {
  90. id: noNetworkLabel
  91. anchors
  92. {
  93. horizontalCenter: parent.horizontalCenter
  94. }
  95. visible: !isNetworkConfigured && isNetworkConfigurable
  96. text: catalog.i18nc("@info", "Please connect your printer to the network.")
  97. font: UM.Theme.getFont("medium")
  98. width: contentWidth
  99. }
  100. Item
  101. {
  102. anchors
  103. {
  104. left: noNetworkLabel.left
  105. }
  106. visible: !isNetworkConfigured && isNetworkConfigurable
  107. width: childrenRect.width
  108. height: childrenRect.height
  109. UM.ColorImage
  110. {
  111. id: externalLinkIcon
  112. anchors.verticalCenter: parent.verticalCenter
  113. color: UM.Theme.getColor("text_link")
  114. source: UM.Theme.getIcon("LinkExternal")
  115. width: UM.Theme.getSize("icon_indicator").width
  116. height: UM.Theme.getSize("icon_indicator").height
  117. }
  118. UM.Label
  119. {
  120. id: manageQueueText
  121. anchors
  122. {
  123. left: externalLinkIcon.right
  124. leftMargin: UM.Theme.getSize("narrow_margin").width
  125. verticalCenter: externalLinkIcon.verticalCenter
  126. }
  127. color: UM.Theme.getColor("text_link")
  128. font: UM.Theme.getFont("medium")
  129. text: catalog.i18nc("@label link to technical assistance", "View user manuals online")
  130. }
  131. MouseArea
  132. {
  133. anchors.fill: parent
  134. hoverEnabled: true
  135. onClicked: Qt.openUrlExternally("https://ultimaker.com/in/cura/troubleshooting/network?utm_source=cura&utm_medium=software&utm_campaign=monitor-not-connected")
  136. onEntered: manageQueueText.font.underline = true
  137. onExited: manageQueueText.font.underline = false
  138. }
  139. }
  140. UM.Label
  141. {
  142. id: noConnectionLabel
  143. anchors.horizontalCenter: parent.horizontalCenter
  144. visible: !isNetworkConfigurable
  145. text: catalog.i18nc("@info", "In order to monitor your print from Cura, please connect the printer.")
  146. font: UM.Theme.getFont("medium")
  147. wrapMode: Text.WordWrap
  148. width: contentWidth
  149. }
  150. }
  151. }