MonitorMain.qml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // Copyright (c) 2018 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.3 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. 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. color: UM.Theme.getColor("monitor_text_primary")
  87. wrapMode: Text.WordWrap
  88. lineHeight: UM.Theme.getSize("monitor_text_line_large").height
  89. lineHeightMode: Text.FixedHeight
  90. width: contentWidth
  91. }
  92. Label
  93. {
  94. id: noNetworkLabel
  95. anchors
  96. {
  97. horizontalCenter: parent.horizontalCenter
  98. }
  99. visible: !isNetworkConfigured && isNetworkConfigurable
  100. text: catalog.i18nc("@info", "Please connect your printer to the network.")
  101. font: UM.Theme.getFont("medium")
  102. color: UM.Theme.getColor("monitor_text_primary")
  103. wrapMode: Text.WordWrap
  104. width: contentWidth
  105. lineHeight: UM.Theme.getSize("monitor_text_line_large").height
  106. lineHeightMode: Text.FixedHeight
  107. }
  108. Item
  109. {
  110. anchors
  111. {
  112. left: noNetworkLabel.left
  113. }
  114. visible: !isNetworkConfigured && isNetworkConfigurable
  115. height: UM.Theme.getSize("monitor_text_line").height
  116. width: childrenRect.width
  117. UM.RecolorImage
  118. {
  119. id: externalLinkIcon
  120. anchors.verticalCenter: parent.verticalCenter
  121. color: UM.Theme.getColor("text_link")
  122. source: UM.Theme.getIcon("external_link")
  123. width: UM.Theme.getSize("monitor_external_link_icon").width
  124. height: UM.Theme.getSize("monitor_external_link_icon").height
  125. }
  126. Label
  127. {
  128. id: manageQueueText
  129. anchors
  130. {
  131. left: externalLinkIcon.right
  132. leftMargin: UM.Theme.getSize("narrow_margin").width
  133. verticalCenter: externalLinkIcon.verticalCenter
  134. }
  135. color: UM.Theme.getColor("text_link")
  136. font: UM.Theme.getFont("medium")
  137. text: catalog.i18nc("@label link to technical assistance", "View user manuals online")
  138. renderType: Text.NativeRendering
  139. }
  140. MouseArea
  141. {
  142. anchors.fill: parent
  143. hoverEnabled: true
  144. onClicked: Qt.openUrlExternally("https://ultimaker.com/en/resources/manuals/ultimaker-3d-printers")
  145. onEntered: manageQueueText.font.underline = true
  146. onExited: manageQueueText.font.underline = false
  147. }
  148. }
  149. }
  150. }