]> git.sesse.net Git - kdenlive/commitdiff
Implement track locking:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 3 Feb 2009 02:33:47 +0000 (02:33 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 3 Feb 2009 02:33:47 +0000 (02:33 +0000)
http://www.kdenlive.org:80/mantis/view.php?id=639

svn path=/branches/KDE4/; revision=3030

19 files changed:
icons/hi16-action-kdenlive-lock.png [new file with mode: 0644]
icons/hi16-action-kdenlive-unlock.png [new file with mode: 0644]
src/CMakeLists.txt
src/abstractclipitem.cpp
src/abstractclipitem.h
src/addtimelineclipcommand.h
src/clipitem.cpp
src/customtrackview.cpp
src/customtrackview.h
src/definitions.h
src/headertrack.cpp
src/headertrack.h
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/locktrackcommand.cpp [new file with mode: 0644]
src/locktrackcommand.h [new file with mode: 0644]
src/trackview.cpp
src/trackview.h
src/widgets/trackheader_ui.ui

diff --git a/icons/hi16-action-kdenlive-lock.png b/icons/hi16-action-kdenlive-lock.png
new file mode 100644 (file)
index 0000000..598835f
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 (file)
index 0000000..727f2f8
Binary files /dev/null and b/icons/hi16-action-kdenlive-unlock.png differ
index f7af8e850cbab7681fd2fb55f0018f6c846feece..ba64d308b9d3ca757c3c30854e439f69d2ded208 100644 (file)
@@ -149,6 +149,7 @@ set(kdenlive_SRCS
   dvdwizardvob.cpp
   dvdwizardmenu.cpp
   dvdwizard.cpp
+  locktrackcommand.cpp
 )
 
 add_definitions( ${KDE4_DEFINITIONS} )
index 353fd9b9b0807438b65617accce961cadbba3b3d..9076051e04de9ab0e2c5bc0941af97ee9a3eb654 100644 (file)
@@ -382,3 +382,16 @@ CustomTrackScene* AbstractClipItem::projectScene() {
     if (scene()) return static_cast <CustomTrackScene*>(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));
+}
+
index 33138bfdff35f279fb39ae1103e71794ab57e37e..5d0b835e6b3083f7e70fff95818badd50aed384b 100644 (file)
@@ -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 ;
index b4c3edb0dafb2302a42e01afd297d952c4b0fa85..4138c5a913257e63ae784a5f026083f4805bdad2 100644 (file)
@@ -22,8 +22,6 @@
 #define TIMELINECLIPCOMMAND_H
 
 #include <QUndoCommand>
-#include <QGraphicsView>
-#include <QPointF>
 #include <QDomElement>
 #include <KDebug>
 
index 7a2e6e6ff0c13fb9cda9f6878bbd0cf7c9c97a90..98e9b3c76b359a01fb3299b501eab927e30b6979 100644 (file)
@@ -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) {
index 69d903dd5901a30502301d3953654437251a54b4..733d84bc1f42d8ce0eabd8506758c4d3ea23bd65 100644 (file)
@@ -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<QGraphicsItem *> 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 <AbstractClipItem *>(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<QGraphicsItem *> 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 <AbstractClipItem *>(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 <ClipItem *>(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 <AbstractClipItem *>(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 <ClipItem*>(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 <Transition *>(m_dragItem) : NULL);
+    emit transitionItemSelected((m_dragItem && m_dragItem->type() == TRANSITIONWIDGET && m_dragItem->isSelected()) ? static_cast <Transition *>(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 <ItemInfo> startClip, QList <ItemInfo> 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 <ItemInfo> startClip, QList <ItemInfo> 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 <ItemInfo> startClip, QList <ItemInfo> sta
             AbstractClipItem *item = static_cast <AbstractClipItem *>(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 <ClipItem*>(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);
index e0ef4d802f64f35c85ebef8397fcbb496a1581e4..39256906c868568ac72cbd6bfde97295261e8169 100644 (file)
@@ -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
index 69c3c70221886e4200d47e89d7d96438fe44841b..b18502a9fed812e2096200d358a47c6955d6e9bc 100644 (file)
@@ -56,6 +56,7 @@ struct TrackInfo {
     TRACKTYPE type;
     bool isMute;
     bool isBlind;
+    bool isLocked;
 };
 
 struct ItemInfo {
index 5af3874d009aa1cc6e455a34ba6b3725386a1fdb..87d221238421b41535ed499448996cb5db85a29e 100644 (file)
@@ -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);
 }
index 4c476c523cbc400fee103f3e2f0009a276c3a73e..4950051efca68b1e14e9db6625f366569c053497 100644 (file)
@@ -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);
index 1e42516f67dc9f13818e9276e13934d73029a153..35c81324b04c857e2b3ce95e51adad9f21557553 100644 (file)
@@ -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 <TrackInfo> KdenliveDoc::tracksList() const {
index 24aaea11210d8d44f35f3c69f19f514d8df8ed35..46d8b6382c21c7fc07b783f24cd71626bdbbcd51 100644 (file)
@@ -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 (file)
index 0000000..9d854a8
--- /dev/null
@@ -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 <KLocale>
+
+#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 (file)
index 0000000..0902d2c
--- /dev/null
@@ -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 <QUndoCommand>
+#include <KDebug>
+
+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
+
index 021fbb656b86f14050a9f22ace83e2aab558747f..0e88dd3c81a636dc94ce44f4bfd1dbc0dd1f74b9 100644 (file)
@@ -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<HeaderTrack *> widgets = this->findChildren<HeaderTrack *>();
+    widgets.at(ix)->setLock(lock);
+}
 
 
 #include "trackview.moc"
index 20798f90c1acb9092190cf778ae63b4a45d4252e..2c9467b00bc3d035432e1ba295ab0505ecf532d4 100644 (file)
@@ -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);
index f7bccce0b054888ba3deebd26044b3579a76ca00..f07fbc070f730313a0750bbdcd1d3a80c9ac971a 100644 (file)
@@ -5,23 +5,14 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>50</width>
-    <height>51</height>
+    <width>58</width>
+    <height>54</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout_2" >
-   <property name="leftMargin" >
+   <property name="margin" >
     <number>0</number>
    </property>
-   <property name="topMargin" >
-    <number>2</number>
-   </property>
-   <property name="rightMargin" >
-    <number>0</number>
-   </property>
-   <property name="bottomMargin" >
-    <number>2</number>
-   </property>
    <item row="0" column="0" >
     <widget class="QFrame" name="frame" >
      <property name="frameShape" >
        <number>0</number>
       </property>
       <property name="spacing" >
-       <number>0</number>
+       <number>-1</number>
       </property>
-      <item row="0" column="0" colspan="3" >
+      <item row="0" column="0" >
+       <widget class="QToolButton" name="buttonLock" >
+        <property name="maximumSize" >
+         <size>
+          <width>22</width>
+          <height>22</height>
+         </size>
+        </property>
+        <property name="text" >
+         <string/>
+        </property>
+        <property name="checkable" >
+         <bool>true</bool>
+        </property>
+        <property name="arrowType" >
+         <enum>Qt::NoArrow</enum>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2" >
        <widget class="QLabel" name="track_number" >
         <property name="sizePolicy" >
-         <sizepolicy vsizetype="Maximum" hsizetype="MinimumExpanding" >
+         <sizepolicy vsizetype="Maximum" hsizetype="Expanding" >
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>