Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Insert / remove space menu

parent 246da15c
......@@ -2381,26 +2381,17 @@ void MainWindow::slotAddGuide()
void MainWindow::slotInsertSpace()
{
//TODO
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->slotInsertSpace();
}
getMainTimeline()->controller()->insertSpace();
}
void MainWindow::slotRemoveSpace()
{
//TODO
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->slotRemoveSpace();
}
getMainTimeline()->controller()->removeSpace(-1, -1, false);
}
void MainWindow::slotRemoveAllSpace()
{
//TODO
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->slotRemoveSpace(true);
}
getMainTimeline()->controller()->removeSpace(-1, -1, true);
}
void MainWindow::slotInsertTrack()
......
......@@ -248,6 +248,22 @@ bool TrackModel::requestClipDeletion(int clipId, bool updateView, Fun &undo, Fun
return false;
}
int TrackModel::getBlankSizeAtPos(int frame)
{
READ_LOCK();
int min_length = 0;
for (int i = 0; i < 2; ++i) {
int ix = m_playlists[i].get_clip_index_at(frame);
if (m_playlists[i].is_blank(ix)) {
int blank_length = m_playlists[i].clip_length(ix);
if (min_length == 0 || (blank_length > 0 && blank_length < min_length)) {
min_length = blank_length;
}
}
}
return min_length;
}
int TrackModel::getBlankSizeNearClip(int clipId, bool after)
{
READ_LOCK();
......
......@@ -144,6 +144,7 @@ protected:
*/
int getBlankSizeNearClip(int clipId, bool after);
int getBlankSizeNearComposition(int compoId, bool after);
int getBlankSizeAtPos(int frame);
/*@brief Returns the (unique) construction id of the track*/
int getId() const;
......
......@@ -261,6 +261,22 @@ Rectangle {
timeline.insertSpace(track, frame);
}
}
MenuItem {
text: i18n('Remove Space On Active Track')
onTriggered: {
var track = Logic.getTrackIdFromPos(menu.clickedY - ruler.height)
var frame = Math.round((menu.clickedX + scrollView.flickableItem.contentX) / timeline.scaleFactor)
timeline.removeSpace(track, frame);
}
}
MenuItem {
text: i18n('Remove Space')
onTriggered: {
var track = Logic.getTrackIdFromPos(menu.clickedY - ruler.height)
var frame = Math.round((menu.clickedX + scrollView.flickableItem.contentX) / timeline.scaleFactor)
timeline.removeSpace(track, frame, true);
}
}
MenuItem {
id: addGuideMenu
text: i18n('Add Guide')
......
......@@ -888,6 +888,11 @@ void TimelineController::insertSpace(int trackId, int frame)
if (frame == -1) {
frame = m_position;
}
if (trackId == -1) {
QVariant returnedValue;
QMetaObject::invokeMethod(m_root, "currentTrackId", Q_RETURN_ARG(QVariant, returnedValue));
trackId = returnedValue.toInt();
}
QPointer<SpacerDialog> d = new SpacerDialog(GenTime(65, pCore->getCurrentFps()), pCore->currentDoc()->timecode(), qApp->activeWindow());
if (d->exec() != QDialog::Accepted) {
delete d;
......@@ -903,3 +908,25 @@ void TimelineController::insertSpace(int trackId, int frame)
int start = m_model->getItemPosition(cid);
requestSpacerEndOperation(cid, start, start + spaceDuration);
}
void TimelineController::removeSpace(int trackId, int frame, bool affectAllTracks)
{
if (frame == -1) {
frame = m_position;
}
if (trackId == -1) {
QVariant returnedValue;
QMetaObject::invokeMethod(m_root, "currentTrackId", Q_RETURN_ARG(QVariant, returnedValue));
trackId = returnedValue.toInt();
}
// find blank duration
int spaceDuration = m_model->getTrackById(trackId)->getBlankSizeAtPos(frame);
int cid = requestSpacerStartOperation(affectAllTracks ? -1 : trackId, frame);
if (cid == -1) {
pCore->displayMessage(i18n("No clips found to insert space"), InformationMessage, 500);
return;
}
int start = m_model->getItemPosition(cid);
requestSpacerEndOperation(cid, start, start - spaceDuration);
}
......@@ -215,7 +215,8 @@ public:
Q_INVOKABLE const QString getTrackNameFromMltIndex(int trackPos);
/* @brief Request inserting space in a track
*/
Q_INVOKABLE void insertSpace(int trackId, int frame);
Q_INVOKABLE void insertSpace(int trackId = -1, int frame = -1);
Q_INVOKABLE void removeSpace(int trackId = -1, int frame = -1, bool affectAllTracks = false);
const QString getTrackNameFromIndex(int trackIndex);
/* @brief Seeks to selected clip start / end
......
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