| 2083 | } |
| 2084 | |
| 2085 | void EffectStackModel::applyAssetKeyframeCommand(int row, const QModelIndex &index, GenTime pos, const QVariant &previousValue, QVariant value, int ix, |
| 2086 | QUndoCommand *command) |
| 2087 | { |
| 2088 | auto item = getEffectStackRow(row); |
| 2089 | if (!item || item->childCount() > 0) { |
| 2090 | // group, error |
| 2091 | return; |
| 2092 | } |
| 2093 | std::shared_ptr<EffectItemModel> eff = std::static_pointer_cast<EffectItemModel>(item); |
| 2094 | const std::shared_ptr<AssetParameterModel> effectParamModel = std::static_pointer_cast<AssetParameterModel>(eff); |
| 2095 | if (KdenliveSettings::applyEffectParamsToGroupWithSameValue()) { |
| 2096 | if (!effectParamModel->getKeyframeModel()->hasKeyframe(pos.frames(pCore->getCurrentFps()))) { |
| 2097 | return; |
| 2098 | } |
| 2099 | const QVariant currentValue = effectParamModel->getKeyframeModel()->getKeyModel(index)->getInterpolatedValue(pos); |
| 2100 | switch (ix) { |
| 2101 | case -1: |
| 2102 | if (previousValue != currentValue) { |
| 2103 | // Don't apply change on this effect, the start value is not the same |
| 2104 | return; |
| 2105 | } |
| 2106 | break; |
| 2107 | case 0: { |
| 2108 | QStringList vals = currentValue.toString().split(QLatin1Char(' ')); |
| 2109 | if (!vals.isEmpty() && previousValue.toString().section(QLatin1Char(' '), 0, 0) == vals.at(0)) { |
| 2110 | vals[0] = value.toString().section(QLatin1Char(' '), 0, 0); |
| 2111 | value = QVariant(vals.join(QLatin1Char(' '))); |
| 2112 | } else { |
| 2113 | return; |
| 2114 | } |
| 2115 | break; |
| 2116 | } |
| 2117 | default: { |
| 2118 | QStringList vals = currentValue.toString().split(QLatin1Char(' ')); |
| 2119 | if (vals.size() > ix && previousValue.toString().section(QLatin1Char(' '), ix, ix) == vals.at(ix)) { |
| 2120 | vals[ix] = value.toString().section(QLatin1Char(' '), ix, ix); |
| 2121 | value = QVariant(vals.join(QLatin1Char(' '))); |
| 2122 | } else { |
| 2123 | return; |
| 2124 | } |
| 2125 | break; |
| 2126 | } |
| 2127 | } |
| 2128 | } |
| 2129 | new AssetKeyframeCommand(effectParamModel, index, value, pos, command); |
| 2130 | } |
| 2131 | |
| 2132 | void EffectStackModel::applyAssetMultiKeyframeCommand(int row, const QList<QModelIndex> &indexes, GenTime pos, const QStringList &sourceValues, |
| 2133 | const QStringList &values, QUndoCommand *command) |
no test coverage detected