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

Copy/paste in timeline through usual shortcuts (groups todo)

parent 61fb3de0
......@@ -2864,22 +2864,12 @@ void MainWindow::slotSetTool(ProjectTool tool)
void MainWindow::slotCopy()
{
//TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->copyClip();
}
*/
getMainTimeline()->controller()->copyItem();
}
void MainWindow::slotPaste()
{
//TODO refac
/*
if (pCore->projectManager()->currentTimeline()) {
pCore->projectManager()->currentTimeline()->projectView()->pasteClip();
}
*/
getMainTimeline()->controller()->pasteItem();
}
void MainWindow::slotPasteEffects()
......
......@@ -462,7 +462,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
bool TimelineModel::requestClipCopy(int clipId, int trackId, int position, int &id)
{
int in = getClipIn(clipId);
int out = in + getClipPlaytime(clipId);
int out = in + getClipPlaytime(clipId) - 1;
QString clipData = QString("%1#%2#%3").arg(getClipBinId(clipId)).arg(in).arg(out);
QWriteLocker locker(&m_lock);
......
......@@ -83,6 +83,10 @@ Rectangle {
return (scrollView.flickableItem.contentX + tracksArea.mouseX) / timeline.scaleFactor;
}
function getMouseTrack() {
return Logic.getTrackIdFromPos(tracksArea.mouseY - ruler.height)
}
function getTrackColor(audio, header) {
var col = activePalette.alternateBase
if (audio) {
......@@ -258,7 +262,7 @@ Rectangle {
onTriggered: {
var track = Logic.getTrackIdFromPos(menu.clickedY - ruler.height)
var frame = Math.round((menu.clickedX + scrollView.flickableItem.contentX) / timeline.scaleFactor)
timeline.copyClip(copiedClip, track, frame)
timeline.pasteItem(copiedClip, track, frame)
}
}
MenuItem {
......
......@@ -300,9 +300,31 @@ void TimelineController::deleteSelectedClips()
}
}
int TimelineController::copyClip(int clipId, int tid, int position)
void TimelineController::copyItem()
{
int clipId = -1;
if (!m_selection.selectedClips.isEmpty()) {
clipId = m_selection.selectedClips.first();
} else {
return;
}
m_root->setProperty("copiedClip", clipId);
}
int TimelineController::pasteItem(int clipId, int tid, int position)
{
int id;
//TODO: copy multiple clips / groups
if (clipId == -1) {
clipId = m_root->property("copiedClip").toInt();
if (clipId == -1) {
return -1;
}
}
if (tid == -1 && position == -1) {
tid = getMouseTrack();
position = getMousePos();
}
if (tid == -1) {
QVariant returnedValue;
QMetaObject::invokeMethod(m_root, "currentTrackId", Q_RETURN_ARG(QVariant, returnedValue));
......@@ -311,11 +333,13 @@ int TimelineController::copyClip(int clipId, int tid, int position)
if (position == -1) {
position = m_position;
}
qDebug()<< "PASTING CLIP: "<<clipId<<", "<<tid<<", "<<position;
if (m_model->isClip(clipId)) {
if (!m_model->requestClipCopy(clipId, tid, position, id)) {
id = -1;
}
}
//TODO copy composition
return id;
}
......@@ -639,6 +663,13 @@ int TimelineController::getMousePos()
return returnedValue.toInt();
}
int TimelineController::getMouseTrack()
{
QVariant returnedValue;
QMetaObject::invokeMethod(m_root, "getMouseTrack", Q_RETURN_ARG(QVariant, returnedValue));
return returnedValue.toInt();
}
void TimelineController::refreshItem(int id)
{
int in = m_model->getItemPosition(id);
......
......@@ -109,8 +109,8 @@ public:
@return the id of the inserted clip
*/
Q_INVOKABLE int insertClip(int tid, int position, const QString &xml, bool logUndo, bool refreshView);
Q_INVOKABLE int copyClip(int clipId, int tid, int position);
Q_INVOKABLE void copyItem();
Q_INVOKABLE int pasteItem(int clipId = -1, int tid = -1, int position = -1);
/* @brief Request inserting a new composition in timeline (dragged from compositions list)
@param tid is the destination track
@param position is the timeline position
......@@ -246,6 +246,9 @@ public:
/* @brief Get the frame where mouse is positionned
*/
int getMousePos();
/* @brief Get the frame where mouse is positionned
*/
int getMouseTrack();
/* @brief Returns a map of track ids/track names
*/
QMap<int, QString> getTrackNames(bool videoOnly);
......
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