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