-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCuraBlender.qml
318 lines (251 loc) · 11.8 KB
/
CuraBlender.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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
// Imports the standard GUI elements from QTQuick.
import QtQuick 6.0
import QtQuick.Controls 6.0
// Imports the Uranium GUI elements, which are themed for Cura.
import UM 1.6 as UM
// Imports the Cura GUI elements.
import Cura 1.7 as Cura
// Dialog from Uranium.
UM.Dialog
{
// Everything needs an id to be adressed elsewhere in the file.
id: base
// The title of the window.
title: catalog.i18nc("@title:window", "CuraBlender Settings")
// We don't want the dialog to block input in the main window.
modality: Qt.NonModal
// Setting the dimensions of the dialog window and prohibiting resizing.
width: minimumWidth
minimumWidth: 350
height: minimumHeight
minimumHeight: 250
// Main component. Contains functions and smaller components like buttons and checkboxes.
Item
{
id: settings
width: base.width
height: base.height
UM.I18nCatalog { id: catalog; name: "cura"}
readonly property string stlImportType: "stl"
readonly property string objImportType: "obj"
readonly property string x3dImportType: "x3d"
readonly property string plyImportType: "ply"
// Gets the first state of the import type. Calls getImportType function and loads the attribute from the settings file.
property var currentImportType: UM.Preferences.getValue("cura_blender/file_extension")
// Updates the view every time the currentImportType changes.
// Only one file extension may be active at the same time.
onCurrentImportTypeChanged:
{
var type = currentImportType
// Sets checked state of import type buttons.
stlButton.checked = type === stlImportType
objButton.checked = type === objImportType
x3dButton.checked = type === x3dImportType
plyButton.checked = type === plyImportType
}
// Label above the import type selection.
Label
{
id: importTypeLabel
anchors.left: parent.left
anchors.top: parent.top
anchors.topMargin: UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("setting").height
// The actual text.
text: catalog.i18nc("@label", "Select Import Type")
font: UM.Theme.getFont("medium_bold")
color: UM.Theme.getColor("text")
}
// Size of the import type image buttons
property int buttonSize: Math.round(UM.Theme.getSize("button").width * 0.75)
// Sets import type to 'stl' button.
Button
{
id: stlButton
anchors.left: parent.left
anchors.top: importTypeLabel.bottom
property bool needBorder: true
checkable: true
autoExclusive: true
flat: true
// The path to the icon.
icon.source: "images/stl_icon.svg"
icon.width: settings.buttonSize
icon.height: settings.buttonSize
// Otherwise the text when holding the mouse over the icon would hide under the other icons.
z: 4
// Sets the current import type to 'stl' and unchecks every other box.
onClicked: UM.Preferences.setValue("cura_blender/file_extension", settings.stlImportType)
}
// Sets import type to 'obj' button.
Button
{
id: objButton
anchors.left: stlButton.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.top: importTypeLabel.bottom
property bool needBorder: true
checkable: true
autoExclusive: true
flat: true
// The path to the icon.
icon.source: "images/obj_icon.svg"
icon.width: settings.buttonSize
icon.height: settings.buttonSize
// Otherwise the text when holding the mouse over the icon would hide under the other icons.
z:3
// Sets the current import type to 'obj' and unchecks every other box.
onClicked: UM.Preferences.setValue("cura_blender/file_extension", settings.objImportType)
}
// Sets import type to 'x3d' button.
Button
{
id: x3dButton
anchors.left: objButton.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.top: importTypeLabel.bottom
property bool needBorder: true
checkable: true
autoExclusive: true
flat: true
// The path to the icon.
icon.source: "images/x3d_icon.svg"
icon.width: settings.buttonSize
icon.height: settings.buttonSize
// Otherwise the text when holding the mouse over the icon would hide under the other icons.
z: 2
// Sets the current import type to 'x3d' and unchecks every other box.
onClicked: UM.Preferences.setValue("cura_blender/file_extension", settings.x3dImportType)
}
// Sets import type to 'ply' button.
Button
{
id: plyButton
anchors.left: x3dButton.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width
anchors.top: importTypeLabel.bottom
property bool needBorder: true
checkable: true
autoExclusive: true
flat: true
// The path to the icon.
icon.source: "images/ply_icon.svg"
icon.width: settings.buttonSize
icon.height: settings.buttonSize
// Otherwise the text when holding the mouse over the icon would hide under the other icons.
z: 1
// Sets the current import type to 'ply' and unchecks every other box.
onClicked: UM.Preferences.setValue("cura_blender/file_extension", settings.plyImportType)
}
// CuraBlender logo.
Image
{
id: logoLabel
anchors.left: plyButton.right
anchors.leftMargin: UM.Theme.getSize("default_margin").width * 3
anchors.top: importTypeLabel.bottom
// The path to the logo.
source: "images/CuraBlender_logo.svg"
sourceSize.width: settings.buttonSize * 1.5
sourceSize.height: settings.buttonSize * 1.5
}
// Checkbox for live reload.
UM.CheckBox
{
id: liveReloadCheckbox
anchors.left: parent.left
anchors.top: stlButton.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").width
// The text for this checkbox.
text: catalog.i18nc("@action:checkbox","Live Reload ")
// The tooltip for this checkbox.
tooltip: catalog.i18nc("@checkbox:description", "Automatically reloads the object inside cura on change.")
// Calls getLiveReload and loads the entry state for live reload attribute.
checked: UM.Preferences.getValue("cura_blender/live_reload")
// Calls setLiveReload and sets the new state for live reload attribute.
onClicked: UM.Preferences.setValue("cura_blender/live_reload", checked)
}
// Checkbox for auto arrange on reload.
UM.CheckBox
{
id: autoArrangeOnReloadCheckbox
anchors.left: parent.left
anchors.top: liveReloadCheckbox.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").width
// The text for this checkbox.
text: catalog.i18nc("@action:checkbox","Auto Arrange on reload ")
// The tooltip for this checkbox.
tooltip: catalog.i18nc("@checkbox:description", "Auto arranges the complete build plate after 'Live Reload'.")
// Calls getAutoArrangeOnReload and loads the entry state for auto arrange on reload attribute.
checked: UM.Preferences.getValue("cura_blender/auto_arrange_on_reload")
// Calls setAutoArrangeOnReload and sets the new state for auto arrange on reload attribute.
onClicked: UM.Preferences.setValue("cura_blender/auto_arrange_on_reload", checked)
}
// Checkbox for auto scale on read.
UM.CheckBox
{
id: autoScaleOnReadCheckbox
anchors.left: liveReloadCheckbox.right
anchors.top: stlButton.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").width
// The text for this checkbox.
text: catalog.i18nc("@action:checkbox","Auto Scale on read")
// The tooltip for this checkbox.
tooltip: catalog.i18nc("@checkbox:description", "Scales object to fit the build plate.")
// Calls getAutoScaleOnRead and loads the entry state for auto scale on read attribute.
checked: UM.Preferences.getValue("cura_blender/auto_scale_on_read")
// Calls setAutoScaleOnRead and sets the new state for auto scale on read attribute.
onClicked: UM.Preferences.setValue("cura_blender/auto_scale_on_read", checked)
}
// Checkbox for show scale message.
UM.CheckBox
{
id: showScaleMessageCheckbox
anchors.left: autoArrangeOnReloadCheckbox.right
anchors.top: autoScaleOnReadCheckbox.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").width
// The text for this checkbox.
text: catalog.i18nc("@action:checkbox","Show Scale Message")
// The tooltip for this checkbox.
tooltip: catalog.i18nc("@checkbox:description", "Shows or hides the auto scale message.")
// Calls getShowScaleMessage and loads the entry state for show scale message attribute.
checked: UM.Preferences.getValue("cura_blender/show_scale_message")
// Calls setShowScaleMessage and sets the new state for show scale message attribute.
onClicked: UM.Preferences.setValue("cura_blender/show_scale_message", checked)
}
// Checkbox for show scale message.
UM.CheckBox
{
id: showCloseBlenderInstancesWarning
anchors.left: parent.left
anchors.top: autoArrangeOnReloadCheckbox.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").width
// The text for this checkbox.
text: catalog.i18nc("@action:checkbox","Warn before closing other Blender instances (Caution!)")
// The tooltip for this checkbox.
tooltip: catalog.i18nc("@checkbox:description", "Potential loss of data. Deactivate on own risk.")
// Calls getShowCloseBlenderInstancesWarning and loads the entry state for show close blender instances warning attribute.
checked: UM.Preferences.getValue("cura_blender/warn_before_closing_other_blender_instances")
// Calls setShowCloseBlenderInstancesWarning and sets the new state for show close blender instances warning attribute.
onClicked: UM.Preferences.setValue("cura_blender/warn_before_closing_other_blender_instances", checked)
}
// Help button.
Cura.SecondaryButton
{
id: helpButton
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
anchors.top: parent.top
height: UM.Theme.getSize("setting_control").height
iconSource: UM.Theme.getIcon("LinkExternal")
// The graphical representation of this object inside cura.
text: catalog.i18nc("@action:button", "Help")
// Opens the help URL with web browser.
onClicked:
{
const url = "https://github.com/awiegel/CuraBlender"
Qt.openUrlExternally(url)
}
}
}
}