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

AddCloudPrintersView.qml « WelcomePages « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0b94d21fae107bdeb649d52916edfd17bf0e83d1 (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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3

import UM 1.5 as UM
import Cura 1.7 as Cura


//
// This component gets activated when the user presses the "Add cloud printers" button from the "Add a Printer" page.
// It contains a busy indicator that remains active until the user logs in and adds a cloud printer in his/her account.
// Once a cloud printer is added in digitalfactory.ultimaker.com, Cura discovers it (in a time window of 30 sec) and displays
// the newly added printers in this page.
//
Item
{
    UM.I18nCatalog { id: catalog; name: "cura" }

    property bool searchingForCloudPrinters: true
    property var discoveredCloudPrintersModel: CuraApplication.getDiscoveredCloudPrintersModel()

    // The area where either the discoveredCloudPrintersList or the busyIndicator will be displayed
    Item
    {
        id: cloudPrintersContent
        width: parent.width
        height: parent.height
        anchors
        {
            top: parent.top
            left: parent.left
            leftMargin: UM.Theme.getSize("default_margin").width
            right: parent.right
            bottom: finishButton.top
            bottomMargin: UM.Theme.getSize("default_margin").height
        }

        Label
        {
            id: titleLabel
            anchors.top: parent.top
            anchors.horizontalCenter: parent.horizontalCenter
            horizontalAlignment: Text.AlignHCenter
            text: catalog.i18nc("@label", "Add a Cloud printer")
            color: UM.Theme.getColor("primary_button")
            font: UM.Theme.getFont("huge")
            renderType: Text.NativeRendering
        }

        // Component that contains a busy indicator and a message, while it waits for Cura to discover a cloud printer
        Item
        {
            id: waitingContent
            width: parent.width
            height: childrenRect.height
            anchors.verticalCenter: parent.verticalCenter
            anchors.horizontalCenter: parent.horizontalCenter
            BusyIndicator
            {
                id: waitingIndicator
                anchors.horizontalCenter: parent.horizontalCenter
                running: searchingForCloudPrinters
                palette.dark: UM.Theme.getColor("text")
            }
            Label
            {
                id: waitingLabel
                anchors.top: waitingIndicator.bottom
                anchors.horizontalCenter: parent.horizontalCenter
                horizontalAlignment: Text.AlignHCenter
                text: catalog.i18nc("@label", "Waiting for Cloud response")
                font: UM.Theme.getFont("large")
                renderType: Text.NativeRendering
                color: UM.Theme.getColor("text")
            }
            Label
            {
                id: noPrintersFoundLabel
                anchors.top: waitingLabel.bottom
                anchors.topMargin: 2 * UM.Theme.getSize("wide_margin").height
                anchors.horizontalCenter: parent.horizontalCenter
                horizontalAlignment: Text.AlignHCenter
                text: catalog.i18nc("@label", "No printers found in your account?")
                font: UM.Theme.getFont("medium")
                color: UM.Theme.getColor("text")
            }
            Label
            {
                text: "Sign in with a different account"
                anchors.top: noPrintersFoundLabel.bottom
                anchors.horizontalCenter: parent.horizontalCenter
                font: UM.Theme.getFont("medium")
                color: UM.Theme.getColor("text_link")
                MouseArea {
                    anchors.fill: parent;
                    onClicked: Cura.API.account.login(true)
                    hoverEnabled: true
                    onEntered:
                    {
                        parent.font.underline = true
                    }
                    onExited:
                    {
                        parent.font.underline = false
                    }
                }
            }
            visible: discoveredCloudPrintersModel.count == 0
        }

        // Label displayed when a new cloud printer is discovered
        Label
        {
            anchors.top: titleLabel.bottom
            anchors.topMargin: 2 * UM.Theme.getSize("default_margin").height
            id: cloudPrintersAddedTitle
            font: UM.Theme.getFont("medium")
            text: catalog.i18nc("@label", "The following printers in your account have been added in Cura:")
            height: contentHeight + 2 * UM.Theme.getSize("default_margin").height
            visible: discoveredCloudPrintersModel.count > 0
            color: UM.Theme.getColor("text")
        }

        // The scrollView that contains the list of newly discovered Ultimaker Cloud printers. Visible only when
        // there is at least a new cloud printer.
        ListView
        {
            id: discoveredCloudPrintersList
            anchors
            {
                top: cloudPrintersAddedTitle.bottom
                topMargin: UM.Theme.getSize("default_margin").height
                left: parent.left
                leftMargin: UM.Theme.getSize("default_margin").width
                right: parent.right
                bottom: parent.bottom
            }

            ScrollBar.vertical: UM.ScrollBar {}
            clip : true
            visible: discoveredCloudPrintersModel.count > 0
            spacing: UM.Theme.getSize("wide_margin").height

            model: discoveredCloudPrintersModel
            delegate: Item
            {
                width: discoveredCloudPrintersList.width
                height: contentColumn.height

                Column
                {
                    id: contentColumn
                    Label
                    {
                        id: cloudPrinterNameLabel
                        leftPadding: UM.Theme.getSize("default_margin").width
                        text: model.name ? model.name : ""
                        font: UM.Theme.getFont("large_bold")
                        color: UM.Theme.getColor("text")
                        elide: Text.ElideRight
                    }
                    Label
                    {
                        id: cloudPrinterTypeLabel
                        leftPadding: 2 * UM.Theme.getSize("default_margin").width
                        topPadding: UM.Theme.getSize("thin_margin").height
                        text: {"Type: " + model.machine_type}
                        font: UM.Theme.getFont("medium")
                        color: UM.Theme.getColor("text")
                        elide: Text.ElideRight
                    }
                    Label
                    {
                        id: cloudPrinterFirmwareVersionLabel
                        leftPadding: 2 * UM.Theme.getSize("default_margin").width
                        text: {"Firmware version: " + model.firmware_version}
                        font: UM.Theme.getFont("medium")
                        color: UM.Theme.getColor("text")
                        elide: Text.ElideRight
                    }
                }
            }
        }
    }

    Cura.SecondaryButton
    {
        id: backButton
        anchors.left: parent.left
        anchors.bottom: parent.bottom
        text: catalog.i18nc("@button", "Add printer manually")
        onClicked:
        {
            discoveredCloudPrintersModel.clear()
            base.showPreviousPage()
        }
        visible: discoveredCloudPrintersModel.count == 0
    }

    Cura.PrimaryButton
    {
        id: finishButton
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        text: base.currentItem.next_page_button_text
        onClicked:
        {
            discoveredCloudPrintersModel.clear()
            base.showNextPage()
        }

        enabled: !waitingContent.visible
    }
}