]> git.sesse.net Git - kdenlive/commitdiff
Improve editing with external program, add "reload clip" feature in project tree
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 20 Feb 2009 00:05:24 +0000 (00:05 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 20 Feb 2009 00:05:24 +0000 (00:05 +0000)
svn path=/branches/KDE4/; revision=3066

src/kdenliveui.rc
src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h
src/renderer.cpp
src/renderer.h

index 123ccb20f4a52462af6e5f4aa30c7e3138ba5fb3..9f30d2a0f875a92d7f3645b82a53ab370bbc71fe 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="kdenlive" version="33">
+<gui name="kdenlive" version="35">
   <ToolBar name="extraToolBar" >
     <text>Extra Toolbar</text>
        <Action name="project_render" />
@@ -26,6 +26,7 @@
       <Menu name="generators" ><text>Generators</text>
       </Menu>
       <Separator />
+      <Action name="reload_clip" />
       <Action name="clip_properties" />       
       <Action name="edit_clip" />
       <Action name="delete_clip" />
index eda4249ab407d306d055bfe465b377989d0073e1..f0191d85fa8d79cbaac421e2f817be6d7a183dca 100644 (file)
@@ -569,9 +569,9 @@ void MainWindow::slotConnectMonitors() {
     m_projectList->setRenderer(m_projectMonitor->render);
     connect(m_projectList, SIGNAL(receivedClipDuration(const QString &, int)), this, SLOT(slotSetClipDuration(const QString &, int)));
     connect(m_projectList, SIGNAL(showClipProperties(DocClipBase *)), this, SLOT(slotShowClipProperties(DocClipBase *)));
-    connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &)));
+    connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, const QString &, bool)), m_projectMonitor->render, SLOT(getFileProperties(const QDomElement &, const QString &, bool)));
     connect(m_projectMonitor->render, SIGNAL(replyGetImage(const QString &, const QPixmap &)), m_projectList, SLOT(slotReplyGetImage(const QString &, const QPixmap &)));
-    connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &)));
+    connect(m_projectMonitor->render, SIGNAL(replyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)), m_projectList, SLOT(slotReplyGetFileProperties(const QString &, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool)));
 
     connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(const QString &)), m_projectList, SLOT(slotRemoveInvalidClip(const QString &)));
 
@@ -1020,16 +1020,25 @@ void MainWindow::setupActions() {
     collection->addAction("clip_properties", clipProperties);
     clipProperties->setData("clip_properties");
     connect(clipProperties , SIGNAL(triggered()), m_projectList, SLOT(slotEditClip()));
+    clipProperties->setEnabled(false);
 
     QAction *openClip = new KAction(KIcon("document-open"), i18n("Edit Clip"), this);
     collection->addAction("edit_clip", openClip);
     openClip->setData("edit_clip");
     connect(openClip , SIGNAL(triggered()), m_projectList, SLOT(slotOpenClip()));
+    openClip->setEnabled(false);
 
     QAction *deleteClip = new KAction(KIcon("edit-delete"), i18n("Delete Clip"), this);
     collection->addAction("delete_clip", deleteClip);
     deleteClip->setData("delete_clip");
     connect(deleteClip , SIGNAL(triggered()), m_projectList, SLOT(slotRemoveClip()));
+    deleteClip->setEnabled(false);
+
+    QAction *reloadClip = new KAction(KIcon("view-refresh"), i18n("Reload Clip"), this);
+    collection->addAction("reload_clip", reloadClip);
+    reloadClip->setData("reload_clip");
+    connect(reloadClip , SIGNAL(triggered()), m_projectList, SLOT(slotReloadClip()));
+    reloadClip->setEnabled(false);
 
     QMenu *addClips = new QMenu();
     addClips->addAction(addClip);
@@ -1038,6 +1047,7 @@ void MainWindow::setupActions() {
     addClips->addAction(addTitleClip);
     addClips->addAction(addFolderButton);
 
+    addClips->addAction(reloadClip);
     addClips->addAction(clipProperties);
     addClips->addAction(openClip);
     addClips->addAction(deleteClip);
index 7b2d8c6bc739f9037486ed6101f4e0f1d0b3d2e8..71dc6ede0d883a3e4922146d87b56f64a3f59bb7 100644 (file)
@@ -54,7 +54,7 @@
 #include "editfoldercommand.h"
 
 ProjectList::ProjectList(QWidget *parent)
-        : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL), m_selectedItem(NULL), m_infoQueue(QMap <QString, QDomElement> ()), m_thumbnailQueue(QList <QString> ()), m_refreshed(false), m_editAction(NULL), m_openAction(NULL), m_deleteAction(NULL) {
+        : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL), m_selectedItem(NULL), m_infoQueue(QMap <QString, QDomElement> ()), m_thumbnailQueue(QList <QString> ()), m_refreshed(false), m_editAction(NULL), m_openAction(NULL), m_deleteAction(NULL), m_reloadAction(NULL) {
 
     QWidget *vbox = new QWidget;
     listView = new ProjectListView(this);;
@@ -104,7 +104,6 @@ ProjectList::~ProjectList() {
 }
 
 void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction) {
-
     QList <QAction *> actions = addMenu->actions();
     for (int i = 0; i < actions.count(); i++) {
         if (actions.at(i)->data().toString() == "clip_properties") {
@@ -121,6 +120,10 @@ void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction) {
             m_openAction = actions.at(i);
             actions.removeAt(i);
             i--;
+        } else if (actions.at(i)->data().toString() == "reload_clip") {
+            m_reloadAction = actions.at(i);
+            actions.removeAt(i);
+            i--;
         }
     }
 
@@ -140,6 +143,7 @@ void ProjectList::setupGeneratorMenu(QMenu *addMenu) {
 
     m_menu->addMenu(addMenu);
     if (addMenu->isEmpty()) addMenu->setEnabled(false);
+    m_menu->addAction(m_reloadAction);
     m_menu->addAction(m_editAction);
     m_menu->addAction(m_openAction);
     m_menu->addAction(m_deleteAction);
@@ -177,6 +181,16 @@ void ProjectList::slotOpenClip() {
     }
 }
 
+void ProjectList::slotReloadClip() {
+    ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
+    if (item && !item->isGroup()) {
+        if (item->clipType() == IMAGE) {
+            item->referencedClip()->producer()->set("force_reload", 1);
+        }
+        emit getFileProperties(item->toXml(), item->clipId(), false);
+    }
+}
+
 void ProjectList::setRenderer(Render *projectRender) {
     m_render = projectRender;
     listView->setIconSize(QSize(40 * m_render->dar(), 40));
@@ -191,12 +205,20 @@ void ProjectList::slotClipSelected() {
         }
         m_editAction->setEnabled(true);
         m_deleteAction->setEnabled(true);
-        m_openAction->setEnabled(true);
+        m_reloadAction->setEnabled(true);
+        if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
+            m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
+            m_openAction->setEnabled(true);
+        } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
+            m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
+            m_openAction->setEnabled(true);
+        } else m_openAction->setEnabled(false);
     } else {
         emit clipSelected(NULL);
         m_editAction->setEnabled(false);
         m_deleteAction->setEnabled(false);
         m_openAction->setEnabled(false);
+        m_reloadAction->setEnabled(false);
     }
 }
 
@@ -280,7 +302,17 @@ void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) {
     }
     m_editAction->setEnabled(enable);
     m_deleteAction->setEnabled(enable);
-    m_openAction->setEnabled(enable);
+    m_reloadAction->setEnabled(enable);
+    if (enable) {
+        ProjectItem *clip = static_cast <ProjectItem*>(item);
+        if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
+            m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
+            m_openAction->setEnabled(true);
+        } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
+            m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
+            m_openAction->setEnabled(true);
+        } else m_openAction->setEnabled(false);
+    } else m_openAction->setEnabled(false);
     m_menu->popup(pos);
 }
 
@@ -311,6 +343,7 @@ void ProjectList::slotRemoveClip() {
         m_editAction->setEnabled(false);
         m_deleteAction->setEnabled(false);
         m_openAction->setEnabled(false);
+        m_reloadAction->setEnabled(false);
     }
 }
 
@@ -448,7 +481,7 @@ void ProjectList::slotProcessNextClipInQueue() {
         const QDomElement dom = i.value();
         const QString id = i.key();
         m_infoQueue.remove(i.key());
-        emit getFileProperties(dom, id);
+        emit getFileProperties(dom, id, true);
     }
     if (m_infoQueue.isEmpty()) listView->setEnabled(true);
 }
@@ -700,13 +733,13 @@ void ProjectList::slotRefreshClipThumbnail(ProjectItem *item, bool update) {
     }
 }
 
-void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
+void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace) {
     ProjectItem *item = getItemById(clipId);
     if (item && producer) {
         listView->blockSignals(true);
         item->setProperties(properties, metadata);
         Q_ASSERT_X(item->referencedClip(), "void ProjectList::slotReplyGetFileProperties", QString("Item with groupName %1 does not have a clip associated").arg(item->groupName()).toLatin1());
-        item->referencedClip()->setProducer(producer);
+        if (replace) item->referencedClip()->setProducer(producer);
         emit receivedClipDuration(clipId, item->clipMaxDuration());
         listView->blockSignals(false);
     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
@@ -749,13 +782,20 @@ ProjectItem *ProjectList::getFolderItemById(const QString &id) {
 }
 
 void ProjectList::slotSelectClip(const QString &ix) {
-    ProjectItem *p = getItemById(ix);
-    if (p) {
-        listView->setCurrentItem(p);
-        listView->scrollToItem(p);
+    ProjectItem *clip = getItemById(ix);
+    if (clip) {
+        listView->setCurrentItem(clip);
+        listView->scrollToItem(clip);
         m_editAction->setEnabled(true);
         m_deleteAction->setEnabled(true);
-        m_openAction->setEnabled(true);
+        m_reloadAction->setEnabled(true);
+        if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
+            m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
+            m_openAction->setEnabled(true);
+        } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
+            m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
+            m_openAction->setEnabled(true);
+        } else m_openAction->setEnabled(false);
     }
 }
 
index f52d250126fc38047cb10bc56b114aa3cf05b978..dc04ec60f3c481c824784ec76cdf56d4da6deb07 100644 (file)
@@ -129,7 +129,7 @@ public:
 public slots:
     void setDocument(KdenliveDoc *doc);
     void slotReplyGetImage(const QString &clipId, const QPixmap &pix);
-    void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
+    void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace);
     void slotAddClip(DocClipBase *clip, bool getProperties);
     void slotDeleteClip(const QString &clipId);
     void slotUpdateClip(const QString &id);
@@ -143,6 +143,7 @@ public slots:
     void slotResetProjectList();
     void slotOpenClip();
     void slotEditClip();
+    void slotReloadClip();
 
 private:
     ProjectListView *listView;
@@ -159,6 +160,7 @@ private:
     QAction *m_editAction;
     QAction *m_deleteAction;
     QAction *m_openAction;
+    QAction *m_reloadAction;
     KdenliveDoc *m_doc;
     ProjectItem *m_selectedItem;
     bool m_refreshed;
@@ -188,7 +190,7 @@ private slots:
 
 signals:
     void clipSelected(DocClipBase *);
-    void getFileProperties(const QDomElement&, const QString &);
+    void getFileProperties(const QDomElement&, const QString &, bool);
     void receivedClipDuration(const QString &, int);
     void showClipProperties(DocClipBase *);
     void projectModified();
index 5c3d5e427332d777dc203715be603582e82c2b1b..5ecd2df16d5e652cca7daddecbda2ce5529198c1 100644 (file)
@@ -114,7 +114,7 @@ void Render::buildConsumer() {
     m_mltConsumer->set("resize", 1);
     m_mltConsumer->set("window_id", m_winid);
     m_mltConsumer->set("terminate_on_pause", 1);
-    m_mltConsumer->set("window_background", (int) KdenliveSettings::window_background().rgb ());
+    m_mltConsumer->set("window_background", (int) KdenliveSettings::window_background().rgb());
 
     m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
     m_mltConsumer->set("rescale", "nearest");
@@ -461,7 +461,7 @@ void Render::slotSplitView(bool doit) {
     }
 }
 
-void Render::getFileProperties(const QDomElement &xml, const QString &clipId) {
+void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bool replaceProducer) {
     int height = 50;
     int width = (int)(height  * m_mltProfile->dar());
     QMap < QString, QString > filePropertyMap;
@@ -470,7 +470,7 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId) {
     KUrl url = KUrl(xml.attribute("resource", QString::null));
     Mlt::Producer *producer = NULL;
     if (xml.attribute("type").toInt() == TEXT && !QFile::exists(url.path())) {
-        emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap);
+        emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer);
         return;
     }
     if (xml.attribute("type").toInt() == COLOR) {
@@ -684,7 +684,7 @@ void Render::getFileProperties(const QDomElement &xml, const QString &clipId) {
             metadataPropertyMap[ name.section(".", 0, -2)] = value;
     }
 
-    emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap);
+    emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer);
     kDebug() << "REquested fuile info for: " << url.path();
     if (frame) delete frame;
     //if (producer) delete producer;
index fd83a14e9f799e38ea9ec308f45c27b8f1c715e2..d10b5d3445217c005c426b19b9ff2da8bb750e69 100644 (file)
@@ -237,7 +237,7 @@ private slots:  // Private slots
 
 signals:   // Signals
     /** emitted when the renderer recieves a reply to a getFileProperties request. */
-    void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &);
+    void replyGetFileProperties(const QString &clipId, Mlt::Producer*, const QMap < QString, QString > &, const QMap < QString, QString > &, bool);
 
     /** emitted when the renderer recieves a reply to a getImage request. */
     void replyGetImage(const QString &, const QPixmap &);
@@ -272,7 +272,7 @@ public slots:  // Public slots
     /** Wraps the VEML command of the same name. Requests the file properties
     for the specified url from the renderer. Upon return, the result will be emitted
     via replyGetFileProperties(). */
-    void getFileProperties(const QDomElement &xml, const QString &clipId);
+    void getFileProperties(const QDomElement &xml, const QString &clipId, bool replaceProducer = true);
 
     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
     static char *decodedString(QString str);