- if (!m_startPix.isNull()) {
- if (m_clipType == IMAGE) {
- painter->drawPixmap(QPointF(br.x() + br.width() - m_startPix.width(), br.y()), m_startPix);
- QLineF l(br.x() + br.width() - m_startPix.width(), br.y(), br.x() + br.width() - m_startPix.width(), br.y() + br.height());
- painter->drawLine(l);
- } else {
- painter->drawPixmap(QPointF(br.x() + br.width() - m_endPix.width(), br.y()), m_endPix);
- QLineF l(br.x() + br.width() - m_endPix.width(), br.y(), br.x() + br.width() - m_endPix.width(), br.y() + br.height());
- painter->drawLine(l);
- }
-
- painter->drawPixmap(QPointF(br.x(), br.y()), m_startPix);
- QLineF l2(br.x() + m_startPix.width(), br.y(), br.x() + m_startPix.width(), br.y() + br.height());
- painter->drawLine(l2);
- }
- if (m_clipType == AV || m_clipType==AUDIO ){
- QPainterPath path= m_clipType==AV ? roundRectPathLower : roundRectPathUpper.united(roundRectPathLower);
- painter->fillPath(path,QBrush(QColor(200,200,200,127)));
- //for test
- int channels=2;
- kDebug() << "audio frames=" << baseClip()->audioFrameChache.size() ;
- for (int channel=0;channel<channels;channel++){
- QRectF re=path.boundingRect();
- int y=re.y()+re.height()*channel/channels+ (re.height()/channels)/2;
- painter->drawLine(re.x() , y, re.x() + re.width(), y );
- }
- }
+ painter->setMatrixEnabled(false);
+
+ if (KdenliveSettings::videothumbnails()) {
+ QPen pen = painter->pen();
+ pen.setStyle(Qt::DotLine);
+ pen.setColor(Qt::white);
+ painter->setPen(pen);
+ if (m_clipType == IMAGE && !m_startPix.isNull()) {
+ QPointF p1 = painter->matrix().map(QPointF(itemWidth, 0)) - QPointF(m_startPix.width(), 0);
+ QPointF p2 = painter->matrix().map(QPointF(itemWidth, itemHeight)) - QPointF(m_startPix.width(), 0);
+ painter->drawPixmap(p1, m_startPix);
+ QLineF l(p1, p2);
+ painter->drawLine(l);
+ } else if (!m_endPix.isNull()) {
+ QPointF p1 = painter->matrix().map(QPointF(itemWidth, 0)) - QPointF(m_endPix.width(), 0);
+ QPointF p2 = painter->matrix().map(QPointF(itemWidth, itemHeight)) - QPointF(m_endPix.width(), 0);
+ painter->drawPixmap(p1, m_endPix);
+ QLineF l(p1, p2);
+ painter->drawLine(l);
+ }
+ if (!m_startPix.isNull()) {
+ QPointF p1 = painter->matrix().map(QPointF(0, 0));
+ QPointF p2 = painter->matrix().map(QPointF(0, itemHeight));
+ painter->drawPixmap(p1, m_startPix);
+ QLineF l2(p1.x() + m_startPix.width(), p1.y(), p2.x() + m_startPix.width(), p2.y());
+ painter->drawLine(l2);
+ }
+ painter->setPen(Qt::black);
+ }
+
+ // draw audio thumbnails
+ if (KdenliveSettings::audiothumbnails() && m_speed == 1.0 && ((m_clipType == AV && exposed.bottom() > (itemHeight / 2)) || m_clipType == AUDIO) && audioThumbReady) {
+
+ double startpixel = exposed.left();
+ if (startpixel < 0)
+ startpixel = 0;
+ double endpixel = exposed.right();
+ if (endpixel < 0)
+ endpixel = 0;
+ //kDebug()<<"/// REPAINTING AUDIO THMBS ZONE: "<<startpixel<<"x"<<endpixel;
+
+ /*QPainterPath path = m_clipType == AV ? roundRectPathLower : resultClipPath;*/
+ QRectF mappedRect;
+ if (m_clipType == AV) {
+ QRectF re = br;
+ re.setTop(re.y() + re.height() / 2);
+ mappedRect = painter->matrix().mapRect(re);
+ //painter->fillRect(mappedRect, QBrush(QColor(200, 200, 200, 140)));
+ } else mappedRect = mapped;
+
+ int channels = baseClip()->getProperty("channels").toInt();
+ if (scale != framePixelWidth)
+ audioThumbCachePic.clear();
+ double cropLeft = m_cropStart.frames(m_fps);
+ const int clipStart = mappedRect.x();
+ const int mappedStartPixel = painter->matrix().map(QPointF(startpixel + cropLeft, 0)).x() - clipStart;
+ const int mappedEndPixel = painter->matrix().map(QPointF(endpixel + cropLeft, 0)).x() - clipStart;
+ cropLeft = cropLeft * scale;
+
+ if (channels >= 1) {
+ emit prepareAudioThumb(scale, mappedStartPixel, mappedEndPixel, channels);
+ }
+
+ for (int startCache = mappedStartPixel - (mappedStartPixel) % 100; startCache < mappedEndPixel; startCache += 100) {
+ if (audioThumbCachePic.contains(startCache) && !audioThumbCachePic[startCache].isNull())
+ painter->drawPixmap(clipStart + startCache - cropLeft, mappedRect.y(), audioThumbCachePic[startCache]);
+ }
+ }
+
+ // draw markers
+ QList < CommentedTime > markers = baseClip()->commentedSnapMarkers();
+ QList < CommentedTime >::Iterator it = markers.begin();
+ GenTime pos;
+ double framepos;
+ QBrush markerBrush;
+ markerBrush = QBrush(QColor(120, 120, 0, 140));
+ QPen pen = painter->pen();
+ pen.setColor(QColor(255, 255, 255, 200));
+ pen.setStyle(Qt::DotLine);
+ painter->setPen(pen);
+ for (; it != markers.end(); ++it) {
+ pos = (*it).time() - cropStart();
+ if (pos > GenTime()) {
+ if (pos > duration()) break;
+ QLineF l(br.x() + pos.frames(m_fps), br.y() + 5, br.x() + pos.frames(m_fps), br.bottom() - 5);
+ QLineF l2 = painter->matrix().map(l);
+ //framepos = scale * pos.frames(m_fps);
+ //QLineF l(framepos, 5, framepos, itemHeight - 5);
+ painter->drawLine(l2);
+ if (KdenliveSettings::showmarkers()) {
+ framepos = br.x() + pos.frames(m_fps);
+ const QRectF r1(framepos + 0.04, 10, itemWidth - framepos - 2, itemHeight - 10);
+ const QRectF r2 = painter->matrix().mapRect(r1);
+ const QRectF txtBounding = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' ');
+
+ QPainterPath path;
+ path.addRoundedRect(txtBounding, 3, 3);
+ painter->fillPath(path, markerBrush);
+ painter->drawText(txtBounding, Qt::AlignCenter, (*it).comment());
+ }
+ //painter->fillRect(QRect(br.x() + framepos, br.y(), 10, br.height()), QBrush(QColor(0, 0, 0, 150)));
+ }
+ }
+ pen.setColor(Qt::black);
+ pen.setStyle(Qt::SolidLine);
+ painter->setPen(pen);
+