* Re-add extract clip in timeline context menu

* Add new option to save current timeline clip as subclip (clip zone)
parent 6d99ae0c
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="171" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="173" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="dvd_wizard" />
......@@ -109,6 +109,8 @@
<Action name="clip_switch" />
<Action name="clip_disable" />
<Action name="clip_in_project_tree" />
<Action name="extract_clip" />
<Action name="save_to_bin" />
<Action name="expand_timeline_clip" />
</Menu>
<Action name="grab_item" />
......
......@@ -513,6 +513,8 @@ void MainWindow::init()
timelineMenu->addAction(actionCollection()->action(QStringLiteral("clip_split")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("clip_switch")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("delete_timeline_clip")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("extract_clip")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("save_to_bin")));
QMenu *markerMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("marker_menu"), this));
timelineMenu->addMenu(markerMenu);
......@@ -1404,7 +1406,6 @@ void MainWindow::setupActions()
addAction(QStringLiteral("delete_clip_marker"), i18n("Delete Marker"), this, SLOT(slotDeleteClipMarker()), QIcon::fromTheme(QStringLiteral("edit-delete")));
addAction(QStringLiteral("delete_all_clip_markers"), i18n("Delete All Markers"), this, SLOT(slotDeleteAllClipMarkers()),
QIcon::fromTheme(QStringLiteral("edit-delete")));
QAction *editClipMarker = addAction(QStringLiteral("edit_clip_marker"), i18n("Edit Marker"), this, SLOT(slotEditClipMarker()),
QIcon::fromTheme(QStringLiteral("document-properties")));
editClipMarker->setData(QStringLiteral("edit_marker"));
......@@ -1420,6 +1421,14 @@ void MainWindow::setupActions()
splitAudio->setData('S');
splitAudio->setEnabled(false);
QAction *extractClip = addAction(QStringLiteral("extract_clip"), i18n("Extract Clip"), this, SLOT(slotExtractClip()), QIcon::fromTheme(QStringLiteral("timeline-extract")), QKeySequence(), clipActionCategory);
extractClip->setData('C');
extractClip->setEnabled(false);
QAction *extractToBin = addAction(QStringLiteral("save_to_bin"), i18n("Save Timeline Zone to Bin"), this, SLOT(slotSaveZoneToBin()), QIcon(), QKeySequence(), clipActionCategory);
extractToBin->setData('C');
extractToBin->setEnabled(false);
QAction *switchEnable = addAction(QStringLiteral("clip_switch"), i18n("Disable Clip"), this, SLOT(slotSwitchClip()),
QIcon(), QKeySequence(), clipActionCategory);
// "W" will be handled specifically to change the action name depending on current selection
......@@ -2560,6 +2569,16 @@ void MainWindow::slotExtractZone()
getMainTimeline()->controller()->extractZone(m_clipMonitor->getZoneInfo());
}
void MainWindow::slotExtractClip()
{
getMainTimeline()->controller()->extract();
}
void MainWindow::slotSaveZoneToBin()
{
getMainTimeline()->controller()->saveZone();
}
void MainWindow::slotLiftZone()
{
getMainTimeline()->controller()->extractZone(m_clipMonitor->getZoneInfo(), true);
......
......@@ -475,6 +475,10 @@ private slots:
void slotGrabItem();
/** @brief Collapse or expand current item (depending on focused widget: effet, track)*/
void slotCollapse();
/** @brief Save currently selected timeline clip as bin subclip*/
void slotExtractClip();
/** @brief Save currently selected timeline clip as bin subclip*/
void slotSaveZoneToBin();
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -1707,11 +1707,45 @@ void TimelineController::extractZone(QPoint zone, bool liftOnly)
void TimelineController::extract(int clipId)
{
// TODO: grouped clips?
if (clipId == -1) {
clipId = m_root->property("mainItemId").toInt();
}
int in = m_model->getClipPosition(clipId);
QPoint zone(in, in + m_model->getClipPlaytime(clipId));
int track = m_model->getClipTrackId(clipId);
TimelineFunctions::extractZone(m_model, {track}, zone, false);
int out = in + m_model->getClipPlaytime(clipId);
QVector <int> tracks;
tracks << m_model->getClipTrackId(clipId);
if (m_model->m_groups->isInGroup(clipId)) {
int targetRoot = m_model->m_groups->getRootId(clipId);
if (m_model->isGroup(targetRoot)) {
std::unordered_set<int> sub = m_model->m_groups->getLeaves(targetRoot);
for (int current_id : sub) {
if (current_id == clipId) {
continue;
}
if (m_model->isClip(current_id)) {
int newIn = m_model->getClipPosition(current_id);
int tk = m_model->getClipTrackId(current_id);
in = qMin(in, newIn);
out = qMax(out, newIn + m_model->getClipPlaytime(current_id));
if (!tracks.contains(tk)) {
tracks << tk;
}
}
}
}
}
TimelineFunctions::extractZone(m_model, tracks, QPoint(in, out), false);
}
void TimelineController::saveZone(int clipId)
{
if (clipId == -1) {
clipId = m_root->property("mainItemId").toInt();
}
int in = m_model->getClipIn(clipId);
int out = in + m_model->getClipPlaytime(clipId);
QString id;
pCore->projectItemModel()->requestAddBinSubClip(id, in, out, {}, m_model->m_allClips[clipId]->binId());
}
bool TimelineController::insertClipZone(const QString &binId, int tid, int position)
......
......@@ -340,7 +340,12 @@ public:
Q_INVOKABLE void requestClipCut(int clipId, int position);
Q_INVOKABLE void extract(int clipId);
/** @brief Extract (delete + remove space) current clip
*/
void extract(int clipId = -1);
/** @brief Save current clip cut as bin subclip
*/
void saveZone(int clipId = -1);
Q_INVOKABLE void splitAudio(int clipId);
Q_INVOKABLE void splitVideo(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