From 664bf2e8e880714395658a254171b7d5b9ab264b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sat, 20 Oct 2012 16:15:44 +0200 Subject: [PATCH] Clip markers can now have a category that is shown as a color. --- src/clipitem.cpp | 15 +++--- src/clipproperties.cpp | 13 ++++-- src/clipproperties.h | 2 +- src/commands/addmarkercommand.cpp | 17 ++++--- src/commands/addmarkercommand.h | 7 ++- src/customtrackview.cpp | 35 ++++++++++---- src/customtrackview.h | 4 +- src/definitions.h | 33 +++++++++++-- src/docclipbase.cpp | 29 ++++++++---- src/docclipbase.h | 5 +- src/kdenlivedoc.cpp | 7 ++- src/mainwindow.cpp | 21 +++++---- src/markerdialog.cpp | 9 +++- src/monitor.cpp | 5 +- src/projectlist.cpp | 11 +++-- src/smallruler.cpp | 7 +-- src/smallruler.h | 4 +- src/widgets/markerdialog_ui.ui | 78 +++++++++++++++++-------------- 18 files changed, 190 insertions(+), 112 deletions(-) diff --git a/src/clipitem.cpp b/src/clipitem.cpp index 5d73dc42..091eee6a 100644 --- a/src/clipitem.cpp +++ b/src/clipitem.cpp @@ -941,10 +941,8 @@ void ClipItem::paint(QPainter *painter, QList < CommentedTime >::Iterator it = markers.begin(); GenTime pos; double framepos; - QBrush markerBrush(QColor(120, 120, 0, 140)); + QBrush markerBrush(QColor(120, 120, 0, 140)); QPen pen = painter->pen(); - pen.setColor(QColor(255, 255, 255, 200)); - pen.setStyle(Qt::DotLine); for (; it != markers.end(); ++it) { pos = GenTime((int)((*it).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart(); @@ -952,6 +950,8 @@ void ClipItem::paint(QPainter *painter, if (pos > cropDuration()) break; QLineF l(rect().x() + pos.frames(m_fps), rect().y(), rect().x() + pos.frames(m_fps), rect().bottom()); QLineF l2 = painter->worldTransform().map(l); + pen.setColor(CommentedTime::markerColor((*it).markerType())); + pen.setStyle(Qt::DotLine); painter->setPen(pen); painter->drawLine(l2); if (KdenliveSettings::showmarkers()) { @@ -960,9 +960,10 @@ void ClipItem::paint(QPainter *painter, const QRectF r2 = painter->worldTransform().mapRect(r1); const QRectF txtBounding3 = painter->boundingRect(r2, Qt::AlignLeft | Qt::AlignTop, ' ' + (*it).comment() + ' '); painter->setBrush(markerBrush); - painter->setPen(Qt::NoPen); - painter->drawRoundedRect(txtBounding3, 3, 3); - painter->setBrush(QBrush(Qt::NoBrush)); + pen.setStyle(Qt::SolidLine); + painter->setPen(pen); + painter->drawRect(txtBounding3); + painter->setBrush(Qt::NoBrush); painter->setPen(Qt::white); painter->drawText(txtBounding3, Qt::AlignCenter, (*it).comment()); } @@ -1093,7 +1094,7 @@ QList ClipItem::commentedSnapMarkers() const pos = GenTime((int)(markers.at(i).time().frames(m_fps) / qAbs(m_speed) + 0.5), m_fps) - cropStart(); if (pos > GenTime()) { if (pos > cropDuration()) break; - else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment())); + else snaps.append(CommentedTime(pos + startPos(), markers.at(i).comment(), markers.at(i).markerType())); } } return snaps; diff --git a/src/clipproperties.cpp b/src/clipproperties.cpp index adb9ad44..3fd5b351 100644 --- a/src/clipproperties.cpp +++ b/src/clipproperties.cpp @@ -732,8 +732,9 @@ void ClipProperties::slotFillMarkersList(DocClipBase *clip) for (int count = 0; count < marks.count(); ++count) { QString time = m_tc.getTimecode(marks[count].time()); QStringList itemtext; - itemtext << time << marks[count].comment(); - (void) new QTreeWidgetItem(m_view.markers_list, itemtext); + itemtext << time << marks.at(count).comment(); + QTreeWidgetItem *item = new QTreeWidgetItem(m_view.markers_list, itemtext); + item->setData(0, Qt::DecorationRole, CommentedTime::markerColor(marks.at(count).markerType())); } } @@ -743,7 +744,7 @@ void ClipProperties::slotAddMarker() QPointer d = new MarkerDialog(m_clip, marker, m_tc, i18n("Add Marker"), this); if (d->exec() == QDialog::Accepted) { - emit addMarker(m_clip->getId(), d->newMarker().time(), d->newMarker().comment()); + emit addMarker(m_clip->getId(), d->newMarker()); } delete d; } @@ -765,7 +766,7 @@ void ClipProperties::slotEditMarker() if (pos < 0 || pos > marks.count() - 1) return; MarkerDialog d(m_clip, marks.at(pos), m_tc, i18n("Edit Marker"), this); if (d.exec() == QDialog::Accepted) { - emit addMarker(m_clip->getId(), d.newMarker().time(), d.newMarker().comment()); + emit addMarker(m_clip->getId(), d.newMarker()); } } @@ -774,7 +775,9 @@ void ClipProperties::slotDeleteMarker() QList < CommentedTime > marks = m_clip->commentedSnapMarkers(); int pos = m_view.markers_list->currentIndex().row(); if (pos < 0 || pos > marks.count() - 1) return; - emit addMarker(m_clip->getId(), marks.at(pos).time(), QString()); + CommentedTime marker = marks.at(pos); + marker.setMarkerType(-1); + emit addMarker(m_clip->getId(), marker); } const QString &ClipProperties::clipId() const diff --git a/src/clipproperties.h b/src/clipproperties.h index 17f143ce..c321b202 100644 --- a/src/clipproperties.h +++ b/src/clipproperties.h @@ -91,7 +91,7 @@ private: QFrame* m_proxyContainer; signals: - void addMarker(const QString &, GenTime, QString); + void addMarker(const QString &, CommentedTime); void deleteProxy(const QString); void applyNewClipProperties(const QString, QMap , QMap , bool, bool); void saveMarkers(const QString &); diff --git a/src/commands/addmarkercommand.cpp b/src/commands/addmarkercommand.cpp index bc6d7320..376ff81e 100644 --- a/src/commands/addmarkercommand.cpp +++ b/src/commands/addmarkercommand.cpp @@ -21,16 +21,15 @@ #include -AddMarkerCommand::AddMarkerCommand(CustomTrackView *view, const QString &oldcomment, const QString &comment, const QString &id, const GenTime &pos, QUndoCommand * parent) : +AddMarkerCommand::AddMarkerCommand(CustomTrackView *view, const CommentedTime oldMarker, const CommentedTime newMarker, const QString &id, QUndoCommand * parent) : QUndoCommand(parent), m_view(view), - m_oldcomment(oldcomment), - m_comment(comment), - m_id(id), - m_pos(pos) + m_oldMarker(oldMarker), + m_newMarker(newMarker), + m_id(id) { - if (m_comment.isEmpty()) setText(i18n("Delete marker")); - else if (m_oldcomment.isEmpty()) setText(i18n("Add marker")); + if (m_newMarker.markerType() < 0) setText(i18n("Delete marker")); + else if (m_oldMarker.comment().isEmpty()) setText(i18n("Add marker")); else setText(i18n("Edit marker")); } @@ -38,11 +37,11 @@ AddMarkerCommand::AddMarkerCommand(CustomTrackView *view, const QString &oldcomm // virtual void AddMarkerCommand::undo() { - m_view->addMarker(m_id, m_pos, m_oldcomment); + m_view->addMarker(m_id, m_oldMarker); } // virtual void AddMarkerCommand::redo() { - m_view->addMarker(m_id, m_pos, m_comment); + m_view->addMarker(m_id, m_newMarker); } diff --git a/src/commands/addmarkercommand.h b/src/commands/addmarkercommand.h index c89d0c67..12ef595d 100644 --- a/src/commands/addmarkercommand.h +++ b/src/commands/addmarkercommand.h @@ -32,16 +32,15 @@ class CustomTrackView; class AddMarkerCommand : public QUndoCommand { public: - AddMarkerCommand(CustomTrackView *view, const QString &oldcomment, const QString &comment, const QString &id, const GenTime &pos, QUndoCommand * parent = 0); + AddMarkerCommand(CustomTrackView *view, const CommentedTime oldMarker, const CommentedTime newMarker, const QString &id, QUndoCommand * parent = 0); virtual void undo(); virtual void redo(); private: CustomTrackView *m_view; - QString m_oldcomment; - QString m_comment; + CommentedTime m_oldMarker; + CommentedTime m_newMarker; QString m_id; - GenTime m_pos; }; #endif diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index d312842e..a82b48bb 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -5251,16 +5251,23 @@ void CustomTrackView::clipEnd() } } -void CustomTrackView::slotAddClipMarker(const QString &id, GenTime t, QString c, QUndoCommand *groupCommand) +void CustomTrackView::slotAddClipMarker(const QString &id, CommentedTime newMarker, QUndoCommand *groupCommand) { - QString oldcomment = m_document->clipManager()->getClipById(id)->markerComment(t); - AddMarkerCommand *command = new AddMarkerCommand(this, oldcomment, c, id, t, groupCommand); + CommentedTime oldMarker = m_document->clipManager()->getClipById(id)->markerAt(newMarker.time()); + if (oldMarker == CommentedTime()) { + oldMarker = newMarker; + oldMarker.setMarkerType(-1); + } + AddMarkerCommand *command = new AddMarkerCommand(this, oldMarker, newMarker, id, groupCommand); if (!groupCommand) m_commandStack->push(command); } void CustomTrackView::slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position) { - AddMarkerCommand *command = new AddMarkerCommand(this, comment, QString(), id, position); + CommentedTime oldmarker(position, comment); + CommentedTime marker = oldmarker; + marker.setMarkerType(-1); + AddMarkerCommand *command = new AddMarkerCommand(this, oldmarker, marker, id); m_commandStack->push(command); } @@ -5277,7 +5284,10 @@ void CustomTrackView::slotDeleteAllClipMarkers(const QString &id) deleteMarkers->setText("Delete clip markers"); for (int i = 0; i < markers.size(); i++) { - new AddMarkerCommand(this, markers.at(i).comment(), QString(), id, markers.at(i).time(), deleteMarkers); + CommentedTime oldMarker = markers.at(i); + CommentedTime marker = oldMarker; + marker.setMarkerType(-1); + new AddMarkerCommand(this, oldMarker, marker, id, deleteMarkers); } m_commandStack->push(deleteMarkers); } @@ -5353,19 +5363,24 @@ void CustomTrackView::slotLoadClipMarkers(const QString &id) } if (!markerText.isEmpty()) { // Marker found, add it - slotAddClipMarker(id, GenTime(time1), markerText, command); - if (time2 > 0 && time2 != time1) slotAddClipMarker(id, GenTime(time2), markerText, command); + //TODO: allow user to set a marker category + CommentedTime marker1(GenTime(time1), markerText); + slotAddClipMarker(id, marker1, command); + if (time2 > 0 && time2 != time1) { + CommentedTime marker2(GenTime(time2), markerText); + slotAddClipMarker(id, marker2, command); + } } } if (command->childCount() > 0) m_commandStack->push(command); else delete command; } -void CustomTrackView::addMarker(const QString &id, const GenTime &pos, const QString &comment) +void CustomTrackView::addMarker(const QString &id, const CommentedTime marker) { DocClipBase *base = m_document->clipManager()->getClipById(id); - if (!comment.isEmpty()) base->addSnapMarker(pos, comment); - else base->deleteSnapMarker(pos); + if (marker.markerType() < 0) base->deleteSnapMarker(marker.time()); + else base->addSnapMarker(marker); emit updateClipMarkers(base); setDocumentModified(); viewport()->update(); diff --git a/src/customtrackview.h b/src/customtrackview.h index c223016a..c4a84704 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -76,7 +76,7 @@ public: 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); + void addMarker(const QString &id, const CommentedTime marker); void setScale(double scaleFactor, double verticalScale); void deleteClip(const QString &clipId); /** @brief Add effect to current clip */ @@ -231,7 +231,7 @@ public slots: * @param id Id of the marker's clip * @param t Position of the marker * @param c Comment of the marker */ - void slotAddClipMarker(const QString &id, GenTime t, QString c, QUndoCommand *groupCommand = 0); + void slotAddClipMarker(const QString &id, CommentedTime newMarker, QUndoCommand *groupCommand = 0); void slotLoadClipMarkers(const QString &id); void slotSaveClipMarkers(const QString &id); bool addGuide(const GenTime &pos, const QString &comment); diff --git a/src/definitions.h b/src/definitions.h index b663fc6b..74e79bc7 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -262,9 +262,9 @@ public: class CommentedTime { public: - CommentedTime(): t(GenTime(0)) {} - CommentedTime(const GenTime &time, QString comment) - : t(time), c(comment) { } + CommentedTime(): t(GenTime(0)), type(0) {} + CommentedTime(const GenTime &time, QString comment, int markerType = 0) + : t(time), c(comment), type(markerType) { } QString comment() const { return (c.isEmpty() ? i18n("Marker") : c); @@ -275,6 +275,31 @@ public: void setComment(QString comm) { c = comm; } + void setMarkerType(int t) { + type = t; + } + int markerType() const { + return type; + } + static QColor markerColor(int type) { + switch (type) { + case 0: + return Qt::red; + break; + case 1: + return Qt::blue; + break; + case 2: + return Qt::green; + break; + case 3: + return Qt::yellow; + break; + default: + return Qt::cyan; + break; + } + }; /* Implementation of > operator; Works identically as with basic types. */ bool operator>(CommentedTime op) const { @@ -304,6 +329,8 @@ public: private: GenTime t; QString c; + int type; + }; diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 09494c9e..13d1c40b 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -290,22 +290,21 @@ QList < CommentedTime > DocClipBase::commentedSnapMarkers() const } -void DocClipBase::addSnapMarker(const GenTime & time, QString comment) +void DocClipBase::addSnapMarker(const CommentedTime marker) { QList < CommentedTime >::Iterator it = m_snapMarkers.begin(); for (it = m_snapMarkers.begin(); it != m_snapMarkers.end(); ++it) { - if ((*it).time() >= time) + if ((*it).time() >= marker.time()) break; } - if ((it != m_snapMarkers.end()) && ((*it).time() == time)) { - (*it).setComment(comment); + if ((it != m_snapMarkers.end()) && ((*it).time() == marker.time())) { + (*it).setComment(marker.comment()); + (*it).setMarkerType(marker.markerType()); //kError() << "trying to add Snap Marker that already exists, this will cause inconsistancies with undo/redo"; } else { - CommentedTime t(time, comment); - m_snapMarkers.insert(it, t); + m_snapMarkers.insert(it, marker); } - } void DocClipBase::editSnapMarker(const GenTime & time, QString comment) @@ -378,10 +377,9 @@ GenTime DocClipBase::findNextSnapMarker(const GenTime & currTime) return duration(); } -QString DocClipBase::markerComment(GenTime t) +QString DocClipBase::markerComment(GenTime t) const { - QList < CommentedTime >::Iterator itt = m_snapMarkers.begin(); - + QList < CommentedTime >::ConstIterator itt = m_snapMarkers.begin(); while (itt != m_snapMarkers.end()) { if ((*itt).time() == t) return (*itt).comment(); @@ -390,6 +388,17 @@ QString DocClipBase::markerComment(GenTime t) return QString(); } +CommentedTime DocClipBase::markerAt(GenTime t) const +{ + QList < CommentedTime >::ConstIterator itt = m_snapMarkers.begin(); + while (itt != m_snapMarkers.end()) { + if ((*itt).time() == t) + return (*itt); + ++itt; + } + return CommentedTime(); +} + void DocClipBase::clearThumbProducer() { if (m_thumbProd) m_thumbProd->clearProducer(); diff --git a/src/docclipbase.h b/src/docclipbase.h index fa363746..352a1bd6 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -263,9 +263,10 @@ public slots: GenTime hasSnapMarkers(const GenTime & time); QString deleteSnapMarker(const GenTime & time); void editSnapMarker(const GenTime & time, QString comment); - void addSnapMarker(const GenTime & time, QString comment); + void addSnapMarker(const CommentedTime marker); QList < GenTime > snapMarkers() const; - QString markerComment(GenTime t); + QString markerComment(GenTime t) const; + CommentedTime markerAt(GenTime t) const; void setClipThumbFrame(const uint &ix); uint getClipThumbFrame() const; void setProperties(QMap properties); diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index be19ccfd..dd1a10f9 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -282,8 +282,10 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup int maxchild = markerslist.count(); for (int k = 0; k < maxchild; k++) { e = markerslist.at(k).toElement(); - if (e.tagName() == "marker") - m_clipManager->getClipById(e.attribute("id"))->addSnapMarker(GenTime(e.attribute("time").toDouble()), e.attribute("comment")); + if (e.tagName() == "marker") { + CommentedTime marker(GenTime(e.attribute("time").toDouble()), e.attribute("comment"), e.attribute("type").toInt()); + m_clipManager->getClipById(e.attribute("id"))->addSnapMarker(marker); + } } infoXml.removeChild(markers); } @@ -725,6 +727,7 @@ QDomDocument KdenliveDoc::xmlSceneList(const QString &scene, const QStringList & marker.setAttribute("time", marks.at(j).time().ms() / 1000); marker.setAttribute("comment", marks.at(j).comment()); marker.setAttribute("id", e.attribute("id")); + marker.setAttribute("type", marks.at(j).markerType()); markers.appendChild(marker); } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0a138bb1..9d6e64d0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2839,7 +2839,7 @@ void MainWindow::slotAddClipMarker() QPointer d = new MarkerDialog(clip, marker, m_activeDocument->timecode(), i18n("Add Marker"), this); if (d->exec() == QDialog::Accepted) - m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker().time(), d->newMarker().comment()); + m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker()); delete d; } @@ -2915,20 +2915,20 @@ void MainWindow::slotEditClipMarker() } QString id = clip->getId(); - QString oldcomment = clip->markerComment(pos); - if (oldcomment.isEmpty()) { + CommentedTime oldMarker = clip->markerAt(pos); + if (oldMarker == CommentedTime()) { m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage); return; } - CommentedTime marker(pos, oldcomment); - QPointer d = new MarkerDialog(clip, marker, + QPointer d = new MarkerDialog(clip, oldMarker, m_activeDocument->timecode(), i18n("Edit Marker"), this); if (d->exec() == QDialog::Accepted) { - m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker().time(), d->newMarker().comment()); + m_activeTimeline->projectView()->slotAddClipMarker(id, d->newMarker()); if (d->newMarker().time() != pos) { // remove old marker - m_activeTimeline->projectView()->slotAddClipMarker(id, pos, QString()); + oldMarker.setMarkerType(-1); + m_activeTimeline->projectView()->slotAddClipMarker(id, oldMarker); } } delete d; @@ -2947,8 +2947,9 @@ void MainWindow::slotAddMarkerGuideQuickly() m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage); return; } - - m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), pos, m_activeDocument->timecode().getDisplayTimecode(pos, false)); + //TODO: allow user to set default marker category + CommentedTime marker(pos, m_activeDocument->timecode().getDisplayTimecode(pos, false)); + m_activeTimeline->projectView()->slotAddClipMarker(clip->getId(), marker); } else { m_activeTimeline->projectView()->slotAddGuide(false); } @@ -3311,7 +3312,7 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip) // any type of clip but a title ClipProperties *dia = new ClipProperties(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this); - connect(dia, SIGNAL(addMarker(const QString &, GenTime, QString)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, GenTime, QString))); + connect(dia, SIGNAL(addMarker(const QString &, CommentedTime)), m_activeTimeline->projectView(), SLOT(slotAddClipMarker(const QString &, CommentedTime))); connect(m_activeTimeline->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), dia, SLOT(slotFillMarkersList(DocClipBase *))); connect(dia, SIGNAL(loadMarkers(const QString &)), m_activeTimeline->projectView(), SLOT(slotLoadClipMarkers(const QString &))); connect(dia, SIGNAL(saveMarkers(const QString &)), m_activeTimeline->projectView(), SLOT(slotSaveClipMarkers(const QString &))); diff --git a/src/markerdialog.cpp b/src/markerdialog.cpp index a3935e5a..5846662f 100644 --- a/src/markerdialog.cpp +++ b/src/markerdialog.cpp @@ -36,6 +36,13 @@ MarkerDialog::MarkerDialog(DocClipBase *clip, CommentedTime t, Timecode tc, cons setupUi(this); setWindowTitle(caption); + // Set up categories + for (int i = 0; i < 5; ++i) { + marker_type->insertItem(i, i18n("Category %1", i)); + marker_type->setItemData(i, CommentedTime::markerColor(i), Qt::DecorationRole); + } + marker_type->setCurrentIndex(t.markerType()); + m_in = new TimecodeDisplay(tc, this); inputLayout->addWidget(m_in); m_in->setValue(t.time()); @@ -121,7 +128,7 @@ void MarkerDialog::slotUpdateThumb() CommentedTime MarkerDialog::newMarker() { - return CommentedTime(m_in->gentime(), marker_comment->text()); + return CommentedTime(m_in->gentime(), marker_comment->text(), marker_type->currentIndex()); } #include "markerdialog.moc" diff --git a/src/monitor.cpp b/src/monitor.cpp index ccdce950..d7491dea 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -226,6 +226,7 @@ QWidget *Monitor::container() bool Monitor::createOpenGlWidget(QWidget *parent, const QString profile) { render = new Render(id(), 0, profile, this); + kDebug()<<"+++++++++++++\nCREATED OPENGL WIDG\n++++++++++++++"; m_glWidget = new VideoGLWidget(parent); if (m_glWidget == NULL) { // Creation failed, we are in trouble... @@ -366,8 +367,8 @@ void Monitor::updateMarkers(DocClipBase *source) QAction *go = m_markerMenu->addAction(position); go->setData(pos); } - m_ruler->setMarkers(marks); - } else m_ruler->setMarkers(QList ()); + } + m_ruler->setMarkers(markers); m_markerMenu->setEnabled(!m_markerMenu->isEmpty()); } } diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 5880f4fe..5fe20516 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -3460,11 +3460,11 @@ void ProjectList::startClipFilterJob(const QString &filterName, const QString &c // Producer params jobParams << QString(); // Filter params, use a smaller region of the image to speed up operation - jobParams << filterName << "bounding=\"25%x25%:25%x25\" _scene_cuts=0"; + jobParams << filterName << "bounding=\"25%x25%:25%x25\" shot_change_list=0"; // Consumer jobParams << "null" << "all=1 terminate_on_pause=1 real_time=-1"; // Keys - jobParams << "_scene_cuts"; + jobParams << "shot_change_list"; QStringList extraParams; extraParams << "projecttreefilter" << "project_profile"; processClipJob(ids, QString(), false, jobParams, i18n("Auto split"), extraParams); @@ -3576,12 +3576,13 @@ void ProjectList::slotGotFilterJobResults(QString id, int , int , QString filter { if (filter == "motion_est") { // Autosplit filter, add sub zones - QStringList cuts = results.value("_scene_cuts").split(':', QString::SkipEmptyParts); + QStringList cuts = results.value("shot_change_list").split(';', QString::SkipEmptyParts); int cutPos = 0; QUndoCommand *command = new QUndoCommand(); command->setText(i18n("Auto Split Clip")); - foreach (const QString &pos, cuts) { - int newPos = pos.toInt(); + foreach (QString pos, cuts) { + if (!pos.contains("=")) continue; + int newPos = pos.section("=", 0, 0).toInt(); // Don't use scenes shorter than 1 second if (newPos - cutPos < 24) continue; (void) new AddClipCutCommand(this, id, cutPos, newPos, QString(), true, false, command); diff --git a/src/smallruler.cpp b/src/smallruler.cpp index 1f0dcfe1..0cf185b0 100644 --- a/src/smallruler.cpp +++ b/src/smallruler.cpp @@ -106,7 +106,7 @@ void SmallRuler::setZone(int start, int end) updatePixmap(); } -void SmallRuler::setMarkers(QList < int > list) +void SmallRuler::setMarkers(QList < CommentedTime > list) { m_markers = list; updatePixmap(); @@ -213,9 +213,10 @@ void SmallRuler::updatePixmap() } // draw markers if (!m_markers.isEmpty()) { - p.setPen(Qt::red); for (int i = 0; i < m_markers.count(); i++) { - p.drawLine(m_markers.at(i) * m_scale, 0, m_markers.at(i) * m_scale, 9); + int pos = m_markers.at(i).time().frames(m_manager->timecode().fps()) * m_scale; + p.setPen(CommentedTime::markerColor(m_markers.at(i).markerType())); + p.drawLine(pos, 0, pos, 9); } } p.end(); diff --git a/src/smallruler.h b/src/smallruler.h index ec08b6d1..6080ca2e 100644 --- a/src/smallruler.h +++ b/src/smallruler.h @@ -40,7 +40,7 @@ public: void setZoneStart(); void setZoneEnd(); QPoint zone(); - void setMarkers(QList < int > list); + void setMarkers(QList < CommentedTime > list); void updatePalette(); void refreshRuler(); @@ -58,7 +58,7 @@ private: int m_zoneStart; int m_zoneEnd; KStatefulBrush m_zoneBrush; - QList m_markers; + QList m_markers; QPixmap m_pixmap; MonitorManager *m_manager; Render *m_render; diff --git a/src/widgets/markerdialog_ui.ui b/src/widgets/markerdialog_ui.ui index cf09cf52..4bdcbe13 100644 --- a/src/widgets/markerdialog_ui.ui +++ b/src/widgets/markerdialog_ui.ui @@ -6,31 +6,35 @@ 0 0 - 312 - 88 + 376 + 124 Marker - - + + + + Position + + + + + - Qt::Vertical + Qt::Horizontal - 218 - 2 + 40 + 20 - - - - + Qt::Horizontal @@ -40,6 +44,12 @@ + + + + + + @@ -47,7 +57,27 @@ - + + + + Qt::Vertical + + + + 218 + 2 + + + + + + + + Category + + + + QFrame::NoFrame @@ -60,28 +90,8 @@ - - - - - - - Position - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - + + -- 2.39.2