]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Add subclips (dragging a zone from clip monitor to project tree)
[kdenlive] / src / clipitem.cpp
index 92f9b565907c8a566b6c2225814b77624cd5e268..0b657927c2b1b20d56bbf8382a52525430115bea 100644 (file)
@@ -68,16 +68,16 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
     m_videoPix = KIcon("kdenlive-show-video").pixmap(QSize(16, 16));
     m_audioPix = KIcon("kdenlive-show-audio").pixmap(QSize(16, 16));
 
-    if (m_speed == 1.0) m_clipName = clip->name();
+    if (m_speed == 1.0) m_clipName = m_clip->name();
     else {
-        m_clipName = clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
+        m_clipName = m_clip->name() + " - " + QString::number(m_speed * 100, 'f', 0) + '%';
     }
-    m_producer = clip->getId();
-    m_clipType = clip->clipType();
+    m_producer = m_clip->getId();
+    m_clipType = m_clip->clipType();
     //m_cropStart = info.cropStart;
-    m_maxDuration = clip->maxDuration();
+    m_maxDuration = m_clip->maxDuration();
     setAcceptDrops(true);
-    m_audioThumbReady = clip->audioThumbCreated();
+    m_audioThumbReady = m_clip->audioThumbCreated();
     //setAcceptsHoverEvents(true);
     connect(this , SIGNAL(prepareAudioThumb(double, int, int, int)) , this, SLOT(slotPrepareAudioThumb(double, int, int, int)));
 
@@ -89,31 +89,26 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
         m_endThumbTimer.setSingleShot(true);
         connect(&m_endThumbTimer, SIGNAL(timeout()), this, SLOT(slotGetEndThumb()));
 
-        connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
-        //connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(getVideoThumbs(int, int)));
+        connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
 
-        connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
-        connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+        connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+        connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
         if (generateThumbs) QTimer::singleShot(200, this, SLOT(slotFetchThumbs()));
 
-        /*if (m_clip->producer()) {
-            videoThumbProducer.init(this, m_clip->producer(), KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio(), KdenliveSettings::trackheight());
-            slotFetchThumbs();
-        }*/
     } else if (m_clipType == COLOR) {
-        QString colour = clip->getProperty("colour");
+        QString colour = m_clip->getProperty("colour");
         colour = colour.replace(0, 2, "#");
         m_baseColor = QColor(colour.left(7));
     } else if (m_clipType == IMAGE || m_clipType == TEXT) {
         m_baseColor = QColor(141, 166, 215);
         if (m_clipType == TEXT) {
-            connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
-            connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
+            connect(this, SIGNAL(getThumb(int, int)), m_clip->thumbProducer(), SLOT(extractImage(int, int)));
+            connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
         }
         //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
     } else if (m_clipType == AUDIO) {
         m_baseColor = QColor(141, 215, 166);
-        connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
+        connect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
     }
 }
 
@@ -121,6 +116,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, i
 ClipItem::~ClipItem()
 {
     blockSignals(true);
+    if (scene()) scene()->removeItem(this);
     if (m_clipType == VIDEO || m_clipType == AV || m_clipType == SLIDESHOW || m_clipType == PLAYLIST) {
         disconnect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QImage)), this, SLOT(slotThumbReady(int, QImage)));
         disconnect(m_clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
@@ -132,7 +128,7 @@ ClipItem *ClipItem::clone(ItemInfo info) const
 {
     ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed, m_strobe);
     if (m_clipType == IMAGE || m_clipType == TEXT) duplicate->slotSetStartThumb(m_startPix);
-    else {
+    else if (m_clipType != COLOR) {
         if (info.cropStart == m_info.cropStart) duplicate->slotSetStartThumb(m_startPix);
         if (info.cropStart + (info.endPos - info.startPos) == m_info.cropStart + (m_info.endPos - m_info.startPos)) duplicate->slotSetEndThumb(m_endPix);
     }
@@ -463,7 +459,7 @@ void ClipItem::refreshClip(bool checkDuration)
 
 void ClipItem::slotFetchThumbs()
 {
-    if (scene() == NULL) return;
+    if (scene() == NULL || m_clipType == AUDIO || m_clipType == COLOR) return;
     if (m_clipType == IMAGE) {
         if (m_startPix.isNull()) {
             m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
@@ -489,35 +485,18 @@ void ClipItem::slotFetchThumbs()
             slotGetStartThumb();
         }
     }
-    /*
-        if (m_hasThumbs) {
-            if (m_endPix.isNull() && m_startPix.isNull()) {
-                int frame1 = (int)m_cropStart.frames(m_fps);
-                int frame2 = (int)(m_cropStart + m_cropDuration).frames(m_fps) - 1;
-                //videoThumbProducer.setThumbFrames(m_clip->producer(), frame1, frame2);
-                //videoThumbProducer.start(QThread::LowestPriority);
-            } else {
-                if (m_endPix.isNull()) slotGetEndThumb();
-                else slotGetStartThumb();
-            }
-
-        } else if (m_startPix.isNull()) slotGetStartThumb();*/
 }
 
 void ClipItem::slotGetStartThumb()
 {
     m_startThumbRequested = true;
     emit getThumb((int)m_speedIndependantInfo.cropStart.frames(m_fps), -1);
-    //videoThumbProducer.setThumbFrames(m_clip->producer(), (int)m_cropStart.frames(m_fps),  - 1);
-    //videoThumbProducer.start(QThread::LowestPriority);
 }
 
 void ClipItem::slotGetEndThumb()
 {
     m_endThumbRequested = true;
     emit getThumb(-1, (int)(m_speedIndependantInfo.cropStart + m_speedIndependantInfo.cropDuration).frames(m_fps) - 1);
-    //videoThumbProducer.setThumbFrames(m_clip->producer(), -1, (int)(m_cropStart + m_cropDuration).frames(m_fps) - 1);
-    //videoThumbProducer.start(QThread::LowestPriority);
 }
 
 
@@ -1097,7 +1076,6 @@ void ClipItem::resizeStart(int posx)
 
     if ((int) cropStart().frames(m_fps) != previous) {
         if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
-            /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
             m_startThumbTimer.start(150);
         }
     }
@@ -1119,7 +1097,6 @@ void ClipItem::resizeEnd(int posx)
 
     if ((int) cropDuration().frames(m_fps) != previous) {
         if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
-            /*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
             m_endThumbTimer.start(150);
         }
     }
@@ -1585,7 +1562,14 @@ void ClipItem::setAudioOnly(bool force)
 {
     m_audioOnly = force;
     if (m_audioOnly) m_baseColor = QColor(141, 215, 166);
-    else m_baseColor = QColor(141, 166, 215);
+    else {
+        if (m_clipType == COLOR) {
+            QString colour = m_clip->getProperty("colour");
+            colour = colour.replace(0, 2, "#");
+            m_baseColor = QColor(colour.left(7));
+        } else if (m_clipType == AUDIO) m_baseColor = QColor(141, 215, 166);
+        else m_baseColor = QColor(141, 166, 215);
+    }
     m_audioThumbCachePic.clear();
 }