From f12ae5f3dcb20734eb005ab3ad032b6aa996ff56 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 18 Jan 2011 21:47:15 +0000 Subject: [PATCH] Continued work on proxy editing svn path=/trunk/kdenlive/; revision=5333 --- src/kdenlivesettingsdialog.cpp | 1 + src/mainwindow.cpp | 2 +- src/projectlist.cpp | 45 +++++++++++++++++++++++++++++++--- src/projectlist.h | 2 ++ src/renderer.h | 5 +++- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/kdenlivesettingsdialog.cpp b/src/kdenlivesettingsdialog.cpp index dcf15cf8..b6eb1efd 100644 --- a/src/kdenlivesettingsdialog.cpp +++ b/src/kdenlivesettingsdialog.cpp @@ -616,6 +616,7 @@ void KdenliveSettingsDialog::updateSettings() } if (m_configProject.kcfg_enableproxy->isChecked() != KdenliveSettings::enableproxy()) { + KdenliveSettings::setEnableproxy(m_configProject.kcfg_enableproxy->isChecked()); emit updateProxySettings(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9b2be9c8..34ecc812 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4141,7 +4141,7 @@ void MainWindow::slotUpdateProxySettings() if (m_renderWidget) m_renderWidget->updateProxyConfig(); if (KdenliveSettings::enableproxy()) KStandardDirs::makeDir(m_activeDocument->projectFolder().path(KUrl::AddTrailingSlash) + "proxy/"); - //TODO: update proxy in project tree + m_projectList->updateProxyConfig(); } #include "mainwindow.moc" diff --git a/src/projectlist.cpp b/src/projectlist.cpp index b2837a20..bf883501 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -1020,6 +1020,7 @@ void ProjectList::slotGotProxy(const QString id, bool success) item->setProxyStatus(2); QDomElement e = item->referencedClip()->toXML().cloneNode().toElement(); e.removeAttribute("file_hash"); + e.setAttribute("replace", 1); m_infoQueue.insert(id, e); if (!m_queueTimer.isActive()) slotProcessNextClipInQueue(); } @@ -1054,10 +1055,16 @@ void ProjectList::slotProcessNextClipInQueue() QMap::const_iterator j = m_infoQueue.constBegin(); if (j != m_infoQueue.constEnd()) { - const QDomElement dom = j.value(); + QDomElement dom = j.value(); const QString id = j.key(); m_infoQueue.remove(j.key()); - emit getFileProperties(dom, id, m_listView->iconSize().height(), false); + bool replace; + if (dom.hasAttribute("replace")) { + dom.removeAttribute("replace"); + replace = true; + } + else replace = false; + emit getFileProperties(dom, id, m_listView->iconSize().height(), replace); } if (!m_infoQueue.isEmpty()) m_queueTimer.start(); } @@ -1515,6 +1522,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled); toReload = clipId; } + if (item->referencedClip()->getProperty("proxy").isEmpty()) item->setProxyStatus(0); item->referencedClip()->setProducer(producer, replace); item->referencedClip()->askForAudioThumbs(); if (!replace && item->data(0, Qt::DecorationRole).isNull()) @@ -1938,7 +1946,6 @@ QMap ProjectList::getProxies() QTreeWidgetItemIterator it(m_listView); while (*it) { if ((*it)->type() != PROJECTCLIPTYPE) { - // subitem ++it; continue; } @@ -1952,4 +1959,36 @@ QMap ProjectList::getProxies() return list; } +void ProjectList::updateProxyConfig() +{ + ProjectItem *item; + QTreeWidgetItemIterator it(m_listView); + while (*it) { + if ((*it)->type() != PROJECTCLIPTYPE) { + ++it; + continue; + } + item = static_cast(*it); + if (item && item->referencedClip() != NULL) { + if (KdenliveSettings::enableproxy()) { + DocClipBase *clip = item->referencedClip(); + connect(clip, SIGNAL(proxyReady(const QString, bool)), this, SLOT(slotGotProxy(const QString, bool))); + item->setProxyStatus(1); + clip->generateProxy(m_doc->projectFolder()); + } + else if (!item->referencedClip()->getProperty("proxy").isEmpty()) { + // remove proxy + item->referencedClip()->clearProperty("proxy"); + QDomElement e = item->toXml().cloneNode().toElement(); + e.removeAttribute("file_hash"); + e.setAttribute("replace", 1); + m_infoQueue.insert(item->clipId(), e); + } + } + ++it; + } + if (!m_infoQueue.isEmpty() && !m_queueTimer.isActive()) m_queueTimer.start(); + +} + #include "projectlist.moc" diff --git a/src/projectlist.h b/src/projectlist.h index 186ce3a2..42d56d6c 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -189,6 +189,8 @@ public: static QString getExtensions(); /** @brief Returns a list of urls containing original and proxy urls. */ QMap getProxies(); + /** @brief Enable / disable proxies. */ + void updateProxyConfig(); public slots: void setDocument(KdenliveDoc *doc); diff --git a/src/renderer.h b/src/renderer.h index 11d2d3e8..b53e2721 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -373,7 +373,10 @@ public slots: bool isValid(KUrl url); /** @brief Requests the file properties for the specified URL. - * + @param xml The xml parameters for the clip + @param clipId The clip Id string + @param imageHeight The height (in pixels) of the returned thumbnail (height of a treewidgetitem in projectlist) + @param replaceProducer If true, the MLT producer will be recreated * Upon return, the result will be emitted via replyGetFileProperties(). * Wraps the VEML command of the same name. */ void getFileProperties(const QDomElement xml, const QString &clipId, int imageHeight, bool replaceProducer = true); -- 2.39.2