Commit eafde0c2 authored by Nicolas Carion's avatar Nicolas Carion

fix clip menu to show only enable/disable

parent 9b5ef796
......@@ -396,17 +396,21 @@ void TimelineFunctions::showCompositionKeyframes(std::shared_ptr<TimelineItemMod
timeline->dataChanged(modelIndex, modelIndex, {TimelineModel::KeyframesRole});
}
bool TimelineFunctions::changeClipState(std::shared_ptr<TimelineItemModel> timeline, int clipId, PlaylistState::ClipState status)
bool TimelineFunctions::switchEnableState(std::shared_ptr<TimelineItemModel> timeline, int clipId)
{
PlaylistState::ClipState oldState = timeline->m_allClips[clipId]->clipState();
if (oldState == status) {
return true;
PlaylistState::ClipState oldState = timeline->getClipPtr(clipId)->clipState();
PlaylistState::ClipState state = PlaylistState::Disabled;
bool disable = true;
if (oldState == PlaylistState::Disabled) {
bool audio = timeline->getTrackById(timeline->getClipTrackId(clipId))->isAudioTrack();
state = audio ? PlaylistState::AudioOnly : PlaylistState::VideoOnly;
disable = false;
}
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool result = changeClipState(timeline, clipId, status, undo, redo);
bool result = changeClipState(timeline, clipId, state, undo, redo);
if (result) {
pCore->pushUndo(undo, redo, i18n("Change clip state"));
pCore->pushUndo(undo, redo, disable ? i18n("Disable clip") : i18n("Enable clip"));
}
return result;
}
......
......@@ -74,14 +74,14 @@ struct TimelineFunctions
static void showClipKeyframes(std::shared_ptr<TimelineItemModel> timeline, int clipId, bool value);
static void showCompositionKeyframes(std::shared_ptr<TimelineItemModel> timeline, int compoId, bool value);
/* @brief Change the status of the clip to Video+audio, video only, or audio only
/* @brief If the clip is activated, disable, otherwise enable
* @param timeline: pointer to the timeline that we modify
* @param clipId: Id of the clip to modify
* @param status: target status of the clip
This function creates an undo object and returns true on success
*/
static bool changeClipState(std::shared_ptr<TimelineItemModel> timeline, int clipId, PlaylistState::ClipState status);
/* @brief Same function as above, but accumulates for undo/redo
static bool switchEnableState(std::shared_ptr<TimelineItemModel> timeline, int clipId);
/* @brief change the clip state and accumulates for undo/redo
*/
static bool changeClipState(std::shared_ptr<TimelineItemModel> timeline, int clipId, PlaylistState::ClipState status, Fun &undo, Fun &redo);
......
......@@ -12,6 +12,11 @@ OLD.Menu {
//mergeItem.visible = timeline.mergeClipWithNext(trackIndex, index, true)
menu.popup()
}
OLD.MenuItem {
visible: true
text: i18n('Copy')
onTriggered: root.copiedClip = clipId
}
OLD.MenuItem {
visible: true
text: i18n('Cut')
......@@ -35,11 +40,6 @@ OLD.Menu {
onTriggered: timeline.unGroupSelection(clipId)
}
OLD.MenuItem {
visible: true
text: i18n('Copy')
onTriggered: root.copiedClip = clipId
}
OLD.MenuItem {
visible: root.copiedClip != -1 && root.copiedClip != clipId
text: i18n('Paste Effects')
......@@ -80,31 +80,9 @@ OLD.Menu {
text: i18n('Split At Playhead')
onTriggered: timeline.triggerAction('cut_timeline_clip')
}
OLD.Menu {
title: i18n('Clip Type...')
OLD.ExclusiveGroup {
id: radioInputGroup
}
OLD.MenuItem {
text: i18n('Video Only')
checkable: true
checked: clipStatus == ClipState.VideoOnly
exclusiveGroup: radioInputGroup
onTriggered: timeline.setClipStatus(clipId, ClipState.VideoOnly)
}
OLD.MenuItem {
text: i18n('Audio Only')
checkable: true
checked: clipStatus == ClipState.AudioOnly
exclusiveGroup: radioInputGroup
onTriggered: timeline.setClipStatus(clipId, ClipState.AudioOnly)
}
OLD.MenuItem {
text: i18n('Disabled')
checkable: true
checked: clipStatus == ClipState.Disabled
exclusiveGroup: radioInputGroup
onTriggered: timeline.setClipStatus(clipId, ClipState.Disabled)
}
OLD.MenuItem {
visible: true
text: clipStatus != ClipState.Disabled ? i18n('Disable clip') : i18n('Enable clip')
onTriggered: timeline.switchEnableState(clipId)
}
}
......@@ -1464,9 +1464,9 @@ void TimelineController::showCompositionKeyframes(int clipId, bool value)
TimelineFunctions::showCompositionKeyframes(m_model, clipId, value);
}
void TimelineController::setClipStatus(int clipId, PlaylistState::ClipState status)
void TimelineController::switchEnableState(int clipId)
{
TimelineFunctions::changeClipState(m_model, clipId, status);
TimelineFunctions::switchEnableState(m_model, clipId);
}
void TimelineController::splitAudio(int clipId)
......
......@@ -250,9 +250,9 @@ public:
*/
Q_INVOKABLE void insertSpace(int trackId = -1, int frame = -1);
Q_INVOKABLE void removeSpace(int trackId = -1, int frame = -1, bool affectAllTracks = false);
/* @brief Change a clip status (normal / audio only / video only)
/* @brief If clip is enabled, disable, otherwise enable
*/
Q_INVOKABLE void setClipStatus(int clipId, PlaylistState::ClipState status);
Q_INVOKABLE void switchEnableState(int clipId);
Q_INVOKABLE void requestClipCut(int clipId, int position);
......
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