Fix disabling clip only disable audio part of an AV clip.

BUG: 411466
parent 9a51d703
......@@ -581,20 +581,30 @@ void TimelineFunctions::showCompositionKeyframes(const std::shared_ptr<TimelineI
timeline->dataChanged(modelIndex, modelIndex, {TimelineModel::ShowKeyframesRole});
}
bool TimelineFunctions::switchEnableState(const std::shared_ptr<TimelineItemModel> &timeline, int clipId)
bool TimelineFunctions::switchEnableState(const std::shared_ptr<TimelineItemModel> &timeline, std::unordered_set<int> selection)
{
PlaylistState::ClipState oldState = timeline->getClipPtr(clipId)->clipState();
PlaylistState::ClipState state = PlaylistState::Disabled;
bool disable = true;
if (oldState == PlaylistState::Disabled) {
state = timeline->getTrackById_const(timeline->getClipTrackId(clipId))->trackType();
disable = false;
}
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool result = changeClipState(timeline, clipId, state, undo, redo);
bool result = false;
bool disable = true;
for (int clipId : selection) {
if (!timeline->isClip(clipId)) {
continue;
}
PlaylistState::ClipState oldState = timeline->getClipPtr(clipId)->clipState();
PlaylistState::ClipState state = PlaylistState::Disabled;
disable = true;
if (oldState == PlaylistState::Disabled) {
state = timeline->getTrackById_const(timeline->getClipTrackId(clipId))->trackType();
disable = false;
}
result = changeClipState(timeline, clipId, state, undo, redo);
if (!result) {
break;
}
}
if (result) {
pCore->pushUndo(undo, redo, disable ? i18n("Disable clip") : i18n("Enable clip"));
pCore->pushUndo(undo, redo, disable ? i18n("Disable clip") : i18n("Enable clip"));
}
return result;
}
......
......@@ -102,7 +102,7 @@ struct TimelineFunctions
* @param status: target status of the clip
This function creates an undo object and returns true on success
*/
static bool switchEnableState(const std::shared_ptr<TimelineItemModel> &timeline, int clipId);
static bool switchEnableState(const std::shared_ptr<TimelineItemModel> &timeline, std::unordered_set<int> selection);
/* @brief change the clip state and accumulates for undo/redo
*/
static bool changeClipState(const std::shared_ptr<TimelineItemModel> &timeline, int clipId, PlaylistState::ClipState status, Fun &undo, Fun &redo);
......
......@@ -1752,12 +1752,13 @@ void TimelineController::showCompositionKeyframes(int clipId, bool value)
TimelineFunctions::showCompositionKeyframes(m_model, clipId, value);
}
void TimelineController::switchEnableState(int clipId)
void TimelineController::switchEnableState(std::unordered_set<int> selection)
{
if (clipId == -1) {
clipId = getMainSelectedItem(false, false);
if (selection.empty()) {
selection = m_model->getCurrentSelection();
//clipId = getMainSelectedItem(false, false);
}
TimelineFunctions::switchEnableState(m_model, clipId);
TimelineFunctions::switchEnableState(m_model, selection);
}
void TimelineController::addCompositionToClip(const QString &assetId, int clipId, int offset)
......
......@@ -332,7 +332,7 @@ public:
Q_INVOKABLE void removeSpace(int trackId = -1, int frame = -1, bool affectAllTracks = false);
/* @brief If clip is enabled, disable, otherwise enable
*/
Q_INVOKABLE void switchEnableState(int clipId = -1);
Q_INVOKABLE void switchEnableState(std::unordered_set<int> selection = {});
Q_INVOKABLE void addCompositionToClip(const QString &assetId, int clipId, int offset);
Q_INVOKABLE void addEffectToClip(const QString &assetId, int clipId);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment