Use TabRow for material page selection

The contents of the page is done with a simple page that becomes visible or not. The easiest solution I could think of. No StackLayout necessary here.

Contributes to issue CURA-8686.
This commit is contained in:
Ghostkeeper 2022-01-25 13:57:47 +01:00
parent cfafdf878a
commit 2758957d5c
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A

View File

@ -11,7 +11,7 @@ import Cura 1.0 as Cura
import ".." // Access to ReadOnlyTextArea.qml
OldControls.TabView
Item
{
id: base
@ -68,20 +68,35 @@ OldControls.TabView
}
}
OldControls.Tab
UM.TabRow
{
title: catalog.i18nc("@title", "Information")
anchors.margins: UM.Theme.getSize("default_margin").width
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"
}
}
ScrollView
{
id: scrollView
anchors.fill: parent
id: informationPage
anchors
{
top: pageSelectorTabRow.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
ScrollBar.vertical: UM.ScrollBar
{
parent: scrollView
parent: informationPage
anchors
{
top: parent.top
@ -91,8 +106,9 @@ OldControls.TabView
}
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
clip: true
visible: pageSelectorTabRow.currentItem.activeView === "information"
property real columnWidth: (scrollView.width * 0.5 - UM.Theme.getSize("default_margin").width) | 0
property real columnWidth: (width * 0.5 - UM.Theme.getSize("default_margin").width) | 0
Flow
{
@ -136,40 +152,40 @@ OldControls.TabView
onRejected: no()
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Display Name") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Display Name") }
ReadOnlyTextField
{
id: displayNameTextField;
width: scrollView.columnWidth;
width: informationPage.columnWidth;
text: properties.name;
readOnly: !base.editingEnabled;
onEditingFinished: base.updateMaterialDisplayName(properties.name, text)
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") }
ReadOnlyTextField
{
id: brandTextField;
width: scrollView.columnWidth;
width: informationPage.columnWidth;
text: properties.brand;
readOnly: !base.editingEnabled;
onEditingFinished: base.updateMaterialBrand(properties.brand, text)
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
ReadOnlyTextField
{
id: materialTypeField;
width: scrollView.columnWidth;
width: informationPage.columnWidth;
text: properties.material;
readOnly: !base.editingEnabled;
onEditingFinished: base.updateMaterialType(properties.material, text)
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
Row
{
width: scrollView.columnWidth
width: informationPage.columnWidth
height: parent.rowHeight
spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
@ -218,11 +234,11 @@ OldControls.TabView
Label { width: parent.width; height: parent.rowHeight; font.bold: true; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Properties") }
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") }
ReadOnlySpinBox
{
id: densitySpinBox
width: scrollView.columnWidth
width: informationPage.columnWidth
value: properties.density
decimals: 2
suffix: " g/cm³"
@ -233,11 +249,11 @@ OldControls.TabView
onValueChanged: updateCostPerMeter()
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") }
ReadOnlySpinBox
{
id: diameterSpinBox
width: scrollView.columnWidth
width: informationPage.columnWidth
value: properties.diameter
decimals: 2
suffix: " mm"
@ -267,11 +283,11 @@ OldControls.TabView
onValueChanged: updateCostPerMeter()
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") }
OldControls.SpinBox
{
id: spoolCostSpinBox
width: scrollView.columnWidth
width: informationPage.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_cost")
prefix: base.currency + " "
decimals: 2
@ -284,11 +300,11 @@ OldControls.TabView
}
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") }
OldControls.SpinBox
{
id: spoolWeightSpinBox
width: scrollView.columnWidth
width: informationPage.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
suffix: " g"
stepSize: 100
@ -302,19 +318,19 @@ OldControls.TabView
}
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") }
Label
{
width: scrollView.columnWidth
width: informationPage.columnWidth
text: "~ %1 m".arg(Math.round(base.spoolLength))
verticalAlignment: Qt.AlignVCenter
height: parent.rowHeight
}
Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter") }
Label { width: informationPage.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter") }
Label
{
width: scrollView.columnWidth
width: informationPage.columnWidth
text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency)
verticalAlignment: Qt.AlignVCenter
height: parent.rowHeight
@ -323,7 +339,7 @@ OldControls.TabView
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height; visible: unlinkMaterialButton.visible }
Label
{
width: 2 * scrollView.columnWidth
width: 2 * informationPage.columnWidth
verticalAlignment: Qt.AlignVCenter
text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames)
wrapMode: Text.WordWrap
@ -348,7 +364,7 @@ OldControls.TabView
ReadOnlyTextArea
{
text: properties.description;
width: 2 * scrollView.columnWidth
width: 2 * informationPage.columnWidth
wrapMode: Text.WordWrap
readOnly: !base.editingEnabled;
@ -361,7 +377,7 @@ OldControls.TabView
ReadOnlyTextArea
{
text: properties.adhesion_info;
width: 2 * scrollView.columnWidth
width: 2 * informationPage.columnWidth
wrapMode: Text.WordWrap
readOnly: !base.editingEnabled;
@ -378,31 +394,26 @@ OldControls.TabView
base.costPerMeter = calculateCostPerMeter(spoolCostSpinBox.value);
}
}
}
OldControls.Tab
{
title: catalog.i18nc("@label", "Print settings")
anchors
{
leftMargin: UM.Theme.getSize("default_margin").width
topMargin: UM.Theme.getSize("default_margin").height
bottomMargin: UM.Theme.getSize("default_margin").height
rightMargin: 0
}
ListView
{
anchors.fill: parent
anchors
{
top: pageSelectorTabRow.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
model: UM.SettingDefinitionsModel
{
containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
visibilityHandler: Cura.MaterialSettingsVisibilityHandler { }
expanded: ["*"]
}
ScrollBar.vertical: UM.ScrollBar {}
clip: true
visible: pageSelectorTabRow.currentItem.activeView === "settings"
delegate: UM.TooltipArea
{
@ -473,7 +484,6 @@ OldControls.TabView
}
}
}
}
function calculateSpoolLength(diameter, density, spoolWeight)
{