From: Jean-Baptiste Mardelle Date: Tue, 3 Feb 2009 02:33:47 +0000 (+0000) Subject: Implement track locking: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b93354f1ba8628a6f07b3960dec0ee35dfe4bdd9;p=kdenlive Implement track locking: http://www.kdenlive.org:80/mantis/view.php?id=639 svn path=/branches/KDE4/; revision=3030 --- diff --git a/icons/hi16-action-kdenlive-lock.png b/icons/hi16-action-kdenlive-lock.png new file mode 100644 index 00000000..598835f3 Binary files /dev/null and b/icons/hi16-action-kdenlive-lock.png differ diff --git a/icons/hi16-action-kdenlive-unlock.png b/icons/hi16-action-kdenlive-unlock.png new file mode 100644 index 00000000..727f2f8b Binary files /dev/null and b/icons/hi16-action-kdenlive-unlock.png differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f7af8e85..ba64d308 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -149,6 +149,7 @@ set(kdenlive_SRCS dvdwizardvob.cpp dvdwizardmenu.cpp dvdwizard.cpp + locktrackcommand.cpp ) add_definitions( ${KDE4_DEFINITIONS} ) diff --git a/src/abstractclipitem.cpp b/src/abstractclipitem.cpp index 353fd9b9..9076051e 100644 --- a/src/abstractclipitem.cpp +++ b/src/abstractclipitem.cpp @@ -382,3 +382,16 @@ CustomTrackScene* AbstractClipItem::projectScene() { if (scene()) return static_cast (scene()); return NULL; } + +void AbstractClipItem::setItemLocked(bool locked) { + if (locked) { + setSelected(false); + setFlag(QGraphicsItem::ItemIsMovable, false); + setFlag(QGraphicsItem::ItemIsSelectable, false); + } else setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); +} + +bool AbstractClipItem::isItemLocked() const { + return !(flags() & (QGraphicsItem::ItemIsSelectable)); +} + diff --git a/src/abstractclipitem.h b/src/abstractclipitem.h index 33138bfd..5d0b835e 100644 --- a/src/abstractclipitem.h +++ b/src/abstractclipitem.h @@ -42,6 +42,8 @@ public: CustomTrackScene* projectScene(); void updateRectGeometry(); void updateItem(); + void setItemLocked(bool locked); + bool isItemLocked() const; virtual OPERATIONTYPE operationMode(QPointF pos) = 0; virtual GenTime startPos() const ; diff --git a/src/addtimelineclipcommand.h b/src/addtimelineclipcommand.h index b4c3edb0..4138c5a9 100644 --- a/src/addtimelineclipcommand.h +++ b/src/addtimelineclipcommand.h @@ -22,8 +22,6 @@ #define TIMELINECLIPCOMMAND_H #include -#include -#include #include #include diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 7a2e6e6f..98e9b3c7 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -739,6 +739,8 @@ void ClipItem::paint(QPainter *painter, OPERATIONTYPE ClipItem::operationMode(QPointF pos) { + if (isItemLocked()) return NONE; + if (isSelected()) { m_editedKeyframe = mouseOverKeyFrames(pos); if (m_editedKeyframe != -1) return KEYFRAME; @@ -939,6 +941,7 @@ void ClipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { //virtual void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) { //if (e->pos().x() < 20) m_hover = true; + if (isItemLocked()) return; m_hover = true; QRectF r = boundingRect(); double width = 35 / projectScene()->scale(); @@ -950,6 +953,7 @@ void ClipItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) { //virtual void ClipItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) { + if (isItemLocked()) return; m_hover = false; QRectF r = boundingRect(); double width = 35 / projectScene()->scale(); @@ -1316,7 +1320,8 @@ void ClipItem::dropEvent(QGraphicsSceneDragDropEvent * event) { //virtual void ClipItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) { - event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist")); + if (isItemLocked()) event->setAccepted(false); + else event->setAccepted(event->mimeData()->hasFormat("kdenlive/effectslist")); } void ClipItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) { diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 69d903dd..733d84bc 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -68,6 +68,7 @@ #include "movegroupcommand.h" #include "ui_addtrack_ui.h" #include "initeffects.h" +#include "locktrackcommand.h" //TODO: // disable animation if user asked it in KDE's global settings @@ -652,7 +653,7 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) { return; } updateSnapPoints(m_dragItem); - if (m_dragItem->type() == AVWIDGET) emit clipItemSelected((ClipItem*) m_dragItem); + if (m_dragItem->type() == AVWIDGET && !m_dragItem->isItemLocked()) emit clipItemSelected((ClipItem*) m_dragItem); else emit clipItemSelected(NULL); if (event->modifiers() != Qt::ControlModifier && (m_dragItem->group() || m_dragItem->isSelected())) { @@ -778,8 +779,10 @@ void CustomTrackView::resetSelectionGroup(bool selectItems) { QList children = m_selectionGroup->childItems(); scene()->destroyItemGroup(m_selectionGroup); for (int i = 0; i < children.count(); i++) { - children.at(i)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); - children.at(i)->setSelected(selectItems); + if (!static_cast (children.at(i))->isItemLocked()) { + children.at(i)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + children.at(i)->setSelected(selectItems); + } } m_selectionGroup = NULL; KdenliveSettings::setSnaptopoints(snap); @@ -1407,8 +1410,12 @@ void CustomTrackView::dropEvent(QDropEvent * event) { m_commandStack->push(command); item->baseClip()->addReference(); m_document->updateClip(item->baseClip()->getId()); - ItemInfo info; - info = item->info(); + ItemInfo info = item->info(); + + int tracknumber = m_document->tracksCount() - info.track - 1; + bool isLocked = m_document->trackInfoAt(tracknumber).isLocked; + if (isLocked) item->setItemLocked(true); + if (item->baseClip()->isTransparent()) { // add transparency transition int endTrack = getPreviousVideoTrack(info.track); @@ -1584,15 +1591,39 @@ void CustomTrackView::changeTrack(int ix, TrackInfo type) { void CustomTrackView::slotSwitchTrackAudio(int ix) { /*for (int i = 0; i < m_document->tracksCount(); i++) kDebug() << "TRK " << i << " STATE: " << m_document->trackInfoAt(i).isMute << m_document->trackInfoAt(i).isBlind;*/ - int tracknumber = m_document->tracksCount() - ix; - m_document->switchTrackAudio(tracknumber - 1, !m_document->trackInfoAt(tracknumber - 1).isMute); kDebug() << "NEXT TRK STATE: " << m_document->trackInfoAt(tracknumber - 1).isMute << m_document->trackInfoAt(tracknumber - 1).isBlind; m_document->renderer()->mltChangeTrackState(tracknumber, m_document->trackInfoAt(tracknumber - 1).isMute, m_document->trackInfoAt(tracknumber - 1).isBlind); m_document->setModified(true); } +void CustomTrackView::slotSwitchTrackLock(int ix) { + int tracknumber = m_document->tracksCount() - ix - 1; + LockTrackCommand *command = new LockTrackCommand(this, ix, !m_document->trackInfoAt(tracknumber).isLocked, true); + m_commandStack->push(command); +} + + +void CustomTrackView::lockTrack(int ix, bool lock) { + int tracknumber = m_document->tracksCount() - ix - 1; + m_document->switchTrackLock(tracknumber, lock); + emit doTrackLock(ix, lock); + QList selection = items(0, ix * m_tracksHeight + m_tracksHeight / 2, mapFromScene(sceneRect().width(), 0).x(), m_tracksHeight / 2 - 2); + + for (int i = 0; i < selection.count(); i++) { + if (selection.at(i)->type() != AVWIDGET && selection.at(i)->type() != TRANSITIONWIDGET) continue; + if (selection.at(i)->isSelected()) { + if (selection.at(i)->type() == AVWIDGET) emit clipItemSelected(NULL); + else emit transitionItemSelected(NULL); + } + static_cast (selection.at(i))->setItemLocked(lock); + } + kDebug() << "NEXT TRK STATE: " << m_document->trackInfoAt(tracknumber).isLocked; + viewport()->update(); + m_document->setModified(true); +} + void CustomTrackView::slotSwitchTrackVideo(int ix) { int tracknumber = m_document->tracksCount() - ix; m_document->switchTrackVideo(tracknumber - 1, !m_document->trackInfoAt(tracknumber - 1).isBlind); @@ -1876,6 +1907,10 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) { ClipItem *item = static_cast (m_dragItem); bool success = m_document->renderer()->mltMoveClip((int)(m_document->tracksCount() - m_dragItemInfo.track), (int)(m_document->tracksCount() - m_dragItem->track()), (int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItem->startPos().frames(m_document->fps())), item->baseClip()->producer(info.track)); if (success) { + int tracknumber = m_document->tracksCount() - item->track() - 1; + bool isLocked = m_document->trackInfoAt(tracknumber).isLocked; + if (isLocked) item->setItemLocked(true); + QUndoCommand *moveCommand = new QUndoCommand(); moveCommand->setText(i18n("Move clip")); new MoveClipCommand(this, m_dragItemInfo, info, false, moveCommand); @@ -2001,6 +2036,13 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) { AbstractClipItem *item = static_cast (items.at(i)); item->updateItem(); ItemInfo info = item->info(); + int tracknumber = m_document->tracksCount() - info.track - 1; + bool isLocked = m_document->trackInfoAt(tracknumber).isLocked; + if (isLocked) { + m_selectionGroup->removeFromGroup(item); + item->setItemLocked(true); + } + if (item->type() == AVWIDGET) { ClipItem *clip = static_cast (item); info.track = m_document->tracksCount() - info.track; @@ -2191,7 +2233,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) { updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect(), item->selectedEffectIndex()); } - emit transitionItemSelected((m_dragItem && m_dragItem->type() == TRANSITIONWIDGET) ? static_cast (m_dragItem) : NULL); + emit transitionItemSelected((m_dragItem && m_dragItem->type() == TRANSITIONWIDGET && m_dragItem->isSelected()) ? static_cast (m_dragItem) : NULL); m_document->setModified(true); m_operationMode = NONE; } @@ -2308,6 +2350,11 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i ClipItem *item = new ClipItem(baseclip, info, m_document->fps(), xml.attribute("speed", "1").toDouble()); item->setEffectList(effects); scene()->addItem(item); + + int tracknumber = m_document->tracksCount() - info.track - 1; + bool isLocked = m_document->trackInfoAt(tracknumber).isLocked; + if (isLocked) item->setItemLocked(true); + if (item->baseClip()->isTransparent()) { // add transparency transition int endTrack = getPreviousVideoTrack(info.track); @@ -2442,8 +2489,15 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end) { bool snap = KdenliveSettings::snaptopoints(); KdenliveSettings::setSnaptopoints(false); item->setPos((int) end.startPos.frames(m_document->fps()), (int)(end.track * m_tracksHeight + 1)); + + int tracknumber = m_document->tracksCount() - end.track - 1; + bool isLocked = m_document->trackInfoAt(tracknumber).isLocked; m_scene->clearSelection(); - item->setSelected(true); + if (isLocked) item->setItemLocked(true); + else { + if (item->isItemLocked()) item->setItemLocked(false); + item->setSelected(true); + } if (item->baseClip()->isTransparent()) { // Also move automatic transition Transition *tr = getTransitionItemAt(start.startPos, start.track); @@ -2473,6 +2527,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta } ClipItem *clip = getClipItemAt(startClip.at(i).startPos, startClip.at(i).track); if (clip) { + clip->setItemLocked(false); clip->setSelected(true); m_document->renderer()->mltRemoveClip(m_document->tracksCount() - startClip.at(i).track, startClip.at(i).startPos); } @@ -2484,6 +2539,7 @@ void CustomTrackView::moveGroup(QList startClip, QList sta } Transition *tr = getTransitionItemAt(startTransition.at(i).startPos, startTransition.at(i).track); if (tr) { + tr->setItemLocked(false); tr->setSelected(true); m_document->renderer()->mltDeleteTransition(tr->transitionTag(), tr->transitionEndTrack(), m_document->tracksCount() - startTransition.at(i).track, startTransition.at(i).startPos, startTransition.at(i).endPos, tr->toXML()); } @@ -2509,6 +2565,11 @@ void CustomTrackView::moveGroup(QList startClip, QList sta AbstractClipItem *item = static_cast (children.at(i)); item->updateItem(); ItemInfo info = item->info(); + int tracknumber = m_document->tracksCount() - info.track - 1; + bool isLocked = m_document->trackInfoAt(tracknumber).isLocked; + if (isLocked) item->setItemLocked(true); + else if (item->isItemLocked()) item->setItemLocked(false); + if (item->type() == AVWIDGET) { ClipItem *clip = static_cast (item); info.track = m_document->tracksCount() - info.track; @@ -2928,9 +2989,8 @@ void CustomTrackView::drawBackground(QPainter * painter, const QRectF & rect) { painter->drawLine(r.left(), 0, r.right(), 0); uint max = m_document->tracksCount(); for (uint i = 0; i < max;i++) { - /*if (max - i - 1 == m_selectedTrack) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(QColor(211, 205, 147))); - else*/ - if (m_document->trackInfoAt(max - i - 1).type == AUDIOTRACK) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(QColor(240, 240, 255))); + if (m_document->trackInfoAt(max - i - 1).isLocked == true) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(QColor(250, 250, 100))); + else if (m_document->trackInfoAt(max - i - 1).type == AUDIOTRACK) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(QColor(240, 240, 255))); painter->drawLine(r.left(), m_tracksHeight * (i + 1), r.right(), m_tracksHeight * (i + 1)); } int lowerLimit = m_tracksHeight * m_document->tracksCount() + 1; @@ -3337,10 +3397,12 @@ void CustomTrackView::slotInsertTrack(int ix) { info.type = VIDEOTRACK; info.isMute = false; info.isBlind = false; + info.isLocked = false; } else { info.type = AUDIOTRACK; info.isMute = false; info.isBlind = true; + info.isLocked = false; } AddTrackCommand *addTrack = new AddTrackCommand(this, ix, info, true, true); m_commandStack->push(addTrack); @@ -3372,13 +3434,14 @@ void CustomTrackView::slotChangeTrack(int ix) { if (d.exec() == QDialog::Accepted) { TrackInfo info; + info.isLocked = false; + info.isMute = false; + if (view.video_track->isChecked()) { info.type = VIDEOTRACK; - info.isMute = false; info.isBlind = false; } else { info.type = AUDIOTRACK; - info.isMute = false; info.isBlind = true; } changeTimelineTrack(ix, info); diff --git a/src/customtrackview.h b/src/customtrackview.h index e0ef4d80..39256906 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -108,6 +108,7 @@ public: void autoTransition(); QStringList getLadspaParams(QDomElement effect) const; void initCursorPos(int pos); + void lockTrack(int ix, bool lock); public slots: void setCursorPos(int pos, bool seek = true); @@ -125,6 +126,7 @@ public slots: void slotTransitionTrackUpdated(Transition *tr, int track); void slotSwitchTrackAudio(int ix); void slotSwitchTrackVideo(int ix); + void slotSwitchTrackLock(int ix); void slotUpdateClip(const QString &clipId); void slotAddClipMarker(const QString &id, GenTime t, QString c); bool addGuide(const GenTime pos, const QString &comment); @@ -239,6 +241,7 @@ signals: void trackHeightChanged(); void displayMessage(const QString, MessageType); void showClipFrame(DocClipBase *, const int); + void doTrackLock(int, bool); }; #endif diff --git a/src/definitions.h b/src/definitions.h index 69c3c702..b18502a9 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -56,6 +56,7 @@ struct TrackInfo { TRACKTYPE type; bool isMute; bool isBlind; + bool isLocked; }; struct ItemInfo { diff --git a/src/headertrack.cpp b/src/headertrack.cpp index 5af3874d..87d22123 100644 --- a/src/headertrack.cpp +++ b/src/headertrack.cpp @@ -37,7 +37,12 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, QWidget *parent) view.setupUi(this); view.track_number->setText(QString::number(m_index)); view.buttonVideo->setChecked(!info.isBlind); + view.buttonVideo->setToolTip(i18n("Hide track")); view.buttonAudio->setChecked(!info.isMute); + view.buttonAudio->setToolTip(i18n("Mute track")); + view.buttonLock->setChecked(info.isLocked); + view.buttonLock->setToolTip(i18n("Lock track")); + if (m_type == VIDEOTRACK) { view.frame->setBackgroundRole(QPalette::AlternateBase); view.frame->setAutoFillBackground(true); @@ -48,8 +53,13 @@ HeaderTrack::HeaderTrack(int index, TrackInfo info, QWidget *parent) } if (!info.isMute) view.buttonAudio->setIcon(KIcon("kdenlive-show-audio")); else view.buttonAudio->setIcon(KIcon("kdenlive-hide-audio")); + + if (!info.isLocked) view.buttonLock->setIcon(KIcon("kdenlive-unlock")); + else view.buttonLock->setIcon(KIcon("kdenlive-lock")); + connect(view.buttonVideo, SIGNAL(clicked()), this, SLOT(switchVideo())); connect(view.buttonAudio, SIGNAL(clicked()), this, SLOT(switchAudio())); + connect(view.buttonLock, SIGNAL(clicked()), this, SLOT(switchLock())); m_contextMenu = new QMenu(this); @@ -88,6 +98,21 @@ void HeaderTrack::switchAudio() { emit switchTrackAudio(m_index); } +void HeaderTrack::switchLock(bool emitSignal) { + if (view.buttonLock->isChecked()) { + view.buttonLock->setIcon(KIcon("kdenlive-lock")); + } else { + view.buttonLock->setIcon(KIcon("kdenlive-unlock")); + } + if (emitSignal) emit switchTrackLock(m_index); +} + + +void HeaderTrack::setLock(bool lock) { + view.buttonLock->setChecked(lock); + switchLock(false); +} + void HeaderTrack::slotDeleteTrack() { emit deleteTrack(m_index); } diff --git a/src/headertrack.h b/src/headertrack.h index 4c476c52..4950051e 100644 --- a/src/headertrack.h +++ b/src/headertrack.h @@ -32,6 +32,7 @@ class HeaderTrack : public QWidget { public: HeaderTrack(int index, TrackInfo info, QWidget *parent = 0); ~HeaderTrack(); + void setLock(bool lock); protected: //virtual void paintEvent(QPaintEvent * /*e*/); @@ -49,10 +50,12 @@ private slots: void slotDeleteTrack(); void slotAddTrack(); void slotChangeTrack(); + void switchLock(bool emitSignal = true); signals: void switchTrackAudio(int); void switchTrackVideo(int); + void switchTrackLock(int); void insertTrack(int); void deleteTrack(int); void changeTrack(int); diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 1e42516f..35c81324 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -97,11 +97,14 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup videoTrack.type = VIDEOTRACK; videoTrack.isMute = false; videoTrack.isBlind = false; + videoTrack.isLocked = false; TrackInfo audioTrack; audioTrack.type = AUDIOTRACK; audioTrack.isMute = false; audioTrack.isBlind = true; + audioTrack.isLocked = false; + for (int i = 0; i < xmltracks.size(); i++) { if (xmltracks.data()[i] == 'v') m_tracksList.append(videoTrack); else m_tracksList.append(audioTrack); @@ -239,11 +242,13 @@ QDomDocument KdenliveDoc::createEmptyDocument(const int videotracks, const int a videoTrack.type = VIDEOTRACK; videoTrack.isMute = false; videoTrack.isBlind = false; + videoTrack.isLocked = false; TrackInfo audioTrack; audioTrack.type = AUDIOTRACK; audioTrack.isMute = false; audioTrack.isBlind = true; + audioTrack.isLocked = false; QDomElement tractor = doc.createElement("tractor"); tractor.setAttribute("id", "maintractor"); @@ -1460,6 +1465,10 @@ void KdenliveDoc::switchTrackAudio(int ix, bool hide) { m_tracksList[ix].isMute = hide; // !m_tracksList.at(ix).isMute; } +void KdenliveDoc::switchTrackLock(int ix, bool lock) { + m_tracksList[ix].isLocked = lock; +} + void KdenliveDoc::switchTrackVideo(int ix, bool hide) { m_tracksList[ix].isBlind = hide; // !m_tracksList.at(ix).isBlind; } @@ -1477,6 +1486,7 @@ void KdenliveDoc::setTrackType(int ix, TrackInfo type) { m_tracksList[ix].type = type.type; m_tracksList[ix].isMute = type.isMute; m_tracksList[ix].isBlind = type.isBlind; + m_tracksList[ix].isLocked = type.isLocked; } const QList KdenliveDoc::tracksList() const { diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 24aaea11..46d8b638 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -108,6 +108,7 @@ Q_OBJECT public: QString getTracksInfo() const; void switchTrackVideo(int ix, bool hide); void switchTrackAudio(int ix, bool hide); + void switchTrackLock(int ix, bool lock); void cachePixmap(const QString &fileId, const QPixmap &pix) const; void setProjectFolder(KUrl url); QString getLadspaFile() const; diff --git a/src/locktrackcommand.cpp b/src/locktrackcommand.cpp new file mode 100644 index 00000000..9d854a80 --- /dev/null +++ b/src/locktrackcommand.cpp @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include + +#include "locktrackcommand.h" +#include "customtrackview.h" + +LockTrackCommand::LockTrackCommand(CustomTrackView *view, int ix, bool lock, bool doIt, QUndoCommand * parent) : QUndoCommand(parent), m_view(view), m_ix(ix), m_lock(lock), m_doIt(doIt) { + if (lock) setText(i18n("Lock track")); + else setText(i18n("Unlock track")); +} + + +// virtual +void LockTrackCommand::undo() { + m_view->lockTrack(m_ix, !m_lock); +} +// virtual +void LockTrackCommand::redo() { + if (m_doIt) { + m_view->lockTrack(m_ix, m_lock); + } + m_doIt = true; +} + + diff --git a/src/locktrackcommand.h b/src/locktrackcommand.h new file mode 100644 index 00000000..0902d2cf --- /dev/null +++ b/src/locktrackcommand.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef LOCKTRACKCOMMAND_H +#define LOCKTRACKCOMMAND_H + +#include +#include + +class CustomTrackView; + +class LockTrackCommand : public QUndoCommand { +public: + LockTrackCommand(CustomTrackView *view, int ix, bool lock, bool doIt, QUndoCommand * parent = 0); + virtual void undo(); + virtual void redo(); + +private: + CustomTrackView *m_view; + int m_ix; + bool m_doIt; + bool m_lock; +}; + +#endif + diff --git a/src/trackview.cpp b/src/trackview.cpp index 021fbb65..0e88dd3c 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -83,6 +83,8 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int))); connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int))); connect(m_trackview, SIGNAL(transitionItemSelected(Transition*, bool)), this, SLOT(slotTransitionItemSelected(Transition*, bool))); + connect(m_trackview, SIGNAL(doTrackLock(int, bool)), this, SLOT(slotChangeTrackLock(int, bool))); + slotChangeZoom(m_doc->zoom()); slotSetZone(m_doc->zone()); } @@ -357,6 +359,7 @@ void TrackView::slotRebuildTrackHeaders() { HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), this); connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int))); connect(header, SIGNAL(switchTrackAudio(int)), m_trackview, SLOT(slotSwitchTrackAudio(int))); + connect(header, SIGNAL(switchTrackLock(int)), m_trackview, SLOT(slotSwitchTrackLock(int))); connect(header, SIGNAL(deleteTrack(int)), this, SIGNAL(deleteTrack(int))); connect(header, SIGNAL(insertTrack(int)), this, SIGNAL(insertTrack(int))); @@ -660,6 +663,10 @@ const QString & TrackView::editMode() const { return m_editMode; } +void TrackView::slotChangeTrackLock(int ix, bool lock) { + QList widgets = this->findChildren(); + widgets.at(ix)->setLock(lock); +} #include "trackview.moc" diff --git a/src/trackview.h b/src/trackview.h index 20798f90..2c9467b0 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -92,7 +92,7 @@ private slots: void moveCursorPos(int pos); void slotTransitionItemSelected(Transition*, bool update); void slotRebuildTrackHeaders(); - + void slotChangeTrackLock(int ix, bool lock); signals: void mousePosition(int); diff --git a/src/widgets/trackheader_ui.ui b/src/widgets/trackheader_ui.ui index f7bccce0..f07fbc07 100644 --- a/src/widgets/trackheader_ui.ui +++ b/src/widgets/trackheader_ui.ui @@ -5,23 +5,14 @@ 0 0 - 50 - 51 + 58 + 54 - + 0 - - 2 - - - 0 - - - 2 - @@ -35,12 +26,31 @@ 0 - 0 + -1 - + + + + + 22 + 22 + + + + + + + true + + + Qt::NoArrow + + + + - + 0 0