]> git.sesse.net Git - kdenlive/commitdiff
moving cutter tool over a clip now shows the frame to be cut in clip monitor
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 23 Jun 2008 21:17:32 +0000 (21:17 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 23 Jun 2008 21:17:32 +0000 (21:17 +0000)
svn path=/branches/KDE4/; revision=2268

src/customtrackview.cpp
src/customtrackview.h
src/mainwindow.cpp
src/markerdialog.cpp
src/monitor.cpp
src/monitor.h
src/projectlist.cpp
src/projectlist.h

index 27f47e9a87298fbabe54477454eaba4f7a3fc22f..93a0a2b41d8e8a30560feeb4bd30103258b39f4f 100644 (file)
@@ -226,8 +226,8 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) {
 
     if (m_tool == RAZORTOOL) {
         setCursor(m_razorCursor);
-        QGraphicsView::mouseMoveEvent(event);
-        return;
+        //QGraphicsView::mouseMoveEvent(event);
+        //return;
     }
 
     QList<QGraphicsItem *> itemList = items(event->pos());
@@ -245,6 +245,14 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event) {
 
     if (item && event->buttons() == Qt::NoButton) {
         AbstractClipItem *clip = (AbstractClipItem*) item;
+               if (m_tool == RAZORTOOL) {
+                       // razor tool over a clip, display current frame in monitor
+                       if (item->type() == AVWIDGET) {
+                               emit showClipFrame(((ClipItem *) item)->baseClip(), mapToScene(event->pos()).x() / m_scale - (clip->startPos() - clip->cropStart()).frames(m_document->fps()));
+                       }
+                       QGraphicsView::mouseMoveEvent(event);
+                       return;
+               }
         opMode = clip->operationMode(mapToScene(event->pos()), m_scale);
         double size = 8;
         if (opMode == m_moveOpMode) {
@@ -454,7 +462,10 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) {
                 QGraphicsItem *item = collisionList.at(i);
                 if (item->type() == AVWIDGET || item->type() == TRANSITIONWIDGET) {
                     if (m_tool == RAZORTOOL) {
-                        if (item->type() == TRANSITIONWIDGET) return;
+                        if (item->type() == TRANSITIONWIDGET) {
+                                                       emit displayMessage(i18n("Cannot cut a transition"), ErrorMessage);
+                                                       return;
+                                               }
                         AbstractClipItem *clip = (AbstractClipItem *) item;
                         ItemInfo info;
                         info.startPos = clip->startPos();
index a10e2d77ed84ff07333c1c87eeeaba6f5f138dd4..8394ca0dc3c0caae7007e1cb2a9193f4b6f13ca0 100644 (file)
@@ -172,6 +172,7 @@ signals:
     void activateDocumentMonitor();
     void trackHeightChanged();
     void displayMessage(const QString, MessageType);
+       void showClipFrame(DocClipBase *, const int);
 };
 
 #endif
index fd47bc2763f571854db495e651643e30df111047..22b0937139d0abba3de29781c15e0e74f2df7663 100644 (file)
@@ -829,6 +829,8 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
             disconnect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
             disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int)));
             disconnect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
+                       disconnect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
+
             disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
             disconnect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
             disconnect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
@@ -839,12 +841,12 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
             disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
         }
         m_activeDocument->setRenderer(NULL);
-        disconnect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
+        disconnect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
         m_clipMonitor->stop();
     }
     m_monitorManager->resetProfiles(doc->profilePath());
     m_projectList->setDocument(doc);
-    connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
+    connect(m_projectList, SIGNAL(clipSelected(DocClipBase *)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *)));
     connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor()));
     connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
     connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int)));
@@ -870,6 +872,8 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
     connect(trackView->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
 
+    connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, const int)));
+
 
     connect(effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement)));
     connect(effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement)));
index 49adf09dbc38058fd9c4b69639b8ca7e0a402b77..0a93cf72173fe07b1764cadac859f774dcd5f342 100644 (file)
@@ -52,7 +52,7 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, QWid
 
     m_view.marker_comment->selectAll();
     m_view.marker_comment->setFocus();
-    QPixmap p;
+    QPixmap p((int) (100 * m_dar), 100);
     QString colour = clip->getProperty("colour");
     switch (m_clip->clipType()) {
     case VIDEO:
@@ -66,11 +66,9 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, QWid
         break;
     case COLOR:
         colour = colour.replace(0, 2, "#");
-        p = QPixmap(m_view.clip_thumb->width(), m_view.clip_thumb->height());
         p.fill(QColor(colour.left(7)));
         break;
     default:
-        p = QPixmap(m_view.clip_thumb->width(), m_view.clip_thumb->height());
         p.fill(Qt::black);
     }
     if (!p.isNull()) {
index 155d0a71544c4c63e0b477eba75abb56ab385091..6e06e26f446973f9979509ea8085812f672867b2 100644 (file)
 #include "renderer.h"
 #include "monitormanager.h"
 #include "smallruler.h"
+#include "docclipbase.h"
 
 Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
-        : QWidget(parent), render(NULL), m_monitorManager(manager), m_name(name), m_isActive(false) {
+        : QWidget(parent), render(NULL), m_monitorManager(manager), m_name(name), m_isActive(false), m_currentClip(NULL) {
     ui.setupUi(this);
     m_scale = 1;
     m_ruler = new SmallRuler();
@@ -263,18 +264,22 @@ void Monitor::slotPlay() {
     m_playAction->setIcon(m_pauseIcon);
 }
 
-void Monitor::slotSetXml(const QDomElement &e) {
+void Monitor::slotSetXml(DocClipBase *clip, const int position) {
     if (render == NULL) return;
     if (!m_isActive) m_monitorManager->activateMonitor(m_name);
-    if (e.isNull()) return;
-    QDomDocument doc;
-    QDomElement westley = doc.createElement("westley");
-    doc.appendChild(westley);
-    westley.appendChild(e);
-    render->setSceneList(doc, 0);
-    m_ruler->slotNewValue(0);
-    m_timePos->setText("00:00:00:00");
-    m_position = 0;
+    if (!clip) return;
+       if (clip != m_currentClip) {
+               m_currentClip = clip;
+               QDomDocument doc;
+               QDomElement westley = doc.createElement("westley");
+               doc.appendChild(westley);
+               westley.appendChild(doc.importNode(m_currentClip->toXML(), true));
+               render->setSceneList(doc, 0);
+               m_ruler->slotNewValue(0);
+               m_timePos->setText("00:00:00:00");
+               m_position = 0;
+       }
+       if (position != -1) render->seek(GenTime(position, render->fps()));
 }
 
 void Monitor::slotOpenFile(const QString &file) {
index cccb6392aff157611b828c176b1adc4fadafb200..7e1c486813c9a74f81904f15b563a6df2d18555b 100644 (file)
@@ -31,6 +31,7 @@
 class MonitorManager;
 class Render;
 class SmallRuler;
+class DocClipBase;
 
 class MonitorRefresh : public QWidget {
     Q_OBJECT
@@ -73,6 +74,7 @@ private:
     KRestrictedLine *m_timePos;
     QAction *m_playAction;
     QMenu *m_contextMenu;
+       DocClipBase *m_currentClip;
 
 private slots:
     void adjustRulerSize(int length);
@@ -82,7 +84,7 @@ private slots:
 
 public slots:
     void slotOpenFile(const QString &);
-    void slotSetXml(const QDomElement &e);
+    void slotSetXml(DocClipBase *clip, const int position = -1);
     void initMonitor();
     void refreshMonitor(bool visible);
     void slotSeek(int pos);
index 60eae55ff22db1a5d0f617cecb5ba56874697d81..b5cb34959f5d1876926b572a75107628896281f4 100644 (file)
@@ -129,7 +129,7 @@ ProjectList::~ProjectList() {
 
 void ProjectList::slotEditClip() {
     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
-    if (item && !item->isGroup()) emit clipSelected(item->toXml());
+    if (item && !item->isGroup()) emit clipSelected(item->referencedClip());
     emit showClipProperties(item->referencedClip());
 }
 
@@ -144,11 +144,11 @@ void ProjectList::slotClipSelected() {
     if (item && !item->isGroup()) {
         if (item == m_selectedItem) {
             // if user clicked on the active clip item, just focus monitor, don't update it.
-            emit clipSelected(QDomElement());
+            emit clipSelected(NULL);
             return;
         }
         m_selectedItem = item;
-        emit clipSelected(item->toXml());
+        emit clipSelected(item->referencedClip());
     }
 }
 
index 27ee804d198774fdc22a2fbb6bc902334c215cc8..c6176c4b840909d8549b19978882c56c35def8df 100644 (file)
@@ -154,7 +154,7 @@ private slots:
 
 
 signals:
-    void clipSelected(const QDomElement &);
+    void clipSelected(DocClipBase *);
     void getFileProperties(const QDomElement&, int);
     void receivedClipDuration(int, int);
     void showClipProperties(DocClipBase *);