Update materials view preference menu to QtControls 2

CURA-8684
This commit is contained in:
casper 2022-01-24 23:28:25 +01:00
parent 6dc535063b
commit b47c7c9395

View file

@ -1,8 +1,9 @@
// Copyright (c) 2017 Ultimaker B.V. // Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher. // Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 1.4 import QtQuick.Controls 2.1
import QtQuick.Controls 1.4 as OldControls
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import UM 1.2 as UM import UM 1.2 as UM
@ -10,7 +11,7 @@ import Cura 1.0 as Cura
import ".." // Access to ReadOnlyTextArea.qml import ".." // Access to ReadOnlyTextArea.qml
TabView OldControls.TabView
{ {
id: base id: base
@ -67,13 +68,13 @@ TabView
} }
} }
Tab OldControls.Tab
{ {
title: catalog.i18nc("@title", "Information") title: catalog.i18nc("@title", "Information")
anchors.margins: UM.Theme.getSize("default_margin").width anchors.margins: UM.Theme.getSize("default_margin").width
ScrollView OldControls.ScrollView
{ {
id: scrollView id: scrollView
anchors.fill: parent anchors.fill: parent
@ -262,13 +263,25 @@ TabView
id: spoolCostSpinBox id: spoolCostSpinBox
width: scrollView.columnWidth width: scrollView.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_cost") value: base.getMaterialPreferenceValue(properties.guid, "spool_cost")
prefix: base.currency + " " to: 100000000
decimals: 2 editable: true
maximumValue: 100000000
property int decimals: 2
valueFromText: function(text) {
// remove all non-number tokens from input string so value can be parsed correctly
var value = Number(text.replace(/[^0-9.-]+/g, ""));
var precision = Math.pow(10, spoolCostSpinBox.decimals);
return Math.round(value * precision) / precision;
}
textFromValue: function(value) {
return base.currency + " " + value.toFixed(spoolCostSpinBox.decimals)
}
onValueChanged: onValueChanged:
{ {
base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value)) base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value, decimals))
updateCostPerMeter() updateCostPerMeter()
} }
} }
@ -279,10 +292,19 @@ TabView
id: spoolWeightSpinBox id: spoolWeightSpinBox
width: scrollView.columnWidth width: scrollView.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight")) value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
suffix: " g"
stepSize: 100 stepSize: 100
decimals: 0 to: 10000
maximumValue: 10000 editable: true
valueFromText: function(text, locale) {
// remove all non-number tokens from input string so value can be parsed correctly
var value = Number(text.replace(/[^0-9.-]+/g, ""));
return Math.round(value);
}
textFromValue: function(value, locale) {
return value + " g"
}
onValueChanged: onValueChanged:
{ {
@ -369,7 +391,7 @@ TabView
} }
} }
Tab OldControls.Tab
{ {
title: catalog.i18nc("@label", "Print settings") title: catalog.i18nc("@label", "Print settings")
anchors anchors
@ -380,7 +402,7 @@ TabView
rightMargin: 0 rightMargin: 0
} }
ScrollView OldControls.ScrollView
{ {
anchors.fill: parent; anchors.fill: parent;