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

MaterialsView.qml « Materials « Preferences « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2cbadc6bd660b2b2380823f94af9899bab9c322c (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
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
// Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.7
import QtQuick.Controls 2.15
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.3

import UM 1.5 as UM
import Cura 1.0 as Cura

Item
{
    id: base

    property QtObject properties
    property var currentMaterialNode: null

    property bool editingEnabled: false
    property string currency: UM.Preferences.getValue("cura/currency") ? UM.Preferences.getValue("cura/currency") : "€"
    property string containerId: ""
    property var materialPreferenceValues: UM.Preferences.getValue("cura/material_settings") ? JSON.parse(UM.Preferences.getValue("cura/material_settings")) : {}
    property var materialManagementModel: CuraApplication.getMaterialManagementModel()

    property double spoolLength: calculateSpoolLength()
    property real costPerMeter: calculateCostPerMeter()

    signal resetSelectedMaterial()

    property bool reevaluateLinkedMaterials: false
    property string linkedMaterialNames:
    {
        if (reevaluateLinkedMaterials)
        {
            reevaluateLinkedMaterials = false;
        }
        if (!base.containerId || !base.editingEnabled || !base.currentMaterialNode)
        {
            return "";
        }
        var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.currentMaterialNode, true);
        if (linkedMaterials.length == 0)
        {
            return "";
        }
        return linkedMaterials.join(", ");
    }

    function getApproximateDiameter(diameter)
    {
        return Math.round(diameter);
    }

    // This trick makes sure to make all fields lose focus so their onEditingFinished will be triggered
    // and modified values will be saved. This can happen when a user changes a value and then closes the
    // dialog directly.
    //
    // Please note that somehow this callback is ONLY triggered when visible is false.
    onVisibleChanged:
    {
        if (!visible)
        {
            base.focus = false;
        }
    }

    Rectangle
    {
        color: UM.Theme.getColor("main_background")

        anchors
        {
            top: pageSelectorTabRow.bottom
            topMargin: -UM.Theme.getSize("default_lining").width
            left: parent.left
            right: parent.right
            bottom: parent.bottom
        }
        border.width: UM.Theme.getSize("default_lining").width
        border.color: UM.Theme.getColor("border_main")

        ScrollView
        {
            id: informationPage
            anchors
            {
                fill: parent
                topMargin: UM.Theme.getSize("thin_margin").height
                bottomMargin: UM.Theme.getSize("thin_margin").height
                leftMargin: UM.Theme.getSize("thin_margin").width
                rightMargin: UM.Theme.getSize("thin_margin").width
            }

            ScrollBar.vertical: UM.ScrollBar
            {
                id: scrollBar
                parent: informationPage.parent
                anchors
                {
                    top: parent.top
                    right: parent.right
                    bottom: parent.bottom
                }
            }
            ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
            clip: true
            visible: pageSelectorTabRow.currentItem.activeView === "information"

            property real columnWidth: Math.floor((width - scrollBar.width - UM.Theme.getSize("narrow_margin").width) / 2)
            property real rowHeight: UM.Theme.getSize("setting_control").height

            Column
            {
                width: informationPage.width
                spacing: UM.Theme.getSize("narrow_margin").height

                Cura.MessageDialog
                {
                    id: confirmDiameterChangeDialog

                    title: catalog.i18nc("@title:window", "Confirm Diameter Change")
                    text: catalog.i18nc("@label (%1 is a number)", "The new filament diameter is set to %1 mm, which is not compatible with the current extruder. Do you wish to continue?".arg(new_diameter_value))
                    standardButtons: Dialog.Yes | Dialog.No

                    property var new_diameter_value: null
                    property var old_diameter_value: null
                    property var old_approximate_diameter_value: null

                    onAccepted:
                    {
                        base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString());
                        base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value);
                        // CURA-6868 Make sure to update the extruder to user a diameter-compatible material.
                        Cura.MachineManager.updateMaterialWithVariant()
                        base.resetSelectedMaterial()
                    }

                    onRejected:
                    {
                        base.properties.diameter = old_diameter_value;
                        diameterTextField.valueText = Qt.binding(function() { return base.properties.diameter })
                    }
                }

                Row
                {
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Display Name")
                    }
                    Cura.TextField
                    {
                        id: displayNameTextField
                        width: informationPage.columnWidth
                        text: properties.name
                        enabled: base.editingEnabled
                        onEditingFinished: base.updateMaterialDisplayName(properties.name, text)
                    }
                }

                Row
                {
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Brand")
                    }
                    Cura.TextField
                    {
                        id: brandTextField
                        width: informationPage.columnWidth
                        text: properties.brand
                        enabled: base.editingEnabled
                        onEditingFinished: base.updateMaterialBrand(properties.brand, text)
                    }
                }

                Row
                {
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Material Type")
                    }
                    Cura.TextField
                    {
                        id: materialTypeField
                        width: informationPage.columnWidth
                        text: properties.material
                        enabled: base.editingEnabled
                        onEditingFinished: base.updateMaterialType(properties.material, text)
                    }
                }

                Row
                {
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color")
                    }

                    Row
                    {
                        width: informationPage.columnWidth
                        spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)

                        // color indicator square
                        Item
                        {
                            id: colorSelector

                            anchors.verticalCenter: parent.verticalCenter

                            width: colorSelectorBackground.width + 2 * UM.Theme.getSize("narrow_margin").width
                            height: colorSelectorBackground.height + 2 * UM.Theme.getSize("narrow_margin").height

                            Rectangle
                            {
                                id: colorSelectorBackground
                                color: properties.color_code
                                width: UM.Theme.getSize("icon_indicator").width
                                height: UM.Theme.getSize("icon_indicator").height
                                radius: width / 2
                                anchors.centerIn: parent
                            }

                            // open the color selection dialog on click
                            MouseArea
                            {
                                anchors.fill: parent
                                onClicked: colorDialog.open()
                                enabled: base.editingEnabled
                            }
                        }

                        // pretty color name text field
                        Cura.TextField
                        {
                            id: colorLabel;
                            width: parent.width - colorSelector.width - parent.spacing
                            text: properties.color_name;
                            enabled: base.editingEnabled
                            onEditingFinished: base.setMetaDataEntry("color_name", properties.color_name, text)
                        }

                        // popup dialog to select a new color
                        // if successful it sets the properties.color_code value to the new color
                        Cura.ColorDialog
                        {
                            id: colorDialog
                            title: catalog.i18nc("@title", "Material color picker")
                            color: properties.color_code
                            onAccepted: base.setMetaDataEntry("color_code", properties.color_code, color)
                        }
                    }
                }

                UM.Label
                {
                    width: parent.width
                    height: parent.rowHeight
                    font: UM.Theme.getFont("default_bold")
                    verticalAlignment: Qt.AlignVCenter
                    text: catalog.i18nc("@label", "Properties")
                }

                Row
                {
                    height: parent.rowHeight
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Density")
                    }

                    Cura.NumericTextFieldWithUnit
                    {
                        id: densityTextField
                        enabled: base.editingEnabled
                        valueText: properties.density
                        controlWidth: informationPage.columnWidth
                        controlHeight: informationPage.rowHeight
                        spacing: 0
                        unitText: "g/cm³"
                        decimals: 2
                        maximum: 1000

                        editingFinishedFunction: function()
                        {
                            var modified_text = valueText.replace(",", ".");
                            base.setMetaDataEntry("properties/density", properties.density, modified_text)
                        }

                        onValueTextChanged: updateCostPerMeter()
                    }
                }

                Row
                {
                    height: parent.rowHeight
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Diameter")
                    }

                    Cura.NumericTextFieldWithUnit
                    {
                        id: diameterTextField
                        enabled: base.editingEnabled
                        valueText: properties.diameter
                        controlWidth: informationPage.columnWidth
                        controlHeight: informationPage.rowHeight
                        spacing: 0
                        unitText: "mm"
                        decimals: 2
                        maximum: 1000

                        editingFinishedFunction: function()
                        {
                            // This does not use a SettingPropertyProvider, because we need to make the change to all containers
                            // which derive from the same base_file
                            var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter");
                            var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter");
                            var modified_value = valueText.replace(",", ".");
                            var new_approximate_diameter = getApproximateDiameter(modified_value);

                            if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter)
                            {
                                confirmDiameterChangeDialog.old_diameter_value = old_diameter;
                                confirmDiameterChangeDialog.new_diameter_value = modified_value;
                                confirmDiameterChangeDialog.old_approximate_diameter_value = old_approximate_diameter;

                                confirmDiameterChangeDialog.open()
                            }
                            else {
                                base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, new_approximate_diameter);
                                base.setMetaDataEntry("properties/diameter", properties.diameter, modified_value);
                            }
                        }

                        onValueTextChanged: updateCostPerMeter()
                    }
                }

                Row
                {
                    height: parent.rowHeight
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Filament Cost")
                    }

                    Cura.NumericTextFieldWithUnit
                    {
                        id: spoolCostTextField
                        valueText: base.getMaterialPreferenceValue(properties.guid, "spool_cost")
                        controlWidth: informationPage.columnWidth
                        controlHeight: informationPage.rowHeight
                        spacing: 0
                        unitText: base.currency
                        decimals: 2
                        maximum: 100000000

                        editingFinishedFunction: function()
                        {
                            var modified_text = valueText.replace(",", ".");
                            base.setMaterialPreferenceValue(properties.guid, "spool_cost", modified_text);
                        }

                        onValueTextChanged: updateCostPerMeter()
                    }
                }

                Row
                {
                    height: parent.rowHeight
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Filament weight")
                    }

                    Cura.NumericTextFieldWithUnit
                    {
                        id: spoolWeightTextField
                        valueText: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
                        controlWidth: informationPage.columnWidth
                        controlHeight: informationPage.rowHeight
                        spacing: 0
                        unitText: " g"
                        decimals: 0
                        maximum: 10000

                        editingFinishedFunction: function()
                        {
                            var modified_text = valueText.replace(",", ".")
                            base.setMaterialPreferenceValue(properties.guid, "spool_weight", modified_text)
                        }

                        onValueTextChanged: updateCostPerMeter()
                    }
                }

                Row
                {
                    height: parent.rowHeight
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Filament length")
                    }
                    UM.Label
                    {
                        width: informationPage.columnWidth
                        text: "~ %1 m".arg(Math.round(base.spoolLength))
                        height: informationPage.rowHeight
                    }
                }

                Row
                {
                    height: parent.rowHeight
                    spacing: UM.Theme.getSize("narrow_margin").width
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: catalog.i18nc("@label", "Cost per Meter")
                    }
                    UM.Label
                    {
                        height: informationPage.rowHeight
                        width: informationPage.columnWidth
                        text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency)
                    }
                }

                UM.Label
                {
                    height: parent.rowHeight
                    width: informationPage.width
                    text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames)
                    wrapMode: Text.WordWrap
                    visible: unlinkMaterialButton.visible
                }
                Cura.SecondaryButton
                {
                    id: unlinkMaterialButton
                    text: catalog.i18nc("@label", "Unlink Material")
                    visible: base.linkedMaterialNames != ""
                    onClicked:
                    {
                        Cura.ContainerManager.unlinkMaterial(base.currentMaterialNode)
                        base.reevaluateLinkedMaterials = true
                    }
                }

                UM.Label
                {
                    width: informationPage.width
                    height: parent.rowHeight
                    text: catalog.i18nc("@label", "Description")
                }
                Cura.ReadOnlyTextArea
                {
                    text: properties.description
                    width: informationPage.width - scrollBar.width
                    height: 0.4 * informationPage.width
                    wrapMode: Text.WordWrap

                    readOnly: !base.editingEnabled

                    onEditingFinished: base.setMetaDataEntry("description", properties.description, text)
                }

                UM.Label
                {
                    width: informationPage.width
                    height: parent.rowHeight
                    text: catalog.i18nc("@label", "Adhesion Information")
                }

                Cura.ReadOnlyTextArea
                {
                    text: properties.adhesion_info
                    width: informationPage.width - scrollBar.width
                    height: 0.4 * informationPage.width
                    wrapMode: Text.WordWrap
                    readOnly: !base.editingEnabled

                    onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text)
                }
            }
        }

        ListView
        {
            id: settingsPage
            visible: pageSelectorTabRow.currentItem.activeView === "settings"
            clip: true

            anchors
            {
                fill: parent
                topMargin: UM.Theme.getSize("thin_margin").height
                bottomMargin: UM.Theme.getSize("thin_margin").height
                leftMargin: UM.Theme.getSize("thin_margin").width
                rightMargin: UM.Theme.getSize("thin_margin").width
            }

            width: settingsPage.width
            spacing: UM.Theme.getSize("narrow_margin").height

            ScrollBar.vertical: UM.ScrollBar
            {
                id: settingScrollBar
                parent: settingsPage.parent
                anchors
                {
                    top: parent.top
                    right: parent.right
                    bottom: parent.bottom
                }
            }

            property real columnWidth: Math.floor((width - settingScrollBar.width - UM.Theme.getSize("narrow_margin").width) / 2)

            model: UM.SettingDefinitionsModel
            {
                containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
                visibilityHandler: Cura.MaterialSettingsVisibilityHandler { }
                expanded: ["*"]
            }

            delegate: UM.TooltipArea
            {
                width: childrenRect.width
                height: childrenRect.height

                UM.TooltipArea
                {
                    anchors.fill: parent
                    text: model.description
                }
                UM.Label
                {
                    id: label
                    width: settingsPage.columnWidth
                    height: spinBox.height + UM.Theme.getSize("default_lining").height
                    text: model.label
                    elide: Text.ElideRight
                    verticalAlignment: Qt.AlignVCenter
                }
                Cura.SpinBox
                {
                    id: spinBox
                    anchors.left: label.right
                    value:
                    {
                        // In case the setting is not in the material...
                        if (!isNaN(parseFloat(materialPropertyProvider.properties.value)))
                        {
                            return parseFloat(materialPropertyProvider.properties.value);
                        }
                        // ... we search in the variant, and if it is not there...
                        if (!isNaN(parseFloat(variantPropertyProvider.properties.value)))
                        {
                            return parseFloat(variantPropertyProvider.properties.value);
                        }
                        // ... then look in the definition container.
                        if (!isNaN(parseFloat(machinePropertyProvider.properties.value)))
                        {
                            return parseFloat(machinePropertyProvider.properties.value);
                        }
                        return 0;
                    }
                    width: settingsPage.columnWidth
                    suffix: " " + model.unit
                    to: 99999
                    decimals: model.unit == "mm" ? 2 : 0

                    onEditingFinished: materialPropertyProvider.setPropertyValue("value", value)
                }

                UM.ContainerPropertyProvider
                {
                    id: materialPropertyProvider
                    containerId: base.containerId
                    watchedProperties: [ "value" ]
                    key: model.key
                }
                UM.ContainerPropertyProvider
                {
                    id: variantPropertyProvider
                    containerId: Cura.MachineManager.activeStack.variant.id
                    watchedProperties: [ "value" ]
                    key: model.key
                }
                UM.ContainerPropertyProvider
                {
                    id: machinePropertyProvider
                    containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
                    watchedProperties: ["value"]
                    key: model.key
                }
            }
        }
    }

    UM.TabRow
    {
        id: pageSelectorTabRow
        UM.TabRowButton
        {
            text: catalog.i18nc("@title", "Information")
            property string activeView: "information" //To determine which page gets displayed.
        }
        UM.TabRowButton
        {
            text: catalog.i18nc("@label", "Print settings")
            property string activeView: "settings"
        }
    }

    function updateCostPerMeter()
    {
        var modified_weight = spoolWeightTextField.valueText.replace(",", ".")
        var modified_cost = spoolCostTextField.valueText.replace(",", ".")
        var modified_diameter = diameterTextField.valueText.replace(",", ".")
        var modified_density = densityTextField.valueText.replace(",", ".")
        base.spoolLength = calculateSpoolLength(modified_diameter, modified_density, parseInt(modified_weight));
        base.costPerMeter = calculateCostPerMeter(parseFloat(modified_cost));
    }

    function calculateSpoolLength(diameter, density, spoolWeight)
    {
        if(!diameter)
        {
            diameter = properties.diameter;
        }
        if(!density)
        {
            density = properties.density;
        }
        if(!spoolWeight)
        {
            spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"));
        }

        if (diameter == 0 || density == 0 || spoolWeight == 0)
        {
            return 0;
        }
        var area = Math.PI * Math.pow(diameter / 2, 2); // in mm2
        var volume = (spoolWeight / density); // in cm3
        return volume / area; // in m
    }

    function calculateCostPerMeter(spoolCost)
    {
        if(!spoolCost)
        {
            spoolCost = base.getMaterialPreferenceValue(properties.guid, "spool_cost");
        }

        if (spoolLength == 0)
        {
            return 0;
        }
        return spoolCost / spoolLength;
    }

    // Tiny convenience function to check if a value really changed before trying to set it.
    function setMetaDataEntry(entry_name, old_value, new_value)
    {
        if (old_value != new_value)
        {
            Cura.ContainerManager.setContainerMetaDataEntry(base.currentMaterialNode, entry_name, new_value)
            // make sure the UI properties are updated as well since we don't re-fetch the entire model here
            // When the entry_name is something like properties/diameter, we take the last part of the entry_name
            var list = entry_name.split("/")
            var key = list[list.length - 1]
            properties[key] = new_value
        }
    }

    function setMaterialPreferenceValue(material_guid, entry_name, new_value)
    {
        if(!(material_guid in materialPreferenceValues))
        {
            materialPreferenceValues[material_guid] = {};
        }
        if(entry_name in materialPreferenceValues[material_guid] && materialPreferenceValues[material_guid][entry_name] == new_value)
        {
            // value has not changed
            return;
        }
        if (entry_name in materialPreferenceValues[material_guid] && new_value.toString() == 0)
        {
            // no need to store a 0, that's the default, so remove it
            materialPreferenceValues[material_guid].delete(entry_name);
            if (!(materialPreferenceValues[material_guid]))
            {
                // remove empty map
                materialPreferenceValues.delete(material_guid);
            }
        }
        if (new_value.toString() != 0)
        {
            // store new value
            materialPreferenceValues[material_guid][entry_name] = new_value;
        }

        // store preference
        UM.Preferences.setValue("cura/material_settings", JSON.stringify(materialPreferenceValues));
    }

    function getMaterialPreferenceValue(material_guid, entry_name, default_value)
    {
        if(material_guid in materialPreferenceValues && entry_name in materialPreferenceValues[material_guid])
        {
            return materialPreferenceValues[material_guid][entry_name];
        }
        default_value = default_value | 0;
        return default_value;
    }

    // update the display name of the material
    function updateMaterialDisplayName(old_name, new_name)
    {
        // don't change when new name is the same
        if (old_name == new_name)
        {
            return
        }

        // update the values
        base.materialManagementModel.setMaterialName(base.currentMaterialNode, new_name)
        properties.name = new_name
    }

    // update the type of the material
    function updateMaterialType(old_type, new_type)
    {
        base.setMetaDataEntry("material", old_type, new_type)
        properties.material = new_type
    }

    // update the brand of the material
    function updateMaterialBrand(old_brand, new_brand)
    {
        base.setMetaDataEntry("brand", old_brand, new_brand)
        properties.brand = new_brand
    }
}