Fix MaterialView layout issues

Make scrollview look more in line with the scrollview on the profiles page
This commit is contained in:
fieldOfView 2017-04-30 10:28:03 +02:00
parent a1d9b1a37f
commit 577a8d0a3e

View File

@ -43,62 +43,62 @@ TabView
{ {
title: catalog.i18nc("@title","Information") title: catalog.i18nc("@title","Information")
anchors anchors.margins: UM.Theme.getSize("default_margin").width
{
leftMargin: UM.Theme.getSize("default_margin").width
topMargin: UM.Theme.getSize("default_margin").height
bottomMargin: UM.Theme.getSize("default_margin").height
rightMargin: 0
}
ScrollView ScrollView
{ {
id: scrollView
anchors.fill: parent anchors.fill: parent
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
flickableItem.flickableDirection: Flickable.VerticalFlick flickableItem.flickableDirection: Flickable.VerticalFlick
frameVisible: true
property real columnWidth: Math.floor(viewport.width * 0.5) - UM.Theme.getSize("default_margin").width
Flow Flow
{ {
id: containerGrid id: containerGrid
width: base.width; x: UM.Theme.getSize("default_margin").width
y: UM.Theme.getSize("default_lining").height
property real rowHeight: textField.height; width: base.width
property real rowHeight: textField.height + UM.Theme.getSize("default_lining").height
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Display Name") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Display Name") }
ReadOnlyTextField ReadOnlyTextField
{ {
id: displayNameTextField; id: displayNameTextField;
width: base.secondColumnWidth; width: scrollView.columnWidth;
text: properties.name; text: properties.name;
readOnly: !base.editingEnabled; readOnly: !base.editingEnabled;
onEditingFinished: base.setName(properties.name, text) onEditingFinished: base.setName(properties.name, text)
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") }
ReadOnlyTextField ReadOnlyTextField
{ {
id: textField; id: textField;
width: base.secondColumnWidth; width: scrollView.columnWidth;
text: properties.supplier; text: properties.supplier;
readOnly: !base.editingEnabled; readOnly: !base.editingEnabled;
onEditingFinished: base.setMetaDataEntry("brand", properties.supplier, text) onEditingFinished: base.setMetaDataEntry("brand", properties.supplier, text)
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") }
ReadOnlyTextField ReadOnlyTextField
{ {
width: base.secondColumnWidth; width: scrollView.columnWidth;
text: properties.material_type; text: properties.material_type;
readOnly: !base.editingEnabled; readOnly: !base.editingEnabled;
onEditingFinished: base.setMetaDataEntry("material", properties.material_type, text) onEditingFinished: base.setMetaDataEntry("material", properties.material_type, text)
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") }
Row Row
{ {
width: base.secondColumnWidth; width: scrollView.columnWidth;
height: parent.rowHeight; height: parent.rowHeight;
spacing: UM.Theme.getSize("default_margin").width/2 spacing: UM.Theme.getSize("default_margin").width/2
@ -130,11 +130,11 @@ TabView
Label { width: parent.width; height: parent.rowHeight; font.bold: true; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Properties") } Label { width: parent.width; height: parent.rowHeight; font.bold: true; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Properties") }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Density") }
ReadOnlySpinBox ReadOnlySpinBox
{ {
id: densitySpinBox id: densitySpinBox
width: base.secondColumnWidth width: scrollView.columnWidth
value: properties.density value: properties.density
decimals: 2 decimals: 2
suffix: " g/cm³" suffix: " g/cm³"
@ -145,11 +145,11 @@ TabView
onValueChanged: updateCostPerMeter() onValueChanged: updateCostPerMeter()
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Diameter") }
ReadOnlySpinBox ReadOnlySpinBox
{ {
id: diameterSpinBox id: diameterSpinBox
width: base.secondColumnWidth width: scrollView.columnWidth
value: properties.diameter value: properties.diameter
decimals: 2 decimals: 2
suffix: " mm" suffix: " mm"
@ -160,11 +160,11 @@ TabView
onValueChanged: updateCostPerMeter() onValueChanged: updateCostPerMeter()
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament Cost") }
SpinBox SpinBox
{ {
id: spoolCostSpinBox id: spoolCostSpinBox
width: base.secondColumnWidth width: scrollView.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_cost") value: base.getMaterialPreferenceValue(properties.guid, "spool_cost")
prefix: base.currency + " " prefix: base.currency + " "
decimals: 2 decimals: 2
@ -176,11 +176,11 @@ TabView
} }
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament weight") }
SpinBox SpinBox
{ {
id: spoolWeightSpinBox id: spoolWeightSpinBox
width: base.secondColumnWidth width: scrollView.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight") value: base.getMaterialPreferenceValue(properties.guid, "spool_weight")
suffix: " g" suffix: " g"
stepSize: 100 stepSize: 100
@ -193,19 +193,19 @@ TabView
} }
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Filament length") }
Label Label
{ {
width: base.secondColumnWidth width: scrollView.columnWidth
text: "~ %1 m".arg(Math.round(base.spoolLength)) text: "~ %1 m".arg(Math.round(base.spoolLength))
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
height: parent.rowHeight height: parent.rowHeight
} }
Label { width: base.firstColumnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter") } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Cost per Meter") }
Label Label
{ {
width: base.secondColumnWidth width: scrollView.columnWidth
text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency) text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency)
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
height: parent.rowHeight height: parent.rowHeight
@ -214,7 +214,7 @@ TabView
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height; visible: unlinkMaterialButton.visible } Item { width: parent.width; height: UM.Theme.getSize("default_margin").height; visible: unlinkMaterialButton.visible }
Label Label
{ {
width: parent.width width: 2 * scrollView.columnWidth
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames) text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames)
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
@ -239,7 +239,7 @@ TabView
ReadOnlyTextArea ReadOnlyTextArea
{ {
text: properties.description; text: properties.description;
width: base.firstColumnWidth + base.secondColumnWidth width: 2 * scrollView.columnWidth
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
readOnly: !base.editingEnabled; readOnly: !base.editingEnabled;
@ -252,13 +252,15 @@ TabView
ReadOnlyTextArea ReadOnlyTextArea
{ {
text: properties.adhesion_info; text: properties.adhesion_info;
width: base.firstColumnWidth + base.secondColumnWidth width: 2 * scrollView.columnWidth
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
readOnly: !base.editingEnabled; readOnly: !base.editingEnabled;
onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text) onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text)
} }
Item { width: parent.width; height: UM.Theme.getSize("default_margin").height }
} }
function updateCostPerMeter() function updateCostPerMeter()
@ -304,6 +306,7 @@ TabView
width: base.firstColumnWidth; width: base.firstColumnWidth;
height: spinBox.height height: spinBox.height
text: model.label text: model.label
elide: Text.ElideRight
} }
ReadOnlySpinBox ReadOnlySpinBox
{ {