From: Jean-Baptiste Mardelle Date: Sun, 10 Feb 2008 10:19:37 +0000 (+0000) Subject: Connect project monitor X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8244f2dfae1c7d4e7f1bf3ed5098d7994e4230e4;p=kdenlive Connect project monitor svn path=/branches/KDE4/; revision=1829 --- diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 8a0a07aa..1207ee61 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -34,9 +34,11 @@ #include "resizeclipcommand.h" #include "addtimelineclipcommand.h" -CustomTrackView::CustomTrackView(KUndoStack *commandStack, QGraphicsScene * projectscene, QWidget *parent) - : QGraphicsView(projectscene, parent), m_commandStack(commandStack), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0) +CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent) + : QGraphicsView(projectscene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0), m_document(doc) { + if (doc) m_commandStack = doc->commandStack(); + else m_commandStack == NULL; setMouseTracking(true); setAcceptDrops(true); m_animationTimer = new QTimeLine(800); @@ -347,6 +349,7 @@ void CustomTrackView::dropEvent ( QDropEvent * event ) { if (m_dropItem) { AddTimelineClipCommand *command = new AddTimelineClipCommand(this, m_dropItem->xml(), m_dropItem->track(), m_dropItem->startPos(), m_dropItem->rect(), m_dropItem->duration(), false); m_commandStack->push(command); + m_document->renderer()->mltInsertClip(m_dropItem->track(), GenTime(m_dropItem->startPos(), 25), m_dropItem->xml()); } m_dropItem = NULL; } @@ -393,6 +396,8 @@ void CustomTrackView::setCursorPos(int pos) { m_cursorPos = pos; m_cursorLine->setPos(pos, 0); + int frame = mapToScene(QPoint(pos, 0)).x() / m_scale; + m_document->renderer()->seek(GenTime(frame, 25)); } int CustomTrackView::cursorPos() diff --git a/src/customtrackview.h b/src/customtrackview.h index 9b06e1fd..8bc238b3 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -27,6 +27,7 @@ #include +#include "kdenlivedoc.h" #include "clipitem.h" class CustomTrackView : public QGraphicsView @@ -34,7 +35,7 @@ class CustomTrackView : public QGraphicsView Q_OBJECT public: - CustomTrackView(KUndoStack *commandStack, QGraphicsScene * projectscene, QWidget *parent=0); + CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent=0); virtual void mousePressEvent ( QMouseEvent * event ); virtual void mouseReleaseEvent ( QMouseEvent * event ); virtual void mouseMoveEvent ( QMouseEvent * event ); @@ -69,6 +70,7 @@ class CustomTrackView : public QGraphicsView int m_projectDuration; int m_cursorPos; ClipItem *m_dropItem; + KdenliveDoc *m_document; void addItem(QString producer, QPoint pos); QGraphicsLineItem *m_cursorLine; QPointF m_startPos; diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index a0f61f1e..05844d16 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -28,10 +28,8 @@ #include "kdenlivedoc.h" -KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL) +KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL), m_commandStack(new KUndoStack()) { - - m_commandStack = new KUndoStack(); if (!url.isEmpty()) { QString tmpFile; if(KIO::NetAccess::download(url.path(), tmpFile, parent)) @@ -109,6 +107,11 @@ void KdenliveDoc::setRenderer(Render *render) if (m_render) m_render->setSceneList(m_document); } +Render *KdenliveDoc::renderer() +{ + return m_render; +} + QString KdenliveDoc::producerName(int id) { QString result = "unnamed"; diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 7d7b6d11..0c7d93ea 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -53,6 +53,7 @@ class KdenliveDoc:public QObject { QString producerName(int id); void setProducerDuration(int id, int duration); int getProducerDuration(int id); + Render *renderer(); private: KUrl m_url; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0a42b1ed..95f0d704 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -213,6 +213,9 @@ void MainWindow::setupActions() KStandardAction::openNew(this, SLOT(newFile()), actionCollection()); + KStandardAction::preferences(this, SLOT(slotPreferences()), + actionCollection()); + /*KStandardAction::undo(this, SLOT(undo()), actionCollection()); diff --git a/src/monitor.cpp b/src/monitor.cpp index 29e04eb7..7d0a5938 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -188,13 +188,6 @@ void Monitor::refreshMonitor(bool visible) if (visible && render) render->askForRefresh(); } -void Monitor::slotOpen() -{ - if ( render == NULL ) return; - render->mltInsertClip(2, GenTime(1, 25), QString("")); - render->mltInsertClip(2, GenTime(0, 25), QString("")); -} - void Monitor::slotPlay() { if ( render == NULL ) return; diff --git a/src/monitor.h b/src/monitor.h index 904b79b1..bf20b664 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -56,7 +56,6 @@ class Monitor : public QWidget private slots: void slotPlay(); - void slotOpen(); void adjustRulerSize(int length); void seekCursor(int pos); void rendererStopped(int pos); diff --git a/src/projectitem.cpp b/src/projectitem.cpp index a2dd1724..53fde22a 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -42,7 +42,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, QDom { m_element = xml.cloneNode().toElement(); setSizeHint(0, QSize(65, 45)); - setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); + setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable); if (!m_element.isNull()) { m_element.setAttribute("id", clipId); QString cType = m_element.attribute("type", QString::null); @@ -63,7 +63,7 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, { m_element = xml.cloneNode().toElement(); setSizeHint(0, QSize(65, 45)); - setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); + setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable); if (!m_element.isNull()) { m_element.setAttribute("id", clipId); QString cType = m_element.attribute("type", QString::null); @@ -78,7 +78,7 @@ ProjectItem::ProjectItem(QTreeWidget * parent, const QStringList & strings, int : QTreeWidgetItem(parent, strings, QTreeWidgetItem::UserType), m_element(QDomElement()), m_clipType(UNKNOWN), m_clipId(clipId), m_isGroup(true), m_groupName(strings.at(1)) { setSizeHint(0, QSize(65, 45)); - setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); + setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable); setIcon(0, KIcon("folder")); } @@ -91,6 +91,11 @@ int ProjectItem::clipId() const return m_clipId; } +CLIPTYPE ProjectItem::clipType() const +{ + return m_clipType; +} + int ProjectItem::clipMaxDuration() const { return m_element.attribute("duration").toInt(); @@ -123,7 +128,7 @@ QDomElement ProjectItem::toXml() const const KUrl ProjectItem::clipUrl() const { if (m_clipType != COLOR && m_clipType != VIRTUAL && m_clipType != UNKNOWN) - return KUrl(m_element.attribute("resouce")); + return KUrl(m_element.attribute("resource")); else return KUrl(); } diff --git a/src/projectitem.h b/src/projectitem.h index 083db29a..95b4e14f 100644 --- a/src/projectitem.h +++ b/src/projectitem.h @@ -46,6 +46,7 @@ class ProjectItem : public QTreeWidgetItem const QString groupName() const; const KUrl clipUrl() const; int clipMaxDuration() const; + CLIPTYPE clipType() const; private: QDomElement m_element; diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 7fe59f7c..026e5b29 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -107,6 +107,7 @@ ProjectList::ProjectList(QWidget *parent) connect(listView, SIGNAL(requestMenu ( const QPoint &, QTreeWidgetItem * )), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *))); connect(listView, SIGNAL(addClip ()), this, SLOT(slotAddClip())); connect(listView, SIGNAL(addClip (QUrl, const QString &)), this, SLOT(slotAddClip(QUrl, const QString &))); + connect(listView, SIGNAL (itemChanged ( QTreeWidgetItem *, int )), this, SLOT(slotUpdateItemDescription(QTreeWidgetItem *, int ))); m_listViewDelegate = new ItemDelegate(listView); listView->setItemDelegate(m_listViewDelegate); @@ -131,6 +132,19 @@ void ProjectList::slotClipSelected() if (item && !item->isGroup()) emit clipSelected(item->toXml()); } +void ProjectList::slotUpdateItemDescription( QTreeWidgetItem *item, int column) +{ + if (column != 2) return; + ProjectItem *clip = (ProjectItem*) item; + CLIPTYPE type = clip->clipType(); + if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE || type == PLAYLIST) { + // Use Nepomuk system to store clip description + Nepomuk::Resource f( clip->clipUrl().path() ); + f.setDescription(item->text(2)); + kDebug()<<"NEPOMUK, SETTING CLIP: "<clipUrl().path()<<", TO TEXT: "<text(2); + } +} + void ProjectList::slotEditClip() { kDebug()<<"//////////////////////////////////////// DBL CLK"; diff --git a/src/projectlist.h b/src/projectlist.h index 86939085..9628b3e4 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -141,6 +141,8 @@ class ProjectList : public QWidget void slotEditClip(QTreeWidgetItem *, int); void slotContextMenu( const QPoint &pos, QTreeWidgetItem * ); void slotAddFolder(); + /** This is triggered when a clip description has been modified */ + void slotUpdateItemDescription(QTreeWidgetItem *item, int column); //void slotShowMenu(const QPoint &pos); diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index a8ebce7f..400e5a5e 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -39,6 +39,11 @@ ProjectListView::~ProjectListView() { } +void ProjectListView::editItem ( QTreeWidgetItem * item, int column ) +{ + kDebug()<<"//////////////// EDIT ITEM, COL: "<pos())) emit addClip(); + else if (columnAt(event->pos().x()) == 2) QTreeWidget::mouseDoubleClickEvent( event ); } // virtual diff --git a/src/projectlistview.h b/src/projectlistview.h index da5756a5..55dd920b 100644 --- a/src/projectlistview.h +++ b/src/projectlistview.h @@ -31,6 +31,7 @@ class ProjectListView : public QTreeWidget public: ProjectListView(QWidget *parent=0); virtual ~ProjectListView(); + void editItem ( QTreeWidgetItem * item, int column = 0 ); protected: virtual void contextMenuEvent ( QContextMenuEvent * event ); @@ -52,6 +53,7 @@ class ProjectListView : public QTreeWidget private slots: + signals: void requestMenu(const QPoint &, QTreeWidgetItem *); void addClip(); diff --git a/src/renderer.cpp b/src/renderer.cpp index f828dd63..aac9bad2 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -986,14 +986,19 @@ void Render::mltCheckLength() blackTrackPlaylist.remove_region( 0, blackDuration ); int i = 0; int dur = duration; - + QDomDocument doc; + QDomElement black = doc.createElement("producer"); + black.setAttribute("mlt_service", "colour"); + black.setAttribute("colour", "black"); + black.setAttribute("in", "0"); + black.setAttribute("out", "13999"); while (dur > 14000) { // - mltInsertClip(0, GenTime(i * 14000, m_fps), QString("")); + mltInsertClip(0, GenTime(i * 14000, m_fps), black); dur = dur - 14000; i++; } - - mltInsertClip(0, GenTime(), QString("")); + black.setAttribute("out", QString::number(dur)); + mltInsertClip(0, GenTime(), black); m_mltProducer->set("out", duration); emit durationChanged(); @@ -1001,7 +1006,7 @@ void Render::mltCheckLength() } -void Render::mltInsertClip(int track, GenTime position, QString resource) +void Render::mltInsertClip(int track, GenTime position, QDomElement element) { if (!m_mltProducer) { kDebug()<<"PLAYLIST NOT INITIALISED //////"; @@ -1015,6 +1020,10 @@ void Render::mltInsertClip(int track, GenTime position, QString resource) Mlt::Service service(parentProd.get_service()); Mlt::Tractor tractor(service); + QDomDocument doc; + doc.appendChild(doc.importNode(element, true)); + QString resource = doc.toString(); + kDebug()<<"/////// ADDING CLIP TMLNE: "<addWidget(m_ruler); m_scene = new QGraphicsScene(); - m_trackview = new CustomTrackView(m_doc->commandStack(), m_scene, this); + m_trackview = new CustomTrackView(doc, m_scene, this); m_trackview->scale(1, 1); m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop); //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red)); @@ -65,7 +65,7 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) setEditMode("move");*/ connect(view->horizontalSlider, SIGNAL(valueChanged ( int )), this, SLOT(slotChangeZoom( int ))); - connect(m_ruler, SIGNAL(cursorMoved ( int )), m_trackview, SLOT(setCursorPos( int ))); + connect(m_ruler, SIGNAL(cursorMoved ( int )), this, SLOT(setCursorPos( int ))); connect(m_trackview, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int ))); connect(m_trackview, SIGNAL(zoomIn ()), this, SLOT(slotZoomIn())); connect(m_trackview, SIGNAL(zoomOut ()), this, SLOT(slotZoomOut())); @@ -120,10 +120,15 @@ void TrackView::parseDocument(QDomDocument doc) //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height()); } +void TrackView::setCursorPos(int pos) +{ + m_trackview->setCursorPos(pos * m_scale); +} + void TrackView::slotCursorMoved(int pos, bool emitSignal) { kDebug()<<"///// CURSOR: "<slotNewValue(pos * FRAME_SIZE, emitSignal); //(int) m_trackview->mapToScene(QPoint(pos, 0)).x()); + m_ruler->slotNewValue(pos * FRAME_SIZE / m_scale, emitSignal); //(int) m_trackview->mapToScene(QPoint(pos, 0)).x()); //m_trackview->setCursorPos(pos); //m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer); } diff --git a/src/trackview.h b/src/trackview.h index 6c35a58e..a13b92ee 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -95,6 +95,7 @@ class TrackView : public QWidget void slotCursorMoved(int pos, bool slotCursorMoved = false); void slotZoomIn(); void slotZoomOut(); + void setCursorPos(int pos); signals: void mousePosition(int);