Commit 604b8507 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Add icon in timeline toolbar for same track mix

parent ba564eda
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="192" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="193" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="file_save"/>
......@@ -271,6 +271,7 @@
<Separator />
<Action name="timeline_timecode" />
<Separator />
<Action name="mix_clip" />
<Action name="insert_to_in_point" />
<Action name="overwrite_to_in_point" />
<Action name="remove_extract" />
......
......@@ -1131,10 +1131,10 @@ void MainWindow::setupActions()
addAction(QStringLiteral("collapse_expand"), collapseItem, Qt::Key_Less);
connect(collapseItem, &QAction::triggered, this, &MainWindow::slotCollapse);
QAction *sameTrack = new QAction(QIcon::fromTheme(QStringLiteral("collapse-all")), i18n("Same Track"), this);
addAction(QStringLiteral("same_track"), sameTrack, Qt::Key_U);
QAction *sameTrack = new QAction(QIcon::fromTheme(QStringLiteral("composite-track-preview")), i18n("Mix Clips"), this);
addAction(QStringLiteral("mix_clip"), sameTrack, Qt::Key_U);
connect(sameTrack, &QAction::triggered, [this]() {
getCurrentTimeline()->controller()->sameTrack();
getCurrentTimeline()->controller()->mixClip();
});
// toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
......
......@@ -3665,45 +3665,20 @@ void TimelineController::addTracks(int videoTracks, int audioTracks)
}
}
void TimelineController::sameTrack()
void TimelineController::mixClip()
{
qDebug()<<"=== PROCESS SAME TRACK COMPO";
auto sel = m_model->getCurrentSelection();
if (sel.empty()) {
return;
}
QList <int> selectedItems;
int selectedTrack = -1;
for (int s : sel) {
int tid = m_model->getItemTrackId(s);
if (selectedTrack == -1) {
selectedTrack = tid;
selectedItems << s;
} else if (tid == selectedTrack) {
// We found our second clip
selectedItems << s;
break;
}
}
if (selectedItems.count() == 2) {
int mixPosition;
int idToMove;
if (m_model->getItemPosition(selectedItems.at(0)) < m_model->getItemPosition(selectedItems.at(1))) {
mixPosition = m_model->getItemPosition(selectedItems.at(0)) + m_model->getItemPlaytime(selectedItems.at(0)) - 75;
idToMove = selectedItems.at(1);
} else {
mixPosition = m_model->getItemPosition(selectedItems.at(1)) + m_model->getItemPlaytime(selectedItems.at(1)) - 75;
idToMove = selectedItems.at(0);
}
/*if (m_model->m_groups->isInGroup(idToMove)) {
// TODO
} else*/ {
std::function<bool(void)> undo = []() { return true; };
std::function<bool(void)> redo = []() { return true; };
bool result = m_model->requestClipMixMove(idToMove, selectedTrack, mixPosition, true, true, true, undo, redo, false);
pCore->pushUndo(undo, redo, i18n("Create mix"));
}
//m_model->getTrackById(selectedTrack)->mergeClips(selectedItems);
}
int idToMove = *sel.begin();
// Mix duration currently hardcoded to 75 frames
int mixPosition = m_model->getItemPosition(idToMove) - 75;
std::function<bool(void)> undo = []() { return true; };
std::function<bool(void)> redo = []() { return true; };
int selectedTrack = m_model->getItemTrackId(idToMove);
bool result = m_model->requestClipMixMove(idToMove, selectedTrack, mixPosition, true, true, true, undo, redo, false);
pCore->pushUndo(undo, redo, i18n("Create mix"));
}
......@@ -557,7 +557,7 @@ public:
/** @brief Get in/out of currently selected items */
QPoint selectionInOut() const;
/** @brief Create same track transition between clips */
void sameTrack();
void mixClip();
public slots:
void resetView();
......
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