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

JobSpecs.qml « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d2ca855e8bc6c3f6482e16bd6f2bbf9a36d2fc79 (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
// Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.15
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1

import UM 1.5 as UM
import Cura 1.0 as Cura

Item
{
    id: base

    property bool activity: CuraApplication.platformActivity
    property string fileBaseName: (PrintInformation === null) ? "" : PrintInformation.baseName

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

    width: childrenRect.width
    height: childrenRect.height

    onActivityChanged:
    {
        if (!activity)
        {
            // When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't
            // set an empty string as a jobName (which is later used for saving the file)
            PrintInformation.baseName = ""
        }
    }

    Item
    {
        id: jobNameRow
        anchors.top: parent.top
        anchors.left: parent.left
        height: UM.Theme.getSize("jobspecs_line").height

        UM.SimpleButton
        {
            id: printJobPencilIcon
            anchors.left: parent.left
            anchors.verticalCenter: parent.verticalCenter
            width: UM.Theme.getSize("save_button_specs_icons").width
            height: UM.Theme.getSize("save_button_specs_icons").height
            iconSource: UM.Theme.getIcon("Pen")
            hoverColor: UM.Theme.getColor("small_button_text_hover")
            color:  UM.Theme.getColor("small_button_text")
            onClicked:
            {
                printJobTextfield.selectAll()
                printJobTextfield.focus = true
            }
        }

        Cura.TextField
        {
            id: printJobTextfield
            anchors.left: printJobPencilIcon.right
            anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
            height: UM.Theme.getSize("jobspecs_line").height
            width: Math.max(contentWidth + UM.Theme.getSize("default_margin").width + 2, 50) // add two pixels to width to prevent inner text from shifting
            maximumLength: 120
            text: PrintInformation === null ? "" : PrintInformation.jobName
            horizontalAlignment: TextInput.AlignLeft
            onTextChanged:
            {
                if (!activeFocus)
                {
                    // Text is changed from outside, reset the cursor position.
                    cursorPosition = 0
                }
            }

            property string textBeforeEdit: ""

            onActiveFocusChanged:
            {
                if (activeFocus)
                {
                    textBeforeEdit = text
                }
            }

            onEditingFinished:
            {
                if (text != textBeforeEdit) {
                    var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text
                    PrintInformation.setJobName(new_name, true)
                }
                printJobTextfield.focus = false
                cursorPosition = 0
            }

            validator: RegularExpressionValidator {
                regularExpression: /^[^\\\/\*\?\|\[\]]*$/
            }
            color: UM.Theme.getColor("text_scene")
            background: Item {}
            selectByMouse: true
        }
    }

    UM.Label
    {
        id: boundingSpec
        anchors.top: jobNameRow.bottom
        anchors.left: parent.left

        height: UM.Theme.getSize("jobspecs_line").height
        color: UM.Theme.getColor("text_scene")
        text: CuraApplication.getSceneBoundingBoxString
    }

    Row
    {
        id: additionalComponentsRow
        anchors.top: boundingSpec.top
        anchors.bottom: boundingSpec.bottom
        anchors.left: boundingSpec.right
        anchors.leftMargin: UM.Theme.getSize("default_margin").width
    }

    Component.onCompleted: base.addAdditionalComponents("jobSpecsButton")

    Connections
    {
        target: CuraApplication
        function onAdditionalComponentsChanged(areaId) { base.addAdditionalComponents("jobSpecsButton") }
    }

    function addAdditionalComponents(areaId)
    {
        if (areaId == "jobSpecsButton")
        {
            for (var component in CuraApplication.additionalComponents["jobSpecsButton"])
            {
                CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow
            }
        }
    }
}