From d43383d14efb17899c439d85c257f5be5d2a118e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Wed, 26 Aug 2009 15:42:40 +0000 Subject: [PATCH] Various fixes to improve general stability in Qt 4.5.2 svn path=/trunk/kdenlive/; revision=3836 --- src/CMakeLists.txt | 1 + src/abstractclipitem.cpp | 60 ++--------------- src/abstractclipitem.h | 2 - src/abstractgroupitem.cpp | 9 +-- src/addtimelineclipcommand.cpp | 12 ++-- src/addtimelineclipcommand.h | 1 + src/addtransitioncommand.cpp | 12 ++-- src/addtransitioncommand.h | 1 + src/clipitem.cpp | 15 ++--- src/clipitem.h | 2 +- src/clipmanager.cpp | 6 +- src/clipmanager.h | 2 +- src/customruler.cpp | 21 ++++-- src/customtrackscene.cpp | 1 - src/customtrackscene.h | 1 - src/customtrackview.cpp | 113 ++++++++++++++++++--------------- src/customtrackview.h | 8 +-- src/docclipbase.cpp | 30 +++++++-- src/docclipbase.h | 1 + src/graphicsscenerectmove.cpp | 4 +- src/guide.cpp | 56 +++++++++------- src/guide.h | 2 + src/headertrack.cpp | 6 ++ src/headertrack.h | 3 +- src/kdenlivedoc.cpp | 6 +- src/kdenlivedoc.h | 2 +- src/projectlist.cpp | 3 +- src/renderer.cpp | 77 ++++++++++++++++------ src/renderer.h | 2 +- src/timecode.cpp | 6 +- src/timecode.h | 6 +- src/titlewidget.cpp | 5 +- src/trackdialog.cpp | 50 +++++++++++++++ src/trackdialog.h | 48 ++++++++++++++ src/trackview.cpp | 12 ++-- src/transition.cpp | 42 +++++------- src/transition.h | 1 - src/wizard.h | 2 +- 38 files changed, 385 insertions(+), 246 deletions(-) create mode 100644 src/trackdialog.cpp create mode 100644 src/trackdialog.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ab0e5f0e..bfd7c7dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -169,6 +169,7 @@ set(kdenlive_SRCS cliptranscode.cpp keyframeedit.cpp positionedit.cpp + trackdialog.cpp ) add_definitions( ${KDE4_DEFINITIONS} ) diff --git a/src/abstractclipitem.cpp b/src/abstractclipitem.cpp index 5e4c7716..f2664551 100644 --- a/src/abstractclipitem.cpp +++ b/src/abstractclipitem.cpp @@ -38,7 +38,7 @@ AbstractClipItem::AbstractClipItem(const ItemInfo info, const QRectF& rect, doub m_keyframeFactor(1), m_fps(fps) { - setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setTrack(info.track); m_startPos = info.startPos; m_cropDuration = info.endPos - info.startPos; @@ -190,55 +190,6 @@ GenTime AbstractClipItem::maxDuration() const return m_maxDuration; } -QPainterPath AbstractClipItem::upperRectPart(QRectF br) -{ - QPainterPath roundRectPathUpper; - double roundingY = 20; - double roundingX = 20; - double offset = 1; - - while (roundingX > br.width() / 2) { - roundingX = roundingX / 2; - roundingY = roundingY / 2; - } - int br_endx = (int)(br.x() + br .width() - offset); - int br_startx = (int)(br.x() + offset); - int br_starty = (int)(br.y()); - int br_halfy = (int)(br.y() + br.height() / 2 - offset); - - roundRectPathUpper.moveTo(br_endx , br_halfy); - roundRectPathUpper.arcTo(br_endx - roundingX , br_starty , roundingX, roundingY, 0.0, 90.0); - roundRectPathUpper.lineTo(br_startx + roundingX , br_starty); - roundRectPathUpper.arcTo(br_startx , br_starty , roundingX, roundingY, 90.0, 90.0); - roundRectPathUpper.lineTo(br_startx , br_halfy); - - return roundRectPathUpper; -} - -QPainterPath AbstractClipItem::lowerRectPart(QRectF br) -{ - QPainterPath roundRectPathLower; - double roundingY = 20; - double roundingX = 20; - double offset = 1; - - int br_endx = (int)(br.x() + br .width() - offset); - int br_startx = (int)(br.x() + offset); - int br_halfy = (int)(br.y() + br.height() / 2 - offset); - int br_endy = (int)(br.y() + br.height() - 1); - - while (roundingX > br.width() / 2) { - roundingX = roundingX / 2; - roundingY = roundingY / 2; - } - roundRectPathLower.moveTo(br_startx, br_halfy); - roundRectPathLower.arcTo(br_startx , br_endy - roundingY , roundingX, roundingY, 180.0, 90.0); - roundRectPathLower.lineTo(br_endx - roundingX , br_endy); - roundRectPathLower.arcTo(br_endx - roundingX , br_endy - roundingY, roundingX, roundingY, 270.0, 90.0); - roundRectPathLower.lineTo(br_endx , br_halfy); - return roundRectPathLower; -} - void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/) { if (m_keyframes.count() < 2) return; @@ -260,9 +211,8 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/) QLineF l2 = painter->matrix().map(l); painter->setPen(QColor(168, 168, 168, 180)); painter->drawLine(l2); - l2.translate(0, 1); painter->setPen(QColor(108, 108, 108, 180)); - painter->drawLine(l2); + painter->drawLine(l2.translated(0, 1)); painter->setPen(QColor(Qt::white)); } @@ -283,12 +233,12 @@ void AbstractClipItem::drawKeyFrames(QPainter *painter, QRectF /*exposedRect*/) l2 = painter->matrix().map(l); painter->drawLine(l2); if (active) { - painter->fillRect(l2.x1() - 3, l2.y1() - 3, 6, 6, QBrush(color)); + painter->fillRect(l2.x1() - 3, l2.y1() - 3, 6, 6, color); } x1 = x2; y1 = y2; } - if (active) painter->fillRect(l2.x2() - 3, l2.y2() - 3, 6, 6, QBrush(color)); + if (active) painter->fillRect(l2.x2() - 3, l2.y2() - 3, 6, 6, color); } int AbstractClipItem::mouseOverKeyFrames(QPointF pos) @@ -411,7 +361,7 @@ void AbstractClipItem::setItemLocked(bool locked) setSelected(false); setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemIsSelectable, false); - } else setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + } else setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); } bool AbstractClipItem::isItemLocked() const diff --git a/src/abstractclipitem.h b/src/abstractclipitem.h index 55e392b9..231cf946 100644 --- a/src/abstractclipitem.h +++ b/src/abstractclipitem.h @@ -72,8 +72,6 @@ protected: double m_keyframeFactor; double m_keyframeDefault; double m_fps; - QPainterPath upperRectPart(QRectF); - QPainterPath lowerRectPart(QRectF); //QRect visibleRect(); void drawKeyFrames(QPainter *painter, QRectF exposedRect); int mouseOverKeyFrames(QPointF pos); diff --git a/src/abstractgroupitem.cpp b/src/abstractgroupitem.cpp index d9ce8b79..a54cd93f 100644 --- a/src/abstractgroupitem.cpp +++ b/src/abstractgroupitem.cpp @@ -37,7 +37,7 @@ AbstractGroupItem::AbstractGroupItem(double /* fps */) : QGraphicsItemGroup() { setZValue(1); - setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setAcceptDrops(true); } @@ -97,13 +97,14 @@ void AbstractGroupItem::fixItemRect() void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *) { const double scale = option->matrix.m11(); - p->fillRect(option->exposedRect, QColor(100, 100, 200, 100)); + QColor bgcolor(100, 100, 200, 100); + p->fillRect(option->exposedRect, bgcolor); p->setClipping(false); QPen pen = p->pen(); pen.setColor(QColor(200, 90, 90)); pen.setStyle(Qt::DashLine); - pen.setWidthF(1.0); - pen.setCosmetic(true); + pen.setWidthF(0.0); + //pen.setCosmetic(true); p->setPen(pen); p->drawRect(boundingRect().adjusted(0, 0, - 1 / scale, 0)); } diff --git a/src/addtimelineclipcommand.cpp b/src/addtimelineclipcommand.cpp index 543ac23f..7498fa18 100644 --- a/src/addtimelineclipcommand.cpp +++ b/src/addtimelineclipcommand.cpp @@ -35,21 +35,25 @@ AddTimelineClipCommand::AddTimelineClipCommand(CustomTrackView *view, QDomElemen { if (!m_remove) setText(i18n("Add timeline clip")); else setText(i18n("Delete timeline clip")); + if (parent) { + // command has a parent, so there are several operations ongoing, do not refresh monitor + m_refresh = false; + } else m_refresh = true; } // virtual void AddTimelineClipCommand::undo() { - if (!m_remove) m_view->deleteClip(m_clipInfo); - else m_view->addClip(m_xml, m_clipId, m_clipInfo, m_effects); + if (!m_remove) m_view->deleteClip(m_clipInfo, m_refresh); + else m_view->addClip(m_xml, m_clipId, m_clipInfo, m_effects, m_refresh); } // virtual void AddTimelineClipCommand::redo() { if (m_doIt) { - if (!m_remove) m_view->addClip(m_xml, m_clipId, m_clipInfo, m_effects); - else m_view->deleteClip(m_clipInfo); + if (!m_remove) m_view->addClip(m_xml, m_clipId, m_clipInfo, m_effects, m_refresh); + else m_view->deleteClip(m_clipInfo, m_refresh); } m_doIt = true; } diff --git a/src/addtimelineclipcommand.h b/src/addtimelineclipcommand.h index ef713aa2..2752c3a5 100644 --- a/src/addtimelineclipcommand.h +++ b/src/addtimelineclipcommand.h @@ -46,6 +46,7 @@ private: QDomElement m_xml; bool m_doIt; bool m_remove; + bool m_refresh; }; #endif diff --git a/src/addtransitioncommand.cpp b/src/addtransitioncommand.cpp index 9a1be1da..c8acc6dc 100644 --- a/src/addtransitioncommand.cpp +++ b/src/addtransitioncommand.cpp @@ -32,21 +32,25 @@ AddTransitionCommand::AddTransitionCommand(CustomTrackView *view, ItemInfo info, { if (m_remove) setText(i18n("Delete transition from clip")); else setText(i18n("Add transition to clip")); + if (parent) { + // command has a parent, so there are several operations ongoing, do not refresh monitor + m_refresh = false; + } else m_refresh = true; } // virtual void AddTransitionCommand::undo() { - if (m_remove) m_view->addTransition(m_info, m_track, m_params); - else m_view->deleteTransition(m_info, m_track, m_params); + if (m_remove) m_view->addTransition(m_info, m_track, m_params, m_refresh); + else m_view->deleteTransition(m_info, m_track, m_params, m_refresh); } // virtual void AddTransitionCommand::redo() { if (m_doIt) { - if (m_remove) m_view->deleteTransition(m_info, m_track, m_params); - else m_view->addTransition(m_info, m_track, m_params); + if (m_remove) m_view->deleteTransition(m_info, m_track, m_params, m_refresh); + else m_view->addTransition(m_info, m_track, m_params, m_refresh); } m_doIt = true; } diff --git a/src/addtransitioncommand.h b/src/addtransitioncommand.h index 0f09c57d..be6f6a19 100644 --- a/src/addtransitioncommand.h +++ b/src/addtransitioncommand.h @@ -43,6 +43,7 @@ private: int m_track; bool m_doIt; bool m_remove; + bool m_refresh; }; #endif diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 4ba13ad9..2a9f7ab0 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -614,7 +614,7 @@ void ClipItem::setClipName(const QString &name) m_clipName = name; } -const QString &ClipItem::clipProducer() const +const QString ClipItem::clipProducer() const { return m_producer; } @@ -645,9 +645,9 @@ void ClipItem::paint(QPainter *painter, if (parentItem()) paintColor = QColor(255, 248, 149); else paintColor = brush().color(); if (isSelected() || (parentItem() && parentItem()->isSelected())) paintColor = paintColor.darker(); - QRectF br = rect(); - QRectF exposed = option->exposedRect; - QRectF mapped = painter->matrix().mapRect(br); + const QRectF br = rect(); + const QRectF exposed = option->exposedRect; + const QRectF mapped = painter->matrix().mapRect(br); const double itemWidth = br.width(); const double itemHeight = br.height(); @@ -806,8 +806,7 @@ void ClipItem::paint(QPainter *painter, // Draw effects names if (!m_effectNames.isEmpty() && itemWidth * scale > 40) { - QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignLeft | Qt::AlignTop, m_effectNames); - txtBounding.setRight(txtBounding.right() + 15); + QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignLeft | Qt::AlignTop, m_effectNames).adjusted(0, 0, 15, 0); painter->setPen(Qt::white); QBrush markerBrush(Qt::SolidPattern); if (m_timeLine && m_timeLine->state() == QTimeLine::Running) { @@ -840,7 +839,6 @@ void ClipItem::paint(QPainter *painter, } else if (m_audioOnly) { painter->drawPixmap(txtBounding.topLeft() - QPointF(17, -1), m_audioPix); } - txtBounding.translate(QPointF(1, 1)); painter->setPen(QColor(255, 255, 255, 255)); painter->drawText(txtBounding, Qt::AlignCenter, m_clipName); @@ -861,8 +859,7 @@ void ClipItem::paint(QPainter *painter, // draw clip border // expand clip rect to allow correct painting of clip border QPen pen1(frameColor); - pen1.setWidthF(1.0); - pen1.setCosmetic(true); + //pen1.setCosmetic(true); painter->setPen(pen1); /*exposed.setRight(exposed.right() + xoffset + 0.5); diff --git a/src/clipitem.h b/src/clipitem.h index 5e69f84d..9337474a 100644 --- a/src/clipitem.h +++ b/src/clipitem.h @@ -50,7 +50,7 @@ public: void resizeStart(int posx, double speed = 1.0); void resizeEnd(int posx, double speed = 1.0, bool updateKeyFrames = true); OPERATIONTYPE operationMode(QPointF pos); - const QString &clipProducer() const; + const QString clipProducer() const; int clipType() const; DocClipBase *baseClip() const; QString clipName() const; diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 3b6f6b4f..baafa500 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -226,21 +226,21 @@ void ClipManager::clearUnusedProducers() } } -void ClipManager::resetProducersList(QList prods) +void ClipManager::resetProducersList(const QList prods) { for (int i = 0; i < m_clipList.count(); i++) { if (m_clipList.at(i)->numReferences() > 0) { - m_clipList.at(i)->deleteProducers(); + m_clipList.at(i)->clearProducers(); } } QString id; for (int i = 0; i < prods.count(); i++) { id = prods.at(i)->get("id"); + kDebug() << "// // // REPLACE CLIP: " << id; if (id.contains('_')) id = id.section('_', 0, 0); DocClipBase *clip = getClipById(id); if (clip) { clip->setProducer(prods.at(i)); - kDebug() << "// // // REPLACE CLIP: " << id; } } emit checkAllClips(); diff --git a/src/clipmanager.h b/src/clipmanager.h index 88d98858..6f316eae 100644 --- a/src/clipmanager.h +++ b/src/clipmanager.h @@ -76,7 +76,7 @@ Q_OBJECT public: void askForAudioThumb(const QString &id); QString projectFolder() const; void clearUnusedProducers(); - void resetProducersList(QList prods); + void resetProducersList(const QList prods); void addFolder(const QString&, const QString&); void deleteFolder(const QString&); void clear(); diff --git a/src/customruler.cpp b/src/customruler.cpp index fd9786e6..eec25d31 100644 --- a/src/customruler.cpp +++ b/src/customruler.cpp @@ -161,10 +161,19 @@ void CustomRuler::mouseMoveEvent(QMouseEvent * event) } else { int pos = (int)((event->x() + offset())); if (event->y() <= 10) setCursor(Qt::ArrowCursor); - else if (qAbs(pos - m_zoneStart * m_factor) < 4) setCursor(KCursor("left_side", Qt::SizeHorCursor)); - else if (qAbs(pos - m_zoneEnd * m_factor) < 4) setCursor(KCursor("right_side", Qt::SizeHorCursor)); - else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2) * m_factor) < 4) setCursor(Qt::SizeHorCursor); - else setCursor(Qt::ArrowCursor); + else if (qAbs(pos - m_zoneStart * m_factor) < 4) { + setCursor(KCursor("left_side", Qt::SizeHorCursor)); + setToolTip(i18n("Zone start: %1", m_timecode.getTimecodeFromFrames(m_zoneStart))); + } else if (qAbs(pos - m_zoneEnd * m_factor) < 4) { + setCursor(KCursor("right_side", Qt::SizeHorCursor)); + setToolTip(i18n("Zone end: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd))); + } else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2) * m_factor) < 4) { + setCursor(Qt::SizeHorCursor); + setToolTip(i18n("Zone duration: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd - m_zoneStart))); + } else { + setCursor(Qt::ArrowCursor); + setToolTip(QString()); + } } } @@ -334,8 +343,10 @@ void CustomRuler::paintEvent(QPaintEvent *e) } if (zoneEnd > 0) { + QColor center(Qt::white); + center.setAlpha(150); QRect rec(zoneStart - off + (zoneEnd - zoneStart) / 2 - 4, 9, 8, 9); - p.fillRect(rec, QColor(255, 255, 255, 150)); + p.fillRect(rec, center); p.drawRect(rec); QPolygon pa(4); diff --git a/src/customtrackscene.cpp b/src/customtrackscene.cpp index eaacb63a..13672c1f 100644 --- a/src/customtrackscene.cpp +++ b/src/customtrackscene.cpp @@ -27,7 +27,6 @@ CustomTrackScene::CustomTrackScene(KdenliveDoc *doc, QObject *parent) : m_document(doc), m_scale(1.0, 1.0) { - m_transitionPixmap = QPixmap(KStandardDirs::locate("appdata", "transition.png")); } CustomTrackScene::~CustomTrackScene() diff --git a/src/customtrackscene.h b/src/customtrackscene.h index 32224b20..98354827 100644 --- a/src/customtrackscene.h +++ b/src/customtrackscene.h @@ -46,7 +46,6 @@ public: void setScale(double scale, double vscale); QPointF scale() const; int tracksCount() const; - QPixmap m_transitionPixmap; MltVideoProfile profile() const; private: diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 2efe0305..8ffba391 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -57,6 +57,7 @@ #include "groupclipscommand.h" #include "splitaudiocommand.h" #include "changecliptypecommand.h" +#include "trackdialog.h" #include #include @@ -134,10 +135,10 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen verticalScrollBar()->setMaximum(maxWidth); m_cursorLine = projectscene->addLine(0, 0, 0, maxWidth); m_cursorLine->setZValue(1000); - QPen pen1; + /*QPen pen1; pen1.setWidthF(1.0); pen1.setCosmetic(true); - m_cursorLine->setPen(pen1); + m_cursorLine->setPen(pen1);*/ KIcon razorIcon("edit-cut"); m_razorCursor = QCursor(razorIcon.pixmap(22, 22)); @@ -686,7 +687,10 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) } ct++; } - if (!found) m_dragItem = NULL; + if (!found) { + if (m_dragItem) emit clipItemSelected(NULL); + m_dragItem = NULL; + } if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET) { // update transition menu action @@ -734,7 +738,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event) setCursor(Qt::ArrowCursor); m_scene->clearSelection(); //event->accept(); - emit clipItemSelected(NULL); updateClipTypeActions(NULL); if (m_tool == SPACERTOOL) { QList selection; @@ -959,11 +962,11 @@ void CustomTrackView::resetSelectionGroup(bool selectItems) for (int i = 0; i < children.count(); i++) { if (children.at(i)->type() == AVWIDGET || children.at(i)->type() == TRANSITIONWIDGET) { if (!static_cast (children.at(i))->isItemLocked()) { - children.at(i)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + children.at(i)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); children.at(i)->setSelected(selectItems); } } else if (children.at(i)->type() == GROUPWIDGET) { - children.at(i)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + children.at(i)->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); children.at(i)->setSelected(selectItems); } } @@ -1773,11 +1776,11 @@ void CustomTrackView::slotAddTransition(ClipItem* /*clip*/, ItemInfo transitionI setDocumentModified(); } -void CustomTrackView::addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params) +void CustomTrackView::addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh) { Transition *tr = new Transition(transitionInfo, endTrack, m_document->fps(), params, true); //kDebug() << "---- ADDING transition " << params.attribute("value"); - if (m_document->renderer()->mltAddTransition(tr->transitionTag(), endTrack, m_document->tracksCount() - transitionInfo.track, transitionInfo.startPos, transitionInfo.endPos, tr->toXML())) { + if (m_document->renderer()->mltAddTransition(tr->transitionTag(), endTrack, m_document->tracksCount() - transitionInfo.track, transitionInfo.startPos, transitionInfo.endPos, tr->toXML(), refresh)) { scene()->addItem(tr); setDocumentModified(); } else { @@ -1786,14 +1789,14 @@ void CustomTrackView::addTransition(ItemInfo transitionInfo, int endTrack, QDomE } } -void CustomTrackView::deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement /*params*/) +void CustomTrackView::deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement /*params*/, bool refresh) { Transition *item = getTransitionItemAt(transitionInfo.startPos, transitionInfo.track); if (!item) { emit displayMessage(i18n("Select clip to delete"), ErrorMessage); return; } - m_document->renderer()->mltDeleteTransition(item->transitionTag(), endTrack, m_document->tracksCount() - transitionInfo.track, transitionInfo.startPos, transitionInfo.endPos, item->toXML()); + m_document->renderer()->mltDeleteTransition(item->transitionTag(), endTrack, m_document->tracksCount() - transitionInfo.track, transitionInfo.startPos, transitionInfo.endPos, item->toXML(), refresh); if (m_dragItem == item) m_dragItem = NULL; delete item; emit transitionItemSelected(NULL); @@ -2007,8 +2010,9 @@ void CustomTrackView::addTrack(TrackInfo type, int ix) } m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight); setSceneRect(0, 0, sceneRect().width(), maxHeight); - QTimer::singleShot(300, this, SIGNAL(trackHeightChanged())); - viewport()->update(); + //viewport()->update(); + emit trackHeightChanged(); + //QTimer::singleShot(500, this, SIGNAL(trackHeightChanged())); //setFixedHeight(50 * m_tracksCount); } @@ -2077,8 +2081,9 @@ void CustomTrackView::removeTrack(int ix) } m_cursorLine->setLine(m_cursorLine->line().x1(), 0, m_cursorLine->line().x1(), maxHeight); setSceneRect(0, 0, sceneRect().width(), maxHeight); - QTimer::singleShot(300, this, SIGNAL(trackHeightChanged())); - viewport()->update(); + //viewport()->update(); + emit trackHeightChanged(); + //QTimer::singleShot(500, this, SIGNAL(trackHeightChanged())); } void CustomTrackView::changeTrack(int ix, TrackInfo type) @@ -2881,7 +2886,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) m_operationMode = NONE; } -void CustomTrackView::deleteClip(ItemInfo info) +void CustomTrackView::deleteClip(ItemInfo info, bool refresh) { ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track); @@ -2902,13 +2907,13 @@ void CustomTrackView::deleteClip(ItemInfo info) delete tr; } }*/ - scene()->removeItem(item); m_waitingThumbs.removeAll(item); if (m_dragItem == item) m_dragItem = NULL; + scene()->removeItem(item); delete item; item = NULL; setDocumentModified(); - m_document->renderer()->doRefresh(); + if (refresh) m_document->renderer()->doRefresh(); } void CustomTrackView::deleteSelectedClips() @@ -3075,7 +3080,7 @@ void CustomTrackView::doGroupClips(QList clipInfos, QList m_document->clipManager()->removeGroup(grp); scene()->destroyItemGroup(grp); } - clip->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + clip->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); } for (int i = 0; i < transitionInfos.count(); i++) { Transition *tr = getTransitionItemAt(transitionInfos.at(i).startPos, transitionInfos.at(i).track); @@ -3085,7 +3090,7 @@ void CustomTrackView::doGroupClips(QList clipInfos, QList m_document->clipManager()->removeGroup(grp); scene()->destroyItemGroup(grp); } - tr->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + tr->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); } setDocumentModified(); return; @@ -3109,7 +3114,7 @@ void CustomTrackView::doGroupClips(QList clipInfos, QList setDocumentModified(); } -void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo info, EffectsList effects) +void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo info, EffectsList effects, bool refresh) { DocClipBase *baseclip = m_document->clipManager()->getClipById(clipId); if (baseclip == NULL) { @@ -3138,7 +3143,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i m_document->renderer()->mltAddEffect(info.track, info.startPos, item->getEffectArgs(item->effectAt(i)), false); } setDocumentModified(); - m_document->renderer()->doRefresh(); + if (refresh) m_document->renderer()->doRefresh(); m_waitingThumbs.append(item); m_thumbsTimer.start(); } @@ -3894,8 +3899,7 @@ void CustomTrackView::slotRefreshGuides() void CustomTrackView::drawBackground(QPainter * painter, const QRectF &rect) { - QRectF r = rect; - r.setWidth(r.width() + 1); + QRectF r = rect.adjusted(0, 0, 1, 0); painter->setClipRect(r); painter->drawLine(r.left(), 0, r.right(), 0); uint max = m_document->tracksCount(); @@ -3904,13 +3908,13 @@ void CustomTrackView::drawBackground(QPainter * painter, const QRectF &rect) QColor audioColor = palette().alternateBase().color(); QColor base = scheme.background(KColorScheme::NormalBackground).color(); for (uint i = 0; i < max; i++) { - if (m_document->trackInfoAt(max - i - 1).isLocked == true) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(lockedColor)); - else if (m_document->trackInfoAt(max - i - 1).type == AUDIOTRACK) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, QBrush(audioColor)); + if (m_document->trackInfoAt(max - i - 1).isLocked == true) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, lockedColor); + else if (m_document->trackInfoAt(max - i - 1).type == AUDIOTRACK) painter->fillRect(r.left(), m_tracksHeight * i + 1, r.right() - r.left() + 1, m_tracksHeight - 1, audioColor); painter->drawLine(r.left(), m_tracksHeight *(i + 1), r.right(), m_tracksHeight *(i + 1)); } int lowerLimit = m_tracksHeight * m_document->tracksCount() + 1; if (height() > lowerLimit) - painter->fillRect(QRectF(r.left(), lowerLimit, r.width(), height() - lowerLimit), QBrush(base)); + painter->fillRect(QRectF(r.left(), lowerLimit, r.width(), height() - lowerLimit), base); } bool CustomTrackView::findString(const QString &text) @@ -4322,21 +4326,20 @@ void CustomTrackView::saveThumbnails() void CustomTrackView::slotInsertTrack(int ix) { - kDebug() << "// INSERTING TRK: " << ix; - QDialog d(parentWidget()); - Ui::AddTrack_UI view; - view.setupUi(&d); - view.track_nb->setMaximum(m_document->tracksCount() - 1); - view.track_nb->setValue(ix); - d.setWindowTitle(i18n("Insert Track")); + TrackDialog d(m_document, parentWidget()); + d.view.label->setText(i18n("Insert track")); + d.view.track_nb->setMaximum(m_document->tracksCount() - 1); + d.view.track_nb->setValue(ix); + d.setWindowTitle(i18n("Insert New Track")); + d.slotUpdateName(ix); if (d.exec() == QDialog::Accepted) { - ix = view.track_nb->value(); - if (view.before_select->currentIndex() == 1) { + ix = d.view.track_nb->value(); + if (d.view.before_select->currentIndex() == 1) { ix++; } TrackInfo info; - if (view.video_track->isChecked()) { + if (d.view.video_track->isChecked()) { info.type = VIDEOTRACK; info.isMute = false; info.isBlind = false; @@ -4355,9 +4358,17 @@ void CustomTrackView::slotInsertTrack(int ix) void CustomTrackView::slotDeleteTrack(int ix) { - bool ok; - ix = QInputDialog::getInteger(this, i18n("Remove Track"), i18n("Track"), ix, 0, m_document->tracksCount() - 1, 1, &ok); - if (ok) { + TrackDialog d(m_document, parentWidget()); + d.view.label->setText(i18n("Delete track")); + d.view.before_select->setHidden(true); + d.view.track_nb->setMaximum(m_document->tracksCount() - 1); + d.view.track_nb->setValue(ix); + d.slotUpdateName(ix); + d.setWindowTitle(i18n("Delete Track")); + d.view.video_track->setHidden(true); + d.view.audio_track->setHidden(true); + if (d.exec() == QDialog::Accepted) { + ix = d.view.track_nb->value(); TrackInfo info = m_document->trackInfoAt(m_document->tracksCount() - ix - 1); deleteTimelineTrack(ix, info); setDocumentModified(); @@ -4368,27 +4379,26 @@ void CustomTrackView::slotDeleteTrack(int ix) void CustomTrackView::slotChangeTrack(int ix) { - QDialog d(parentWidget()); - Ui::AddTrack_UI view; - view.setupUi(&d); - view.label->setText(i18n("Change track")); - view.before_select->setHidden(true); - view.track_nb->setMaximum(m_document->tracksCount() - 1); - view.track_nb->setValue(ix); + TrackDialog d(m_document, parentWidget()); + d.view.label->setText(i18n("Change track")); + d.view.before_select->setHidden(true); + d.view.track_nb->setMaximum(m_document->tracksCount() - 1); + d.view.track_nb->setValue(ix); + d.slotUpdateName(ix); d.setWindowTitle(i18n("Change Track Type")); if (m_document->trackInfoAt(m_document->tracksCount() - ix - 1).type == VIDEOTRACK) - view.video_track->setChecked(true); + d.view.video_track->setChecked(true); else - view.audio_track->setChecked(true); + d.view.audio_track->setChecked(true); if (d.exec() == QDialog::Accepted) { TrackInfo info; info.isLocked = false; info.isMute = false; - ix = view.track_nb->value(); + ix = d.view.track_nb->value(); - if (view.video_track->isChecked()) { + if (d.view.video_track->isChecked()) { info.type = VIDEOTRACK; info.isBlind = false; } else { @@ -4426,7 +4436,6 @@ void CustomTrackView::deleteTimelineTrack(int ix, TrackInfo trackinfo) } } - selection = m_scene->items(); new AddTrackCommand(this, ix, trackinfo, false, deleteTrack); m_commandStack->push(deleteTrack); } @@ -4629,7 +4638,7 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split) break; } } - clip->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + clip->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); m_document->clipManager()->removeGroup(grp); scene()->destroyItemGroup(grp); } diff --git a/src/customtrackview.h b/src/customtrackview.h index 4f23d5b7..9342d353 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -59,8 +59,8 @@ public: /** move transition, startPos = (old start, old end), endPos = (new start, new end) */ void moveTransition(const ItemInfo start, const ItemInfo end); void resizeClip(const ItemInfo start, const ItemInfo end); - void addClip(QDomElement xml, const QString &clipId, ItemInfo info, EffectsList list = EffectsList()); - void deleteClip(ItemInfo info); + void addClip(QDomElement xml, const QString &clipId, ItemInfo info, EffectsList list = EffectsList(), bool refresh = true); + void deleteClip(ItemInfo info, bool refresh = true); void slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position); void slotDeleteAllClipMarkers(const QString &id); void addMarker(const QString &id, const GenTime &pos, const QString comment); @@ -72,8 +72,8 @@ public: void deleteEffect(int track, GenTime pos, QDomElement effect); void updateEffect(int track, GenTime pos, QDomElement effect, int ix, bool triggeredByUser = true); void moveEffect(int track, GenTime pos, int oldPos, int newPos); - void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params); - void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params); + void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh); + void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh); void updateTransition(int track, GenTime pos, QDomElement oldTransition, QDomElement transition, bool updateTransitionWidget); void moveTransition(GenTime oldpos, GenTime newpos); void activateMonitor(); diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 6c3addf0..b1d5d1c9 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -408,15 +408,34 @@ QString DocClipBase::markerComment(GenTime t) return QString(); } +void DocClipBase::clearProducers() +{ + m_baseTrackProducers.clear(); +} + void DocClipBase::deleteProducers() { + kDebug() << "// CLIP KILL PRODS ct: " << m_baseTrackProducers.count(); + if (m_thumbProd) m_thumbProd->clearProducer(); + /*kDebug()<<"// CLIP KILL PRODS ct: "<clearProducer(); qDeleteAll(m_audioTrackProducers); m_audioTrackProducers.clear(); - delete m_videoOnlyProducer; - m_videoOnlyProducer = NULL; } void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) @@ -424,9 +443,11 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) if (producer == NULL) return; if (reset) { // Clear all previous producers + kDebug() << "/+++++++++++++++ DELETE ALL PRODS " << producer->get("id"); deleteProducers(); } QString id = producer->get("id"); + kDebug() << "// set prod: " << id; if (id.contains('_')) { // this is a subtrack producer, insert it at correct place id = id.section('_', 1); @@ -439,8 +460,7 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) } if (m_audioTrackProducers.at(pos) == NULL) m_audioTrackProducers[pos] = producer; return; - } - if (id.endsWith("video")) { + } else if (id.endsWith("video")) { m_videoOnlyProducer = producer; return; } diff --git a/src/docclipbase.h b/src/docclipbase.h index 5c52c1bc..3714f1aa 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -173,6 +173,7 @@ Q_OBJECT public: void refreshThumbUrl(); const char *producerProperty(const char *name) const; void setProducerProperty(const char *name, const char *data); + void clearProducers(); void deleteProducers(); /** Set default play zone for clip monitor */ diff --git a/src/graphicsscenerectmove.cpp b/src/graphicsscenerectmove.cpp index 47133a20..275c2a4d 100644 --- a/src/graphicsscenerectmove.cpp +++ b/src/graphicsscenerectmove.cpp @@ -246,7 +246,7 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e) } else if (m_tool == TITLE_TEXT) { m_selectedItem = addText(QString()); emit newText((QGraphicsTextItem *) m_selectedItem); - m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); ((QGraphicsTextItem *)m_selectedItem)->setTextInteractionFlags(Qt::TextEditorInteraction); m_selectedItem->setPos(e->scenePos()); QGraphicsScene::mousePressEvent(e); @@ -483,7 +483,7 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) // create new rect item m_selectedItem = addRect(0, 0, e->scenePos().x() - m_sceneClickPoint.x(), e->scenePos().y() - m_sceneClickPoint.y()); emit newRect((QGraphicsRectItem *) m_selectedItem); - m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemClipsToShape); + m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); m_selectedItem->setPos(m_sceneClickPoint); m_resizeMode = BottomRight; QGraphicsScene::mouseMoveEvent(e); diff --git a/src/guide.cpp b/src/guide.cpp index d608d7d0..fb1d7f86 100644 --- a/src/guide.cpp +++ b/src/guide.cpp @@ -19,26 +19,30 @@ #include "guide.h" #include "customtrackview.h" -#include "customtrackscene.h" #include "kdenlivesettings.h" #include #include #include +#include Guide::Guide(CustomTrackView *view, GenTime pos, QString label, double fps, double height) : QGraphicsLineItem(), m_position(pos), m_label(label), m_fps(fps), - m_view(view) + m_view(view), + m_pen(QPen()) { - setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemClipsToShape); + setFlags(QGraphicsItem::ItemIsMovable); setToolTip(label); setLine(0, 0, 0, height); setPos(m_position.frames(m_fps), 0); - setPen(QPen(QBrush(QColor(0, 0, 200, 180)), 2)); + m_pen.setWidthF(0); + m_pen.setColor(QColor(0, 0, 200, 180)); + //m_pen.setCosmetic(true); + setPen(m_pen); setZValue(999); setAcceptsHoverEvents(true); const QFontMetrics metric = m_view->fontMetrics(); @@ -83,13 +87,15 @@ int Guide::type() const //virtual void Guide::hoverEnterEvent(QGraphicsSceneHoverEvent *) { - setPen(QPen(QBrush(QColor(200, 0, 0, 180)), 2)); + m_pen.setColor(QColor(200, 0, 0, 180)); + setPen(m_pen); } //virtual void Guide::hoverLeaveEvent(QGraphicsSceneHoverEvent *) { - setPen(QPen(QBrush(QColor(0, 0, 200, 180)), 2)); + m_pen.setColor(QColor(0, 0, 200, 180)); + setPen(m_pen); } //virtual @@ -108,44 +114,46 @@ QVariant Guide::itemChange(GraphicsItemChange change, const QVariant &value) // virtual QRectF Guide::boundingRect() const { + double scale = m_view->matrix().m11(); + double width = m_pen.widthF() / scale * 2; + QRectF rect(line().x1() - width / 2 , line().y1(), width, line().y2() - line().y1()); if (KdenliveSettings::showmarkers()) { - QRectF rect = QGraphicsLineItem::boundingRect(); - rect.setLeft(line().x1()); - rect.setWidth(m_width / static_cast (scene())->scale().x()); - return rect; - } else return QGraphicsLineItem::boundingRect(); + rect.setWidth(width + m_width / scale); + } + return rect; } // virtual QPainterPath Guide::shape() const { QPainterPath path; - path.addRect(line().x1() - pen().widthF() / 2, line().y1(), pen().widthF(), line().y2() - line().y1()); + if (!scene()) return path; + double scale = m_view->matrix().m11(); + double width = m_pen.widthF() / scale * 2; + path.addRect(line().x1() - width / 2 , line().y1(), width, line().y2() - line().y1()); if (KdenliveSettings::showmarkers()) { const QFontMetrics metric = m_view->fontMetrics(); - int height = metric.height(); - path.addRoundedRect(line().x1(), line().y1() + 10, m_width / static_cast (scene())->scale().x(), height, 3, 3); + QRectF txtBounding(line().x1() + 1 / scale, line().y1() + 10, m_width / scale, metric.height() / m_view->matrix().m22()); + path.addRect(txtBounding); } return path; } // virtual -void Guide::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*w*/) +void Guide::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget */*w*/) { - painter->setMatrixEnabled(false); - QLineF guideline = painter->matrix().map(line()); - painter->setPen(pen()); - painter->drawLine(guideline); - //painter->fillRect(painter->matrix().mapRect(boundingRect()), QColor(200, 100, 100, 100)); - //QGraphicsLineItem::paint(painter, option, w); + QGraphicsLineItem::paint(painter, option); if (KdenliveSettings::showmarkers()) { - QPointF p1 = guideline.p1() + QPointF(1, 0); - QRectF txtBounding = painter->boundingRect(p1.x(), p1.y() + 10, m_width, 50, Qt::AlignLeft | Qt::AlignTop, ' ' + m_label + ' '); + painter->setMatrixEnabled(false); + QPointF p1 = painter->matrix().map(line()).p1() + QPointF(1, 0); + const QFontMetrics metric = m_view->fontMetrics(); + QRectF txtBounding = painter->boundingRect(p1.x(), p1.y() + 10, m_width, metric.height(), Qt::AlignLeft | Qt::AlignTop, ' ' + m_label + ' '); QPainterPath path; path.addRoundedRect(txtBounding, 3, 3); - painter->fillPath(path, QBrush(pen().color())); + painter->fillPath(path, QBrush(m_pen.color())); painter->setPen(Qt::white); painter->drawText(txtBounding, Qt::AlignCenter, m_label); + painter->setMatrixEnabled(true); } } diff --git a/src/guide.h b/src/guide.h index dc455a59..150f83d6 100644 --- a/src/guide.h +++ b/src/guide.h @@ -21,6 +21,7 @@ #define GUIDE_H #include +#include #include "gentime.h" #include "definitions.h" @@ -54,6 +55,7 @@ private: double m_fps; CustomTrackView *m_view; int m_width; + QPen m_pen; }; #endif diff --git a/src/headertrack.cpp b/src/headertrack.cpp index 679e1256..74be8100 100644 --- a/src/headertrack.cpp +++ b/src/headertrack.cpp @@ -28,6 +28,7 @@ #include #include #include +#include HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QWidget *parent) : QWidget(parent), @@ -142,6 +143,11 @@ void HeaderTrack::setLock(bool lock) } void HeaderTrack::slotDeleteTrack() +{ + QTimer::singleShot(500, this, SLOT(deleteTrack())); +} + +void HeaderTrack::deleteTrack() { emit deleteTrack(m_index); } diff --git a/src/headertrack.h b/src/headertrack.h index 903e45a3..7d95c10f 100644 --- a/src/headertrack.h +++ b/src/headertrack.h @@ -32,7 +32,7 @@ class HeaderTrack : public QWidget public: HeaderTrack(int index, TrackInfo info, int height, QWidget *parent = 0); - ~HeaderTrack(); + virtual ~HeaderTrack(); void setLock(bool lock); void adjustSize(int height); @@ -45,6 +45,7 @@ private slots: void switchAudio(); void switchVideo(); void slotDeleteTrack(); + void deleteTrack(); void slotAddTrack(); void slotChangeTrack(); void slotRenameTrack(); diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 4551ee26..4d4a451d 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -745,8 +745,10 @@ void KdenliveDoc::updatePreviewSettings() { m_clipManager->updatePreviewSettings(); m_render->updatePreviewSettings(); + QList prods = m_render->producersList(); m_clipManager->resetProducersList(m_render->producersList()); - + qDeleteAll(prods); + prods.clear(); } Render *KdenliveDoc::renderer() @@ -754,7 +756,7 @@ Render *KdenliveDoc::renderer() return m_render; } -void KdenliveDoc::updateClip(const QString &id) +void KdenliveDoc::updateClip(const QString id) { emit updateClipDisplay(id); } diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 4007f595..217d4bc2 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -73,7 +73,7 @@ Q_OBJECT public: void deleteClip(const QString &clipId); int getFramePos(QString duration); DocClipBase *getBaseClip(const QString &clipId); - void updateClip(const QString &id); + void updateClip(const QString id); void deleteProjectClip(QList ids); /** Inform application of the audio thumbnails generation progress */ void setThumbsProgress(const QString &message, int progress); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 56b402e5..574fc94d 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -642,8 +642,7 @@ void ProjectList::slotAddClip(const QList givenList, const QString &group allExtensions.append(' '); } } - QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files"); - dialogFilter.append("\n*" + QLatin1Char('|') + i18n("All Files")); + const QString dialogFilter = allExtensions.simplified() + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files"); list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), dialogFilter, this); } else { diff --git a/src/renderer.cpp b/src/renderer.cpp index 47cdad14..7b5ce609 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -102,18 +102,35 @@ void Render::closeMlt() { //delete m_osdTimer; if (m_mltProducer) { - Mlt::Service service(m_mltProducer->get_service()); + Mlt::Service service(m_mltProducer->parent().get_service()); + mlt_service_lock(service.get_service()); + if (service.type() == tractor_type) { Mlt::Tractor tractor(service); - int trackNb = tractor.count(); + Mlt::Field *field = tractor.field(); + mlt_service nextservice = mlt_service_get_producer(service.get_service()); + mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice); + QString mlt_type = mlt_properties_get(properties, "mlt_type"); + QString resource = mlt_properties_get(properties, "mlt_service"); + // Delete all transitions + while (mlt_type == "transition") { + mlt_field_disconnect_service(field->get_field(), nextservice); + nextservice = mlt_service_producer(nextservice); + if (nextservice == NULL) break; + properties = MLT_SERVICE_PROPERTIES(nextservice); + mlt_type = mlt_properties_get(properties, "mlt_type"); + resource = mlt_properties_get(properties, "mlt_service"); + } + int trackNb = tractor.count(); while (trackNb > 0) { Mlt::Producer trackProducer(tractor.track(trackNb - 1)); Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); - trackPlaylist.clear(); + if (trackPlaylist.type() == playlist_type) trackPlaylist.clear(); trackNb--; } } + mlt_service_unlock(service.get_service()); } kDebug() << "// // // CLOSE RENDERER " << m_name; @@ -133,7 +150,8 @@ void Render::buildConsumer() delete m_blackClip; m_blackClip = NULL; - if (m_mltProfile) delete m_mltProfile; + //TODO: uncomment following line when everything is clean + //if (m_mltProfile) delete m_mltProfile; m_mltProfile = new Mlt::Profile(tmp); delete[] tmp; @@ -864,8 +882,6 @@ int Render::setSceneList(QString playlist, int position) if (m_winid == -1) return -1; m_isBlocked = true; int error; - qDeleteAll(m_slowmotionProducers.values()); - m_slowmotionProducers.clear(); //kWarning() << "////// RENDER, SET SCENE LIST: " << playlist; @@ -877,25 +893,46 @@ int Render::setSceneList(QString playlist, int position) if (!m_mltConsumer->is_stopped()) { m_mltConsumer->stop(); - //m_mltConsumer->set("refresh", 0); } + m_mltConsumer->set("refresh", 0); if (m_mltProducer) { m_mltProducer->set_speed(0); //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo); - Mlt::Service service(m_mltProducer->get_service()); + Mlt::Service service(m_mltProducer->parent().get_service()); + mlt_service_lock(service.get_service()); + if (service.type() == tractor_type) { Mlt::Tractor tractor(service); + Mlt::Field *field = tractor.field(); + mlt_service nextservice = mlt_service_get_producer(service.get_service()); + mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice); + QString mlt_type = mlt_properties_get(properties, "mlt_type"); + QString resource = mlt_properties_get(properties, "mlt_service"); + // Delete all transitions + while (mlt_type == "transition") { + mlt_field_disconnect_service(field->get_field(), nextservice); + nextservice = mlt_service_producer(nextservice); + if (nextservice == NULL) break; + properties = MLT_SERVICE_PROPERTIES(nextservice); + mlt_type = mlt_properties_get(properties, "mlt_type"); + resource = mlt_properties_get(properties, "mlt_service"); + } + int trackNb = tractor.count(); while (trackNb > 0) { Mlt::Producer trackProducer(tractor.track(trackNb - 1)); Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service()); - trackPlaylist.clear(); + if (trackPlaylist.type() == playlist_type) trackPlaylist.clear(); trackNb--; } } + mlt_service_unlock(service.get_service()); + + qDeleteAll(m_slowmotionProducers.values()); + m_slowmotionProducers.clear(); delete m_mltProducer; m_mltProducer = NULL; @@ -1638,7 +1675,7 @@ bool Render::mltRemoveClip(int track, GenTime position) //kDebug()<<"//// Deleting at: "<< (int) position.frames(m_fps) <<" --------------------------------------"; m_isBlocked = true; Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex); - delete clip; + if (clip) delete clip; trackPlaylist.consolidate_blanks(0); /*if (QString(clip.parent().get("transparency")).toInt() == 1) mltDeleteTransparency((int) position.frames(m_fps), track, QString(clip.parent().get("id")).toInt());*/ @@ -3057,7 +3094,7 @@ void Render::mltSavePlaylist() fileConsumer.start(); } -QList Render::producersList() +const QList Render::producersList() { QList prods; if (m_mltProducer == NULL) return prods; @@ -3244,16 +3281,16 @@ void Render::mltDeleteTrack(int ix) //kDebug() << "/////////// RESULT SCENE: \n" << doc.toString(); setSceneList(doc.toString(), m_framePosition); - if (m_mltProducer != NULL) { - Mlt::Producer parentProd(m_mltProducer->parent()); - if (parentProd.get_producer() != NULL) { - Mlt::Service service(parentProd.get_service()); - if (service.type() == tractor_type) { - Mlt::Tractor tractor(service); - mltCheckLength(&tractor); + /* if (m_mltProducer != NULL) { + Mlt::Producer parentProd(m_mltProducer->parent()); + if (parentProd.get_producer() != NULL) { + Mlt::Service service(parentProd.get_service()); + if (service.type() == tractor_type) { + Mlt::Tractor tractor(service); + mltCheckLength(&tractor); + } } - } - } + }*/ } diff --git a/src/renderer.h b/src/renderer.h index fe0814a2..71319916 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -202,7 +202,7 @@ Q_OBJECT public: in the ClipManager list and speed is the current speed */ int mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int strobe, Mlt::Producer *prod); - QList producersList(); + const QList producersList(); void updatePreviewSettings(); void setDropFrames(bool show); diff --git a/src/timecode.cpp b/src/timecode.cpp index 9a28bcba..8bf4e0b0 100644 --- a/src/timecode.cpp +++ b/src/timecode.cpp @@ -92,7 +92,7 @@ QString Timecode::getTimecode(const GenTime & time) const } } -QString Timecode::getTimecodeFromFrames(int frames) const +const QString Timecode::getTimecodeFromFrames(int frames) const { return getTimecodeHH_MM_SS_FF(frames); } @@ -163,7 +163,7 @@ QString Timecode::getEasyTimecode(const GenTime & time, const double &fps) } -QString Timecode::getTimecodeHH_MM_SS_FF(const GenTime & time) const +const QString Timecode::getTimecodeHH_MM_SS_FF(const GenTime & time) const { if (m_dropFrame) return getTimecodeDropFrame(time); @@ -171,7 +171,7 @@ QString Timecode::getTimecodeHH_MM_SS_FF(const GenTime & time) const return getTimecodeHH_MM_SS_FF((int) time.frames(m_realFps)); } -QString Timecode::getTimecodeHH_MM_SS_FF(int frames) const +const QString Timecode::getTimecodeHH_MM_SS_FF(int frames) const { if (m_dropFrame) { return getTimecodeDropFrame(frames); diff --git a/src/timecode.h b/src/timecode.h index c18752fa..c28c25e3 100644 --- a/src/timecode.h +++ b/src/timecode.h @@ -53,7 +53,7 @@ public: int getFrameCount(const QString duration) const; static QString getEasyTimecode(const GenTime & time, const double &fps); static QString getStringTimecode(int frames, const double &fps); - QString getTimecodeFromFrames(int frames) const; + const QString getTimecodeFromFrames(int frames) const; int fps() const; private: @@ -62,8 +62,8 @@ private: int m_displayedFramesPerSecond; double m_realFps; - QString getTimecodeHH_MM_SS_FF(const GenTime & time) const; - QString getTimecodeHH_MM_SS_FF(int frames) const; + const QString getTimecodeHH_MM_SS_FF(const GenTime & time) const; + const QString getTimecodeHH_MM_SS_FF(int frames) const; QString getTimecodeHH_MM_SS_HH(const GenTime & time) const; QString getTimecodeFrames(const GenTime & time) const; diff --git a/src/titlewidget.cpp b/src/titlewidget.cpp index 1edc631e..1dc30385 100644 --- a/src/titlewidget.cpp +++ b/src/titlewidget.cpp @@ -503,10 +503,11 @@ void TitleWidget::displayBackgroundFrame() QPixmap bg(m_frameWidth / 2, m_frameHeight / 2); QPixmap pattern(20, 20); pattern.fill(); + QColor bgcolor(210, 210, 210); QPainter p; p.begin(&pattern); - p.fillRect(QRect(0, 0, 10, 10), QColor(210, 210, 210)); - p.fillRect(QRect(10, 10, 20, 20), QColor(210, 210, 210)); + p.fillRect(QRect(0, 0, 10, 10), bgcolor); + p.fillRect(QRect(10, 10, 20, 20), bgcolor); p.end(); QBrush br(pattern); diff --git a/src/trackdialog.cpp b/src/trackdialog.cpp new file mode 100644 index 00000000..2526d983 --- /dev/null +++ b/src/trackdialog.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#include "trackdialog.h" +#include "kdenlivedoc.h" +#include "kdenlivesettings.h" + +#include + + +TrackDialog::TrackDialog(KdenliveDoc *doc, QWidget * parent) : + QDialog(parent), + m_doc(doc) +{ + //setFont(KGlobalSettings::toolBarFont()); + view.setupUi(this); + connect(view.track_nb, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateName(int))); +} + +TrackDialog::~TrackDialog() +{ +} + +void TrackDialog::slotUpdateName(int ix) +{ + ix = m_doc->tracksCount() - ix; + view.track_name->setText(m_doc->trackInfoAt(ix - 1).trackName); +} + + +#include "trackdialog.moc" + + diff --git a/src/trackdialog.h b/src/trackdialog.h new file mode 100644 index 00000000..0716b355 --- /dev/null +++ b/src/trackdialog.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef TRACKDIALOG_H +#define TRACKDIALOG_H + + +#include "ui_addtrack_ui.h" + +class KdenliveDoc; + +class TrackDialog : public QDialog +{ + Q_OBJECT + +public: + TrackDialog(KdenliveDoc *doc, QWidget * parent = 0); + ~TrackDialog(); + Ui::AddTrack_UI view; + +public slots: + + void slotUpdateName(int); + +private: + KdenliveDoc *m_doc; +}; + + +#endif + diff --git a/src/trackview.cpp b/src/trackview.cpp index aabf0e6c..1ab892e2 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -62,7 +62,6 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) : m_view.ruler_frame->setLayout(layout); layout->addWidget(m_ruler); - QHBoxLayout *sizeLayout = new QHBoxLayout; sizeLayout->setContentsMargins(0, 0, 0, 0); sizeLayout->setSpacing(0); @@ -70,6 +69,7 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) : QString style1 = "QToolButton {border-style: none;margin: 0px 3px;padding: 0px;} QToolButton:pressed:hover { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;} QToolButton:hover { background-color: rgba(255, 255, 255, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}"; + QToolButton *butSmall = new QToolButton(this); butSmall->setIcon(KIcon("kdenlive-zoom-small")); butSmall->setToolTip(i18n("Smaller tracks")); @@ -83,7 +83,6 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) : sizeLayout->addWidget(butLarge); m_view.size_frame->setStyleSheet(style1); - QHBoxLayout *tracksLayout = new QHBoxLayout; tracksLayout->setContentsMargins(0, 0, 0, 0); tracksLayout->setSpacing(0); @@ -96,11 +95,9 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) : m_headersLayout->setContentsMargins(0, m_trackview->frameWidth(), 0, 0); m_headersLayout->setSpacing(0); m_view.headers_container->setLayout(m_headersLayout); - connect(m_view.headers_area->verticalScrollBar(), SIGNAL(valueChanged(int)), m_trackview->verticalScrollBar(), SLOT(setValue(int))); tracksLayout->addWidget(m_trackview); - connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), m_view.headers_area->verticalScrollBar(), SLOT(setValue(int))); connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders())); @@ -446,14 +443,17 @@ void TrackView::refresh() void TrackView::slotRebuildTrackHeaders() { - QList list = m_doc->tracksList(); + kDebug() << "--------- - - - -REBUILD TLK HEAD"; + const QList list = m_doc->tracksList(); QLayoutItem *child; + m_view.headers_container->hide(); while ((child = m_headersLayout->takeAt(0)) != 0) { if (child->widget()) delete child->widget(); delete child; } int max = list.count(); int height = KdenliveSettings::trackheight() * m_scene->scale().y(); + for (int i = 0; i < max; i++) { HeaderTrack *header = new HeaderTrack(i, list.at(max - i - 1), height, this); connect(header, SIGNAL(switchTrackVideo(int)), m_trackview, SLOT(slotSwitchTrackVideo(int))); @@ -466,6 +466,7 @@ void TrackView::slotRebuildTrackHeaders() connect(header, SIGNAL(renameTrack(int)), this, SLOT(slotRenameTrack(int))); m_headersLayout->addWidget(header); } + m_view.headers_container->show(); } @@ -847,6 +848,7 @@ void TrackView::slotRenameTrack(int ix) info.trackName = newName; m_doc->setTrackType(tracknumber - 1, info); QTimer::singleShot(300, this, SLOT(slotRebuildTrackHeaders())); + m_doc->setModified(true); } } diff --git a/src/transition.cpp b/src/transition.cpp index 0c2b6452..eecbee67 100644 --- a/src/transition.cpp +++ b/src/transition.cpp @@ -117,22 +117,6 @@ bool Transition::invertedTransition() const return false; //m_parameters.attribute("reverse").toInt(); } -QPixmap Transition::transitionPixmap() const -{ - KIcon icon; - QString tag = transitionTag(); - if (tag == "luma") { - if (invertedTransition()) icon = KIcon("kdenlive_trans_up"); - else icon = KIcon("kdenlive_trans_down"); - } else if (tag == "composite") { - icon = KIcon("kdenlive_trans_wiper"); - } else if (tag == "lumafile") { - icon = KIcon("kdenlive_trans_luma"); - } else icon = KIcon("kdenlive_trans_pip"); - return icon.pixmap(QSize(15, 15)); -} - - void Transition::setTransitionDirection(bool /*inv*/) { //m_parameters.setAttribute("reverse", inv); @@ -166,8 +150,8 @@ void Transition::paint(QPainter *painter, const double scale = option->matrix.m11(); QRectF exposed = option->exposedRect; painter->setClipRect(exposed); - QRectF br = rect(); - QRectF mapped = painter->matrix().mapRect(br); + const QRectF br = rect(); + const QRectF mapped = painter->matrix().mapRect(br); painter->fillRect(exposed, brush()); @@ -175,12 +159,17 @@ void Transition::paint(QPainter *painter, QPointF p1(br.x(), br.y() + br.height() / 2 - 7); painter->setMatrixEnabled(false); //painter->drawPixmap(painter->matrix().map(p1) + QPointF(5, 0), transitionPixmap()); - QString text = transitionName(); - if (m_forceTransitionTrack) text.append("|>"); - QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + text + ' '); - painter->fillRect(txtBounding, QBrush(QColor(50, 50, 0, 150))); - txtBounding.translate(QPointF(1, 1)); - painter->setPen(QColor(255, 255, 255, 255)); + const QString text = m_name + (m_forceTransitionTrack ? "|>" : QString()); + const QRectF txtBounding = painter->boundingRect(mapped, Qt::AlignHCenter | Qt::AlignVCenter, ' ' + text + ' '); + + QColor frameColor(Qt::black); + if (isSelected() || (parentItem() && parentItem()->isSelected())) { + frameColor = QColor(Qt::red); + } + frameColor.setAlpha(150); + painter->fillRect(txtBounding, frameColor); + + painter->setPen(Qt::white); painter->drawText(txtBounding, Qt::AlignCenter, text); /* painter->setPen(QColor(0, 0, 0, 180)); @@ -201,8 +190,7 @@ void Transition::paint(QPainter *painter, //pen.setWidth(1); } - pen.setWidthF(1.0); - pen.setCosmetic(true); + //pen.setCosmetic(true); painter->setPen(pen); painter->setClipping(false); painter->drawRect(br.adjusted(0, 0, -1 / scale, 0)); @@ -323,7 +311,7 @@ QDomElement Transition::toXML() m_parameters.setAttribute("clipb_starttime", m_secondClip->startPos().frames(m_referenceClip->fps())); m_parameters.setAttribute("clipb_track", transitionEndTrack()); } - return m_parameters; + return m_parameters.cloneNode().toElement(); } bool Transition::hasGeometry() diff --git a/src/transition.h b/src/transition.h index 5004ad53..088fa15a 100644 --- a/src/transition.h +++ b/src/transition.h @@ -61,7 +61,6 @@ public: void setTransitionParameters(const QDomElement params); void setTransitionDirection(bool inv); void setTransitionTrack(int track); - QPixmap transitionPixmap() const; //Transition *reparent(ClipItem * clip); bool isValid() const; /** Transition should be linked to another track */ diff --git a/src/wizard.h b/src/wizard.h index b3766328..633ba299 100644 --- a/src/wizard.h +++ b/src/wizard.h @@ -48,7 +48,7 @@ public: painter->setPen(option.palette.color(QPalette::HighlightedText)); QColor backgroundColor = option.palette.color(QPalette::Highlight); painter->setBrush(QBrush(backgroundColor)); - painter->fillRect(r1, QBrush(backgroundColor)); + painter->fillRect(r1, backgroundColor); } QFont font = painter->font(); font.setBold(true); -- 2.39.2