[ui] Change Intrinsic display QML structure

This commit is contained in:
Nils Landrodie 2021-08-02 21:16:37 +02:00 committed by Landrodie
parent 7a8f78f5e1
commit 2eb8783c95

View file

@ -12,23 +12,48 @@ RowLayout {
property variant attribute: model.display property variant attribute: model.display
property int rowIndex: model.row property int rowIndex: model.row
property bool readOnly: false property bool readOnly: false
property string toolTipText: attribute.fullLabel
Loader { Pane {
// anchors.fill: parent
// Layout: childrenRect.width
Layout.minimumWidth: loaderComponent.width
Layout.minimumHeight: loaderComponent.height
Layout.fillWidth: true Layout.fillWidth: true
// color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1)
// z: -1
// border.width: 2
// border.color: Qt.darker(palette.window, 1.1)
padding: 0
sourceComponent: { hoverEnabled: true
//console.warn("keys " + Object.keys(intrinsicModel.columns[model.index]))
//console.warn("index " + intrinsicModel.columnCount) ToolTip.delay: 10
//console.warn("HEEELPPP " + model.display.desc.values) ToolTip.timeout: 5000
//console.warn("Object " + intrinsicModel.columns[model.index].display) ToolTip.visible: hovered
switch(model.display.type) ToolTip.text: toolTipText
{
case "ChoiceParam": return choice_component Rectangle {
case "IntParam": return int_component width: parent.width
case "FloatParam": return float_component height: loaderComponent.height
case "BoolParam": return bool_component
case "StringParam": return textField_component color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1)
default: return textField_component border.width: 2
border.color: Qt.darker(palette.window, 1.1)
Loader {
id: loaderComponent
sourceComponent: {
switch(model.display.type)
{
case "ChoiceParam": return choice_component
case "IntParam": return int_component
case "FloatParam": return float_component
case "BoolParam": return bool_component
case "StringParam": return textField_component
default: return textField_component
}
}
} }
} }
} }
@ -42,15 +67,14 @@ RowLayout {
selectByMouse: true selectByMouse: true
selectionColor: 'white' selectionColor: 'white'
selectedTextColor: Qt.darker(palette.window, 1.1) selectedTextColor: Qt.darker(palette.window, 1.1)
/*
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1) color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1)
z: -1 z: -1
border.width: 2 border.width: 2
border.color: Qt.darker(palette.window, 1.1) border.color: Qt.darker(palette.window, 1.1)
} }*/
onEditingFinished: _reconstruction.setAttribute(attribute, text) onEditingFinished: _reconstruction.setAttribute(attribute, text)
onAccepted: { onAccepted: {
@ -65,6 +89,7 @@ RowLayout {
Component { Component {
id: int_component id: int_component
TextInput{ TextInput{
text: model.display.value text: model.display.value
color: 'white' color: 'white'
@ -78,14 +103,14 @@ RowLayout {
} }
validator: intValidator validator: intValidator
/*
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1) color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1)
z: -1 z: -1
border.width: 2 border.width: 2
border.color: Qt.darker(palette.window, 1.1) border.color: Qt.darker(palette.window, 1.1)
} }*/
onEditingFinished: _reconstruction.setAttribute(attribute, Number(text)) onEditingFinished: _reconstruction.setAttribute(attribute, Number(text))
onAccepted: { onAccepted: {
@ -110,13 +135,14 @@ RowLayout {
leftInset: 6 leftInset: 6
rightInset: 6 rightInset: 6
bottomInset: 7 bottomInset: 7
Rectangle {
/*Rectangle {
anchors.fill: parent anchors.fill: parent
color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1) color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1)
z: -1 z: -1
border.width: 2 border.width: 2
border.color: Qt.darker(palette.window, 1.1) border.color: Qt.darker(palette.window, 1.1)
} }*/
Connections { Connections {
target: attribute target: attribute
onValueChanged: combo.currentIndex = combo.find(attribute.value) onValueChanged: combo.currentIndex = combo.find(attribute.value)
@ -130,20 +156,20 @@ RowLayout {
checked: attribute ? attribute.value : false checked: attribute ? attribute.value : false
padding: 12 padding: 12
onToggled: _reconstruction.setAttribute(attribute, !attribute.value) onToggled: _reconstruction.setAttribute(attribute, !attribute.value)
/*
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1) color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1)
z: -1 z: -1
border.width: 2 border.width: 2
border.color: Qt.darker(palette.window, 1.1) border.color: Qt.darker(palette.window, 1.1)
} }*/
} }
} }
Component { Component {
id: float_component id: float_component
TextInput{ TextInput{
//readonly property int stepDecimalCount: stepSize < 1 ? String(stepSize).split(".").pop().length : 0
readonly property real formattedValue: model.display.value.toFixed(2) readonly property real formattedValue: model.display.value.toFixed(2)
property string displayValue: String(formattedValue) property string displayValue: String(formattedValue)
text: displayValue text: displayValue
@ -173,14 +199,16 @@ RowLayout {
} }
validator: doubleValidator validator: doubleValidator
/*
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1) color: rowIndex % 2 ? palette.window : Qt.darker(palette.window, 1.1)
z: -1 z: -1
border.width: 2 border.width: 2
border.color: Qt.darker(palette.window, 1.1) border.color: Qt.darker(palette.window, 1.1)
} ToolTip.text: "HELLOOOOO"
ToolTip.visible: true
}*/
onEditingFinished: _reconstruction.setAttribute(attribute, Number(text)) onEditingFinished: _reconstruction.setAttribute(attribute, Number(text))
onAccepted: { onAccepted: {
_reconstruction.setAttribute(attribute, Number(text)) _reconstruction.setAttribute(attribute, Number(text))
@ -192,7 +220,4 @@ RowLayout {
} }
} }
} }