forked from qt-creator/qt-creator
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:
@@ -43,6 +43,8 @@ HelperWidgets.Section {
|
||||
|
||||
EffectCompositionNodeUniform {
|
||||
width: root.width
|
||||
|
||||
onReset: nodeUniformsModel.resetData(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ Item {
|
||||
id: root
|
||||
|
||||
height: layout.implicitHeight
|
||||
|
||||
visible: !uniformUseCustomValue
|
||||
|
||||
signal reset()
|
||||
|
||||
Component.onCompleted: {
|
||||
if (uniformType === "int") {
|
||||
if (uniformControlType === "channel")
|
||||
@@ -49,10 +50,11 @@ Item {
|
||||
RowLayout {
|
||||
id: layout
|
||||
|
||||
spacing: 20
|
||||
anchors.fill: parent
|
||||
|
||||
Text {
|
||||
id: textName
|
||||
|
||||
text: uniformDisplayName
|
||||
color: StudioTheme.Values.themeTextColor
|
||||
font.pixelSize: StudioTheme.Values.baseFontSize
|
||||
@@ -63,11 +65,38 @@ Item {
|
||||
elide: Text.ElideRight
|
||||
|
||||
HelperWidgets.ToolTipArea {
|
||||
id: tooltipArea
|
||||
|
||||
anchors.fill: parent
|
||||
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 {
|
||||
id: valueLoader
|
||||
Layout.fillWidth: true
|
||||
|
||||
@@ -15,8 +15,14 @@ Row {
|
||||
StudioControls.ColorEditor {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ Row {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
id: spinBox
|
||||
|
||||
// value: uniformValue binding can get overwritten by normal operation of the control
|
||||
property double resetValue: uniformValue
|
||||
onResetValueChanged: value = resetValue
|
||||
|
||||
width: 60
|
||||
spinBoxIndicatorVisible: false
|
||||
inputHAlignment: Qt.AlignHCenter
|
||||
@@ -22,7 +26,7 @@ Row {
|
||||
value: uniformValue
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue = value
|
||||
onValueModified: uniformValue = value
|
||||
}
|
||||
|
||||
StudioControls.Slider {
|
||||
|
||||
@@ -14,6 +14,10 @@ Row {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
id: spinBox
|
||||
|
||||
// value: uniformValue binding can get overwritten by normal operation of the control
|
||||
property double resetValue: uniformValue
|
||||
onResetValueChanged: value = resetValue
|
||||
|
||||
width: 60
|
||||
spinBoxIndicatorVisible: false
|
||||
inputHAlignment: Qt.AlignHCenter
|
||||
@@ -22,7 +26,7 @@ Row {
|
||||
value: uniformValue
|
||||
stepSize: 1
|
||||
decimals: 0
|
||||
onValueChanged: uniformValue = Math.round(value)
|
||||
onValueModified: uniformValue = Math.round(value)
|
||||
}
|
||||
|
||||
StudioControls.Slider {
|
||||
|
||||
@@ -15,6 +15,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -26,7 +30,7 @@ RowLayout {
|
||||
value: uniformValue.x
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.x = value
|
||||
onValueModified: uniformValue.x = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
@@ -51,6 +55,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -62,7 +70,7 @@ RowLayout {
|
||||
value: uniformValue.y
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.y = value
|
||||
onValueModified: uniformValue.y = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
|
||||
@@ -15,6 +15,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -26,7 +30,7 @@ RowLayout {
|
||||
value: uniformValue.x
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.x = value
|
||||
onValueModified: uniformValue.x = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
@@ -51,6 +55,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -62,7 +70,7 @@ RowLayout {
|
||||
value: uniformValue.y
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.y = value
|
||||
onValueModified: uniformValue.y = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
@@ -87,6 +95,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -98,7 +110,7 @@ RowLayout {
|
||||
value: uniformValue.z
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.z = value
|
||||
onValueModified: uniformValue.z = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
|
||||
@@ -15,6 +15,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -26,7 +30,7 @@ RowLayout {
|
||||
value: uniformValue.x
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.x = value
|
||||
onValueModified: uniformValue.x = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
@@ -51,6 +55,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -62,7 +70,7 @@ RowLayout {
|
||||
value: uniformValue.y
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.y = value
|
||||
onValueModified: uniformValue.y = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
@@ -87,6 +95,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -98,7 +110,7 @@ RowLayout {
|
||||
value: uniformValue.z
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.z = value
|
||||
onValueModified: uniformValue.z = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
@@ -123,6 +135,10 @@ RowLayout {
|
||||
HelperWidgets.DoubleSpinBox {
|
||||
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.minimumWidth: 30
|
||||
Layout.maximumWidth: 60
|
||||
@@ -134,7 +150,7 @@ RowLayout {
|
||||
value: uniformValue.w
|
||||
stepSize: .01
|
||||
decimals: 2
|
||||
onValueChanged: uniformValue.w = value
|
||||
onValueModified: uniformValue.w = value
|
||||
}
|
||||
|
||||
Item { // spacer
|
||||
|
||||
@@ -53,5 +53,6 @@ Item {
|
||||
decimals: 2
|
||||
|
||||
onRealValueModified: wrapper.valueModified()
|
||||
onCompressedRealValueModified: wrapper.valueModified()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ bool EffectComposerUniformsModel::setData(const QModelIndex &index, const QVaria
|
||||
int idx = value.toString().indexOf("file:");
|
||||
|
||||
QString path = idx > 0 ? updatedValue.right(updatedValue.size() - idx - 5) : updatedValue;
|
||||
|
||||
if (idx == -1)
|
||||
updatedValue = QUrl::fromLocalFile(path).toString();
|
||||
|
||||
uniform->setValue(updatedValue);
|
||||
@@ -73,6 +75,14 @@ bool EffectComposerUniformsModel::setData(const QModelIndex &index, const QVaria
|
||||
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()
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
Q_INVOKABLE bool resetData(int row);
|
||||
|
||||
void resetModel();
|
||||
|
||||
|
||||
@@ -94,7 +94,13 @@ void Uniform::setValue(const QVariant &newValue)
|
||||
{
|
||||
if (m_value != newValue) {
|
||||
m_value = newValue;
|
||||
|
||||
emit uniformValueChanged();
|
||||
|
||||
if (m_type == Type::Sampler) {
|
||||
m_backendValue->setValue(newValue);
|
||||
emit uniformBackendValueChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user