Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MonitorMain.qml « MonitorStage « plugins - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5d63ac5b832b599baeb0987f7b811994f204e551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.10
import QtQuick.Controls 2.0
import UM 1.5 as UM
import Cura 1.0 as Cura

// We show a nice overlay on the 3D viewer when the current output device has no monitor view
Rectangle
{
    id: viewportOverlay

    property bool isConnected: Cura.MachineManager.activeMachineHasNetworkConnection || Cura.MachineManager.activeMachineHasCloudConnection
    property bool isNetworkConfigurable:
    {
        if(Cura.MachineManager.activeMachine === null)
        {
            return false
        }
        return Cura.MachineManager.activeMachine.supportsNetworkConnection
    }

    property bool isNetworkConfigured:
    {
        // Readability:
        var connectedTypes = [2, 3];
        var types = Cura.MachineManager.activeMachine.configuredConnectionTypes

        // Check if configured connection types includes either 2 or 3 (LAN or cloud)
        for (var i = 0; i < types.length; i++)
        {
            if (connectedTypes.indexOf(types[i]) >= 0)
            {
                return true
            }
        }
        return false
    }

    color: UM.Theme.getColor("viewport_overlay")
    anchors.fill: parent

    UM.I18nCatalog
    {
        id: catalog
        name: "cura"
    }

    // This mouse area is to prevent mouse clicks to be passed onto the scene.
    MouseArea
    {
        anchors.fill: parent
        acceptedButtons: Qt.AllButtons
        onWheel: wheel.accepted = true
    }

    // Disable dropping files into Cura when the monitor page is active
    DropArea
    {
        anchors.fill: parent
    }

    // CASE 1: CAN MONITOR & CONNECTED
    Loader
    {
        id: monitorViewComponent

        anchors.fill: parent

        height: parent.height

        property real maximumWidth: parent.width
        property real maximumHeight: parent.height

        sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem : null
    }

    // CASE 2 & 3: Empty states
    Column
    {
        anchors
        {
            top: parent.top
            topMargin: UM.Theme.getSize("monitor_empty_state_offset").height
            horizontalCenter: parent.horizontalCenter
        }
        width: UM.Theme.getSize("monitor_empty_state_size").width
        spacing: UM.Theme.getSize("default_margin").height
        visible: monitorViewComponent.sourceComponent == null

        // CASE 2: CAN MONITOR & NOT CONNECTED
        UM.Label
        {
            anchors
            {
                horizontalCenter: parent.horizontalCenter
            }
            visible: isNetworkConfigured && !isConnected
            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.")
            font: UM.Theme.getFont("medium")
            width: contentWidth
        }

        UM.Label
        {
            id: noNetworkLabel
            anchors
            {
                horizontalCenter: parent.horizontalCenter
            }
            visible: !isNetworkConfigured && isNetworkConfigurable
            text: catalog.i18nc("@info", "Please connect your printer to the network.")
            font: UM.Theme.getFont("medium")
            width: contentWidth
        }
        Item
        {
            anchors
            {
                left: noNetworkLabel.left
            }
            visible: !isNetworkConfigured && isNetworkConfigurable
            width: childrenRect.width
            height: childrenRect.height

            UM.ColorImage
            {
                id: externalLinkIcon
                anchors.verticalCenter: parent.verticalCenter
                color: UM.Theme.getColor("text_link")
                source: UM.Theme.getIcon("LinkExternal")
                width: UM.Theme.getSize("icon_indicator").width
                height: UM.Theme.getSize("icon_indicator").height
            }
            UM.Label
            {
                id: manageQueueText
                anchors
                {
                    left: externalLinkIcon.right
                    leftMargin: UM.Theme.getSize("narrow_margin").width
                    verticalCenter: externalLinkIcon.verticalCenter
                }
                color: UM.Theme.getColor("text_link")
                font: UM.Theme.getFont("medium")
                text: catalog.i18nc("@label link to technical assistance", "View user manuals online")
            }
            MouseArea
            {
                anchors.fill: parent
                hoverEnabled: true
                onClicked: Qt.openUrlExternally("https://ultimaker.com/in/cura/troubleshooting/network?utm_source=cura&utm_medium=software&utm_campaign=monitor-not-connected")
                onEntered: manageQueueText.font.underline = true
                onExited: manageQueueText.font.underline = false
            }
        }
        UM.Label
        {
            id: noConnectionLabel
            anchors.horizontalCenter: parent.horizontalCenter
            visible: !isNetworkConfigurable
            text: catalog.i18nc("@info", "In order to monitor your print from Cura, please connect the printer.")
            font: UM.Theme.getFont("medium")
            wrapMode: Text.WordWrap
            width: contentWidth
        }
    }
}