]> git.sesse.net Git - kdenlive/blobdiff - src/monitor.cpp
cleanup & fix crash on project saving with Qt 4.5:
[kdenlive] / src / monitor.cpp
index c98060e1b4856a9f02754bfe2a3fd5d13909c975..eb001c65be51bb76b8dbdc098ec199000bcc9b91 100644 (file)
@@ -114,7 +114,6 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
 
 
     connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
-    connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
     connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
     connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
     connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
@@ -128,6 +127,9 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
     if (name != "clip") {
         connect(render, SIGNAL(rendererPosition(int)), this, SIGNAL(renderPosition(int)));
         connect(render, SIGNAL(durationChanged(int)), this, SIGNAL(durationChanged(int)));
+        connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
+    } else {
+        connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SLOT(setClipZone(QPoint)));
     }
     m_monitorRefresh->show();
     kDebug() << "/////// BUILDING MONITOR, ID: " << ui.video_frame->winId();
@@ -259,18 +261,21 @@ GenTime Monitor::getSnapForPos(bool previous) {
 void Monitor::slotZoneMoved(int start, int end) {
     m_ruler->setZone(start, end);
     checkOverlay();
+    setClipZone(m_ruler->zone());
 }
 
 void Monitor::slotSetZoneStart() {
     m_ruler->setZone(m_position, -1);
     emit zoneUpdated(m_ruler->zone());
     checkOverlay();
+    setClipZone(m_ruler->zone());
 }
 
 void Monitor::slotSetZoneEnd() {
     m_ruler->setZone(-1, m_position);
     emit zoneUpdated(m_ruler->zone());
     checkOverlay();
+    setClipZone(m_ruler->zone());
 }
 
 // virtual
@@ -489,10 +494,10 @@ void Monitor::slotRewindOneFrame(int diff) {
     if (m_position < 1) return;
     m_position -= diff;
     m_position = qMax(m_position, 0);
-    checkOverlay();
     render->seekToFrame(m_position);
     emit renderPosition(m_position);
     m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
+    checkOverlay();
 }
 
 void Monitor::slotForwardOneFrame(int diff) {
@@ -501,16 +506,15 @@ void Monitor::slotForwardOneFrame(int diff) {
     if (m_position >= m_length) return;
     m_position += diff;
     m_position = qMin(m_position, m_length);
-    checkOverlay();
     render->seekToFrame(m_position);
     emit renderPosition(m_position);
     m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
+    checkOverlay();
 }
 
 void Monitor::seekCursor(int pos) {
     activateMonitor();
     m_position = pos;
-    //checkOverlay();
     m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
     m_ruler->slotNewValue(pos);
 }
@@ -519,6 +523,7 @@ void Monitor::rendererStopped(int pos) {
     //int rulerPos = (int)(pos * m_scale);
     m_ruler->slotNewValue(pos);
     m_position = pos;
+    checkOverlay();
     m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(pos));
     m_playAction->setChecked(false);
     m_playAction->setIcon(m_playIcon);
@@ -539,6 +544,10 @@ void Monitor::initMonitor() {
 void Monitor::adjustRulerSize(int length) {
     if (length > 0) m_length = length;
     m_ruler->adjustScale(m_length);
+    if (m_currentClip != NULL) {
+        QPoint zone = m_currentClip->zone();
+        m_ruler->setZone(zone.x(), zone.y());
+    }
 }
 
 void Monitor::stop() {
@@ -602,20 +611,15 @@ void Monitor::slotLoopZone() {
 void Monitor::slotSetXml(DocClipBase *clip, const int position) {
     if (render == NULL) return;
     activateMonitor();
-    if (!clip) {
-        kDebug() << "// SETTING NULL CLIP";
+    if (!clip && m_currentClip != NULL) {
         m_currentClip = NULL;
+        render->setProducer(NULL, -1);
         return;
     }
     if (clip != m_currentClip) {
-        if (clip->producer() != NULL) {
-            m_currentClip = clip;
-            render->setProducer(clip->producer(), position);
-            //m_ruler->slotNewValue(0);
-            //adjustRulerSize(clip->producer()->get_playtime());
-            //m_timePos->setText("00:00:00:00");
-            m_position = position;
-        }
+        m_currentClip = clip;
+        render->setProducer(clip->producer(), position);
+        m_position = position;
     } else if (position != -1) render->seek(GenTime(position, render->fps()));
 }
 
@@ -650,11 +654,15 @@ void Monitor::saveSceneList(QString path, QDomElement info) {
     render->saveSceneList(path, info);
 }
 
-QDomDocument Monitor::sceneList() {
-    if (render == NULL) return QDomDocument();
-    QDomDocument doc;
-    doc.setContent(render->sceneList());
-    return doc;
+const QString Monitor::sceneList() {
+    if (render == NULL) return QString();
+    return render->sceneList();
+}
+
+
+void Monitor::setClipZone(QPoint pos) {
+    if (m_currentClip == NULL) return;
+    m_currentClip->setZone(pos);
 }
 
 MonitorRefresh::MonitorRefresh(QWidget* parent): QWidget(parent), m_renderer(NULL) {
@@ -673,7 +681,7 @@ void MonitorRefresh::paintEvent(QPaintEvent * event) {
 
 Overlay::Overlay(QWidget* parent): QLabel(parent) {
     setAttribute(Qt::WA_TransparentForMouseEvents);
-    //setAttribute(Qt::WA_OpaquePaintEvent); //
+    setAttribute(Qt::WA_OpaquePaintEvent);
     //setAttribute(Qt::WA_NoSystemBackground);
     setAutoFillBackground(false);
 }