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

@@ -59,7 +59,9 @@ 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;
updatedValue = QUrl::fromLocalFile(path).toString();
if (idx == -1)
updatedValue = QUrl::fromLocalFile(path).toString();
uniform->setValue(updatedValue);
g_propertyData.insert(uniform->name(), 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();

View File

@@ -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();

View File

@@ -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();
}
}
}