From 8f9379f882c015612f493debf10978aa78267127 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 26 Jan 2008 00:03:25 +0000 Subject: [PATCH] progress on clip view svn path=/branches/KDE4/; revision=1820 --- src/clipitem.cpp | 44 +++++++++++++++++++++++++++-------------- src/clipitem.h | 2 +- src/customtrackview.cpp | 2 +- src/definitions.h | 1 + 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 1e1049f5..a3764ee6 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -34,7 +34,7 @@ #include "kdenlivesettings.h" ClipItem::ClipItem(QDomElement xml, int track, int startpos, const QRectF & rect, int duration) - : QGraphicsRectItem(rect), m_xml(xml), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos) + : QGraphicsRectItem(rect), m_xml(xml), m_resizeMode(NONE), m_grabPoint(0), m_maxTrack(0), m_track(track), m_startPos(startpos), m_thumbProd(NULL) { //setToolTip(name); @@ -43,7 +43,7 @@ ClipItem::ClipItem(QDomElement xml, int track, int startpos, const QRectF & rect m_producer = xml.attribute("id").toInt(); - m_clipType = xml.attribute("type").toInt(); + m_clipType = (CLIPTYPE) xml.attribute("type").toInt(); m_cropStart = xml.attribute("in", 0).toInt(); m_maxDuration = xml.attribute("duration", 0).toInt(); @@ -59,11 +59,17 @@ ClipItem::ClipItem(QDomElement xml, int track, int startpos, const QRectF & rect m_textWidth = textRect.width(); m_label->setPos(rect.x() + rect.width()/2 - m_textWidth/2, rect.y() + rect.height() / 2 - textRect.height()/2); setBrush(QColor(100, 100, 150)); - m_thumbProd = new KThumb(KUrl(xml.attribute("resource"))); - connect(this, SIGNAL(getThumb(int, int, int, int)), m_thumbProd, SLOT(extractImage(int, int, int, int))); - connect(m_thumbProd, SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap))); - QTimer::singleShot(300, this, SLOT(slotFetchThumbs())); - + if (m_clipType == VIDEO || m_clipType == AV) { + m_thumbProd = new KThumb(KUrl(xml.attribute("resource"))); + connect(this, SIGNAL(getThumb(int, int, int, int)), m_thumbProd, SLOT(extractImage(int, int, int, int))); + connect(m_thumbProd, SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap))); + QTimer::singleShot(300, this, SLOT(slotFetchThumbs())); + } + else if (m_clipType == COLOR) { + QString colour = xml.attribute("colour"); + colour = colour.replace(0, 2, "#"); + setBrush(QColor(colour.left(7))); + } //m_startPix.load("/home/one/Desktop/thumb.jpg"); } @@ -142,16 +148,24 @@ int ClipItem::startPos() roundRectPath.lineTo(br.x() + br .width() - roundingX, br.y() + br.height() - offset); roundRectPath.arcTo(br.x() + br .width() - roundingX - offset, br.y() + br.height() - roundingY - offset, roundingX, roundingY, 270.0, 90.0); roundRectPath.closeSubpath(); - painter->fillPath(roundRectPath, brush()); //, QBrush(QColor(Qt::red))); painter->setClipPath(roundRectPath, Qt::IntersectClip); - 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); + //painter->fillPath(roundRectPath, brush()); //, QBrush(QColor(Qt::red))); + painter->fillRect(br, brush()); + //painter->fillRect(QRectF(br.x() + br.width() - m_endPix.width(), br.y(), m_endPix.width(), br.height()), QBrush(QColor(Qt::black))); + if (!m_startPix.isNull()) { + 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); + } painter->setClipRect(option->exposedRect); + QPen pen = painter->pen(); + pen.setColor(Qt::red); + pen.setStyle(Qt::DashDotDotLine); //Qt::DotLine); + if (isSelected()) painter->setPen(pen); painter->drawPath(roundRectPath); //painter->fillRect(QRect(br.x(), br.y(), roundingX, roundingY), QBrush(QColor(Qt::green))); diff --git a/src/clipitem.h b/src/clipitem.h index 853c24e0..f8c4740f 100644 --- a/src/clipitem.h +++ b/src/clipitem.h @@ -64,7 +64,7 @@ class ClipItem : public QObject, public QGraphicsRectItem OPERATIONTYPE m_resizeMode; int m_grabPoint; int m_producer; - int m_clipType; + CLIPTYPE m_clipType; QString m_clipName; int m_maxDuration; int m_cropStart; diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index d92fcd54..b386c73a 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -257,7 +257,7 @@ void CustomTrackView::mousePressEvent ( QMouseEvent * event ) m_clickPoint = mapToScene(event->pos()).x() - m_dragItem->startPos() * m_scale; m_operationMode = m_dragItem->operationMode(item->mapFromScene(mapToScene(event->pos()))); if (m_operationMode == MOVE || m_operationMode == RESIZESTART) m_startPos = QPointF(m_dragItem->startPos(), m_dragItem->track()); - else if (m_operationMode == RESIZEEND) m_startPos = QPointF(m_dragItem->rect().x() + m_dragItem->rect().width(), m_dragItem->rect().y()); + else if (m_operationMode == RESIZEEND) m_startPos = QPointF(m_dragItem->startPos() + m_dragItem->duration(), m_dragItem->track()); kDebug()<<"//////// ITEM CLICKED: "<parentItem()) diff --git a/src/definitions.h b/src/definitions.h index c0fb3858..41b8976e 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -24,6 +24,7 @@ #define FRAME_SIZE 90 enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5}; +enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9}; struct TrackViewClip { int startTime; -- 2.39.2