EffectComposer: Add 'reset' button for values

Task-number: QDS-11719
Change-Id: Ia03366bf109427fbcfe5cc1d4f68ae97fa8dc256
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Shrief Gabr
2024-03-19 14:52:20 +02:00
parent 2128776e16
commit 002bfbf80f
12 changed files with 115 additions and 16 deletions

View File

@@ -43,6 +43,8 @@ HelperWidgets.Section {
EffectCompositionNodeUniform { EffectCompositionNodeUniform {
width: root.width width: root.width
onReset: nodeUniformsModel.resetData(index)
} }
} }
} }

View File

@@ -13,9 +13,10 @@ Item {
id: root id: root
height: layout.implicitHeight height: layout.implicitHeight
visible: !uniformUseCustomValue visible: !uniformUseCustomValue
signal reset()
Component.onCompleted: { Component.onCompleted: {
if (uniformType === "int") { if (uniformType === "int") {
if (uniformControlType === "channel") if (uniformControlType === "channel")
@@ -49,10 +50,11 @@ Item {
RowLayout { RowLayout {
id: layout id: layout
spacing: 20
anchors.fill: parent anchors.fill: parent
Text { Text {
id: textName
text: uniformDisplayName text: uniformDisplayName
color: StudioTheme.Values.themeTextColor color: StudioTheme.Values.themeTextColor
font.pixelSize: StudioTheme.Values.baseFontSize font.pixelSize: StudioTheme.Values.baseFontSize
@@ -63,11 +65,38 @@ Item {
elide: Text.ElideRight elide: Text.ElideRight
HelperWidgets.ToolTipArea { HelperWidgets.ToolTipArea {
id: tooltipArea
anchors.fill: parent anchors.fill: parent
tooltip: uniformDescription tooltip: uniformDescription
} }
} }
Item {
Layout.preferredHeight: 30
Layout.preferredWidth: 30
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
}
HelperWidgets.IconButton {
id: iconButton
buttonSize: 24
icon: StudioTheme.Constants.reload_medium
iconSize: 16
anchors.centerIn: parent
visible: mouseArea.containsMouse || iconButton.containsMouse
tooltip: qsTr("Reset value")
onClicked: root.reset()
}
}
Loader { Loader {
id: valueLoader id: valueLoader
Layout.fillWidth: true Layout.fillWidth: true

View File

@@ -15,8 +15,14 @@ Row {
StudioControls.ColorEditor { StudioControls.ColorEditor {
actionIndicatorVisible: false actionIndicatorVisible: false
Component.onCompleted: color = uniformValue // color: uniformValue binding can get overwritten by normal operation of the control
property color resetValue: uniformValue
onColorChanged: uniformValue = color onResetValueChanged: color = uniformValue
Component.onCompleted: color = uniformValue
onColorChanged: {
if (uniformValue !== color)
uniformValue = color
}
} }
} }

View File

@@ -14,6 +14,10 @@ Row {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: spinBox id: spinBox
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue
onResetValueChanged: value = resetValue
width: 60 width: 60
spinBoxIndicatorVisible: false spinBoxIndicatorVisible: false
inputHAlignment: Qt.AlignHCenter inputHAlignment: Qt.AlignHCenter
@@ -22,7 +26,7 @@ Row {
value: uniformValue value: uniformValue
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue = value onValueModified: uniformValue = value
} }
StudioControls.Slider { StudioControls.Slider {

View File

@@ -14,6 +14,10 @@ Row {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: spinBox id: spinBox
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue
onResetValueChanged: value = resetValue
width: 60 width: 60
spinBoxIndicatorVisible: false spinBoxIndicatorVisible: false
inputHAlignment: Qt.AlignHCenter inputHAlignment: Qt.AlignHCenter
@@ -22,7 +26,7 @@ Row {
value: uniformValue value: uniformValue
stepSize: 1 stepSize: 1
decimals: 0 decimals: 0
onValueChanged: uniformValue = Math.round(value) onValueModified: uniformValue = Math.round(value)
} }
StudioControls.Slider { StudioControls.Slider {

View File

@@ -15,6 +15,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vX id: vX
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.x
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -26,7 +30,7 @@ RowLayout {
value: uniformValue.x value: uniformValue.x
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.x = value onValueModified: uniformValue.x = value
} }
Item { // spacer Item { // spacer
@@ -51,6 +55,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vY id: vY
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.y
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -62,7 +70,7 @@ RowLayout {
value: uniformValue.y value: uniformValue.y
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.y = value onValueModified: uniformValue.y = value
} }
Item { // spacer Item { // spacer

View File

@@ -15,6 +15,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vX id: vX
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.x
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -26,7 +30,7 @@ RowLayout {
value: uniformValue.x value: uniformValue.x
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.x = value onValueModified: uniformValue.x = value
} }
Item { // spacer Item { // spacer
@@ -51,6 +55,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vY id: vY
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.y
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -62,7 +70,7 @@ RowLayout {
value: uniformValue.y value: uniformValue.y
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.y = value onValueModified: uniformValue.y = value
} }
Item { // spacer Item { // spacer
@@ -87,6 +95,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vZ id: vZ
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.z
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -98,7 +110,7 @@ RowLayout {
value: uniformValue.z value: uniformValue.z
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.z = value onValueModified: uniformValue.z = value
} }
Item { // spacer Item { // spacer

View File

@@ -15,6 +15,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vX id: vX
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.x
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -26,7 +30,7 @@ RowLayout {
value: uniformValue.x value: uniformValue.x
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.x = value onValueModified: uniformValue.x = value
} }
Item { // spacer Item { // spacer
@@ -51,6 +55,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vY id: vY
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.y
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -62,7 +70,7 @@ RowLayout {
value: uniformValue.y value: uniformValue.y
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.y = value onValueModified: uniformValue.y = value
} }
Item { // spacer Item { // spacer
@@ -87,6 +95,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vZ id: vZ
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.z
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -98,7 +110,7 @@ RowLayout {
value: uniformValue.z value: uniformValue.z
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.z = value onValueModified: uniformValue.z = value
} }
Item { // spacer Item { // spacer
@@ -123,6 +135,10 @@ RowLayout {
HelperWidgets.DoubleSpinBox { HelperWidgets.DoubleSpinBox {
id: vW id: vW
// value: uniformValue binding can get overwritten by normal operation of the control
property double resetValue: uniformValue.w
onResetValueChanged: value = resetValue
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 30 Layout.minimumWidth: 30
Layout.maximumWidth: 60 Layout.maximumWidth: 60
@@ -134,7 +150,7 @@ RowLayout {
value: uniformValue.w value: uniformValue.w
stepSize: .01 stepSize: .01
decimals: 2 decimals: 2
onValueChanged: uniformValue.w = value onValueModified: uniformValue.w = value
} }
Item { // spacer Item { // spacer

View File

@@ -53,5 +53,6 @@ Item {
decimals: 2 decimals: 2
onRealValueModified: wrapper.valueModified() onRealValueModified: wrapper.valueModified()
onCompressedRealValueModified: wrapper.valueModified()
} }
} }

View File

@@ -59,6 +59,8 @@ bool EffectComposerUniformsModel::setData(const QModelIndex &index, const QVaria
int idx = value.toString().indexOf("file:"); int idx = value.toString().indexOf("file:");
QString path = idx > 0 ? updatedValue.right(updatedValue.size() - idx - 5) : updatedValue; QString path = idx > 0 ? updatedValue.right(updatedValue.size() - idx - 5) : updatedValue;
if (idx == -1)
updatedValue = QUrl::fromLocalFile(path).toString(); updatedValue = QUrl::fromLocalFile(path).toString();
uniform->setValue(updatedValue); uniform->setValue(updatedValue);
@@ -73,6 +75,14 @@ bool EffectComposerUniformsModel::setData(const QModelIndex &index, const QVaria
return true; return true;
} }
bool EffectComposerUniformsModel::resetData(int row)
{
QModelIndex idx = index(row, 0);
QTC_ASSERT(idx.isValid(), return false);
return setData(idx, idx.data(DefaultValueRole), ValueRole);
}
void EffectComposerUniformsModel::resetModel() void EffectComposerUniformsModel::resetModel()
{ {
beginResetModel(); beginResetModel();

View File

@@ -20,6 +20,7 @@ public:
int rowCount(const QModelIndex & parent = QModelIndex()) const override; int rowCount(const QModelIndex & parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override; bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Q_INVOKABLE bool resetData(int row);
void resetModel(); void resetModel();

View File

@@ -94,7 +94,13 @@ void Uniform::setValue(const QVariant &newValue)
{ {
if (m_value != newValue) { if (m_value != newValue) {
m_value = newValue; m_value = newValue;
emit uniformValueChanged(); emit uniformValueChanged();
if (m_type == Type::Sampler) {
m_backendValue->setValue(newValue);
emit uniformBackendValueChanged();
}
} }
} }