-
Notifications
You must be signed in to change notification settings - Fork 0
/
JobSpecs.qml
142 lines (128 loc) · 5.15 KB
/
JobSpecs.qml
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
// Copyright (c) 2017 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import UM 1.1 as UM
import Cura 1.0 as Cura
Item {
id: base
property bool activity: CuraApplication.platformActivity
property string fileBaseName: ""
UM.I18nCatalog { id: catalog; name:"cura"}
height: childrenRect.height
Connections
{
target: backgroundItem
onHasMesh:
{
if (base.fileBaseName == "")
{
base.fileBaseName = name;
}
}
}
onActivityChanged: {
if (activity == true && base.fileBaseName == ''){
//this only runs when you open a file from the terminal (or something that works the same way; for example when you drag a file on the icon in MacOS or use 'open with' on Windows)
base.fileBaseName = PrintInformation.baseName; //get the fileBaseName from PrintInformation.py because this saves the filebase when the file is opened using the terminal (or something alike)
PrintInformation.setBaseName(base.fileBaseName);
}
if (activity == true && base.fileBaseName != ''){
//this runs in all other cases where there is a mesh on the buildplate (activity == true). It uses the fileBaseName from the hasMesh signal
PrintInformation.setBaseName(base.fileBaseName);
}
if (activity == false){
//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.setBaseName('')
}
}
Rectangle
{
id: jobNameRow
anchors.top: parent.top
anchors.right: parent.right
height: UM.Theme.getSize("jobspecs_line").height
visible: base.activity
Item
{
width: parent.width
height: parent.height
Button
{
id: printJobPencilIcon
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
width: UM.Theme.getSize("save_button_specs_icons").width
height: UM.Theme.getSize("save_button_specs_icons").height
onClicked:
{
printJobTextfield.selectAll();
printJobTextfield.focus = true;
}
style: ButtonStyle
{
background: Item
{
UM.RecolorImage
{
width: UM.Theme.getSize("save_button_specs_icons").width;
height: UM.Theme.getSize("save_button_specs_icons").height;
sourceSize.width: width;
sourceSize.height: width;
color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene");
source: UM.Theme.getIcon("pencil");
isBorderVisible: true
}
}
}
}
TextField
{
id: printJobTextfield
anchors.right: printJobPencilIcon.left
anchors.rightMargin: Math.floor(UM.Theme.getSize("default_margin").width/2)
height: UM.Theme.getSize("jobspecs_line").height
width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50)
maximumLength: 120
property int unremovableSpacing: 5
text: PrintInformation.jobName
horizontalAlignment: TextInput.AlignRight
onTextChanged: {
PrintInformation.setJobName(text);
}
onEditingFinished: {
if (printJobTextfield.text != ''){
printJobTextfield.focus = false;
}
}
validator: RegExpValidator {
regExp: /^[^\\ \/ \*\?\|\[\]]*$/
}
style: TextFieldStyle{
//textColor: UM.Theme.getColor("setting_control_text");
//textColor: UM.Theme.getColor("text_green");
textColor: UM.Theme.getColor("text_dark_green");
font: UM.Theme.getFont("default_bold");
background: Rectangle {
opacity: 100
border.width: 0
color: UM.Theme.getColor("job_specs_background")
}
}
}
}
}
Label
{
id: boundingSpec
anchors.top: jobNameRow.bottom
anchors.right: parent.right
height: UM.Theme.getSize("jobspecs_line").height
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("small")
color: UM.Theme.getColor("text_dark_green")
text: CuraApplication.getSceneBoundingBoxString
}
}