]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Show full log if there is a problem with dvd creation
[kdenlive] / src / clipitem.cpp
index cb8f0e31c40c09c77dbc6b97bafc648d30fa0ab0..bcc7af5efae547243c6bdc437ec05ec319466d42 100644 (file)
@@ -107,7 +107,7 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, b
         setBrush(QColor(colour.left(7)));
     } else if (m_clipType == IMAGE || m_clipType == TEXT) {
         setBrush(QColor(141, 166, 215));
-        m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
+        //m_startPix = KThumb::getImage(KUrl(clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
     } else if (m_clipType == AUDIO) {
         setBrush(QColor(141, 215, 166));
         connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
@@ -130,9 +130,12 @@ ClipItem::~ClipItem()
 ClipItem *ClipItem::clone(ItemInfo info) const
 {
     ClipItem *duplicate = new ClipItem(m_clip, info, m_fps, m_speed);
-    if (info.cropStart == m_cropStart) duplicate->slotSetStartThumb(m_startPix);
-    if (info.cropStart + (info.endPos - info.startPos) == m_cropStart + m_cropDuration) duplicate->slotSetEndThumb(m_endPix);
-    kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
+    if (m_clipType == IMAGE || m_clipType == TEXT) duplicate->slotSetStartThumb(m_startPix);
+    else {
+        if (info.cropStart == m_cropStart) duplicate->slotSetStartThumb(m_startPix);
+        if (info.cropStart + (info.endPos - info.startPos) == m_cropStart + m_cropDuration) duplicate->slotSetEndThumb(m_endPix);
+    }
+    //kDebug() << "// CLoning clip: " << (info.cropStart + (info.endPos - info.startPos)).frames(m_fps) << ", CURRENT end: " << (cropStart() + duration()).frames(m_fps);
     duplicate->setEffectList(m_effectList.clone());
     duplicate->setVideoOnly(m_videoOnly);
     duplicate->setAudioOnly(m_audioOnly);
@@ -405,12 +408,14 @@ QDomElement ClipItem::selectedEffect()
     return effectAt(m_selectedEffect);
 }
 
-void ClipItem::resetThumbs()
+void ClipItem::resetThumbs(bool clearExistingThumbs)
 {
-    m_startPix = QPixmap();
-    m_endPix = QPixmap();
+    if (clearExistingThumbs) {
+        m_startPix = QPixmap();
+        m_endPix = QPixmap();
+        m_audioThumbCachePic.clear();
+    }
     slotFetchThumbs();
-    m_audioThumbCachePic.clear();
 }
 
 
@@ -436,11 +441,19 @@ void ClipItem::refreshClip(bool checkDuration)
         QString colour = m_clip->getProperty("colour");
         colour = colour.replace(0, 2, "#");
         setBrush(QColor(colour.left(7)));
-    } else resetThumbs();
+    } else resetThumbs(checkDuration);
 }
 
 void ClipItem::slotFetchThumbs()
 {
+    if (m_clipType == IMAGE || m_clipType == TEXT) {
+        if (m_startPix.isNull()) {
+            m_startPix = KThumb::getImage(KUrl(m_clip->getProperty("resource")), (int)(KdenliveSettings::trackheight() * KdenliveSettings::project_display_ratio()), KdenliveSettings::trackheight());
+            update();
+        }
+        return;
+    }
+
     if (m_endPix.isNull() && m_startPix.isNull()) {
         m_startThumbRequested = true;
         m_endThumbRequested = true;
@@ -691,9 +704,8 @@ void ClipItem::paint(QPainter *painter,
         QRectF mappedRect;
         if (m_clipType == AV && !isAudioOnly()) {
             QRectF re =  br;
-            re.setTop(re.y() + re.height() / 2);
             mappedRect = painter->matrix().mapRect(re);
-            //painter->fillRect(mappedRect, QBrush(QColor(200, 200, 200, 140)));
+            mappedRect.setTop(mappedRect.bottom() - re.height() / 2);
         } else mappedRect = mapped;
 
         int channels = baseClip()->getProperty("channels").toInt();
@@ -795,7 +807,7 @@ void ClipItem::paint(QPainter *painter,
         if (m_timeLine && m_timeLine->state() == QTimeLine::Running) {
             qreal value = m_timeLine->currentValue();
             txtBounding.setWidth(txtBounding.width() * value);
-            markerBrush.setColor(QColor(50 + 200 * (1.0 - value), 50, 50, 100 + 50 * value));
+            markerBrush.setColor(QColor(50 + 200 *(1.0 - value), 50, 50, 100 + 50 * value));
         } else markerBrush.setColor(QColor(50, 50, 50, 150));
         painter->setBrush(markerBrush);
         painter->setPen(Qt::NoPen);
@@ -836,7 +848,7 @@ void ClipItem::paint(QPainter *painter,
     }*/
 
     // draw effect or transition keyframes
-    if (itemWidth > 20) drawKeyFrames(painter, exposed);
+    if (mapped.width() > 20) drawKeyFrames(painter, exposed);
 
     painter->setMatrixEnabled(true);
 
@@ -948,7 +960,7 @@ void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, in
     //kDebug() << "// PREP AUDIO THMB FRMO : scale:" << pixelForOneFrame<< ", from: " << startpixel << ", to: " << endpixel;
     //if ( (!audioThumbWasDrawn || framePixelWidth!=pixelForOneFrame ) && !baseClip()->audioFrameChache.isEmpty()){
 
-    for (int startCache = startpixel - startpixel % 100;startCache < endpixel;startCache += 100) {
+    for (int startCache = startpixel - startpixel % 100; startCache < endpixel; startCache += 100) {
         //kDebug() << "creating " << startCache;
         //if (framePixelWidth!=pixelForOneFrame  ||
         if (m_framePixelWidth == pixelForOneFrame && m_audioThumbCachePic.contains(startCache))
@@ -974,20 +986,20 @@ void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, in
 
         int channelHeight = m_audioThumbCachePic[startCache].height() / channels;
 
-        for (int i = 0;i < channels;i++) {
+        for (int i = 0; i < channels; i++) {
 
             positiveChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
             negativeChannelPaths[i].moveTo(0, channelHeight*i + channelHeight / 2);
         }
 
-        for (int samples = 0;samples <= 100;samples++) {
+        for (int samples = 0; samples <= 100; samples++) {
             double frame = (double)(samples + startCache - 0) / pixelForOneFrame;
             int sample = (int)((frame - (int)(frame)) * 20);   // AUDIO_FRAME_SIZE
             if (frame < 0 || sample < 0 || sample > 19)
                 continue;
             QMap<int, QByteArray> frame_channel_data = baseClip()->m_audioFrameCache[(int)frame];
 
-            for (int channel = 0;channel < channels && frame_channel_data[channel].size() > 0;channel++) {
+            for (int channel = 0; channel < channels && frame_channel_data[channel].size() > 0; channel++) {
 
                 int y = channelHeight * channel + channelHeight / 2;
                 int delta = (int)(frame_channel_data[channel][sample] - 127 / 2)  * channelHeight / 64;
@@ -999,7 +1011,7 @@ void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, in
                     negativeChannelPaths[channel].lineTo(samples, 0.1 + y - delta);
                 }
             }
-            for (int channel = 0;channel < channels ;channel++)
+            for (int channel = 0; channel < channels ; channel++)
                 if (fullAreaDraw && samples == 100) {
                     positiveChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
                     negativeChannelPaths[channel].lineTo(samples, channelHeight*channel + channelHeight / 2);
@@ -1011,7 +1023,7 @@ void ClipItem::slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, in
         pixpainter.setPen(QPen(QColor(0, 0, 0)));
         pixpainter.setBrush(QBrush(QColor(60, 60, 60)));
 
-        for (int i = 0;i < channels;i++) {
+        for (int i = 0; i < channels; i++) {
             if (fullAreaDraw) {
                 //pixpainter.fillPath(positiveChannelPaths[i].united(negativeChannelPaths[i]),QBrush(Qt::SolidPattern));//or singleif looks better
                 pixpainter.drawPath(positiveChannelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
@@ -1434,7 +1446,7 @@ EffectsParameterList ClipItem::getEffectArgs(QDomElement effect)
             QTextStream txtNeu(&neu);
             if (values.size() > 0)
                 txtNeu << (int)values[0].toDouble();
-            for (int i = 0;i < separators.size() && i + 1 < values.size();i++) {
+            for (int i = 0; i < separators.size() && i + 1 < values.size(); i++) {
                 txtNeu << separators[i];
                 txtNeu << (int)(values[i+1].toDouble());
             }