Commit 0301efd8 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix various bin thumbnail refresh issues

parent d40f4321
......@@ -2266,3 +2266,10 @@ void Bin::slotQueryRemoval(const QString &id, QUrl url)
delete m_invalidClipDialog;
m_invalidClipDialog = NULL;
}
void Bin::slotRefreshClipThumbnail(const QString &id)
{
ProjectClip *clip = m_rootFolder->clip(id);
if (!clip) return;
clip->reloadProducer(true);
}
......@@ -485,6 +485,8 @@ public slots:
void slotRemoveInvalidClip(const QString &id, bool replace);
/** @brief Create a folder when opening a document */
void slotLoadFolders(QMap<QString,QString> foldersData);
/** @brief Reload clip thumbnail - when frame for thumbnail changed */
void slotRefreshClipThumbnail(const QString &id);
void slotDeleteClip();
void slotRefreshClipProperties();
void slotItemDoubleClicked(const QModelIndex &ix, const QPoint pos);
......
......@@ -102,9 +102,9 @@ QString ProjectClip::getToolTip() const
return url().toLocalFile();
}
QString ProjectClip::getXmlProperty(const QDomElement &producer, const QString &propertyName)
QString ProjectClip::getXmlProperty(const QDomElement &producer, const QString &propertyName, const QString &defaultValue)
{
QString value;
QString value = defaultValue;
QDomNodeList props = producer.elementsByTagName("property");
for (int i = 0; i < props.count(); ++i) {
if (props.at(i).toElement().attribute("name") == propertyName) {
......@@ -428,8 +428,12 @@ const QString ProjectClip::getFileHash() const
fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
break;
case Text:
fileData = m_controller ? m_controller->property("xmldata").toUtf8() : name().toUtf8();
fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
break;
case Color:
return QString();
fileData = m_controller ? m_controller->property("resource").toUtf8() : name().toUtf8();
fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
break;
default:
QFile file(m_controller ? m_controller->clipUrl().toLocalFile() : m_temporaryUrl.toLocalFile());
......@@ -502,10 +506,7 @@ void ProjectClip::setProperties(QMap <QString, QString> properties, bool refresh
}
else if (properties.contains("resource")) {
// Clip resource changed, update thumbnail
if (m_type == Color) {
//reloadProducer(true);
}
else {
if (m_type != Color) {
reloadProducer();
}
refreshProducer = true;
......@@ -527,7 +528,8 @@ void ProjectClip::setProperties(QMap <QString, QString> properties, bool refresh
emit refreshPropertiesPanel();
}
if (refreshProducer) {
// producer has changed, refresh monitor
// producer has changed, refresh monitor and thumbnail
reloadProducer(true);
bin()->refreshClip(m_id);
}
}
......@@ -729,7 +731,8 @@ void ProjectClip::slotExtractSubImage(QList <int> frames)
QDir thumbFolder(bin()->projectFolder().path() + "/thumbs/");
for (int i = 0; i < frames.count(); i++) {
int pos = frames.at(i);
QImage img(thumbFolder.absolutePath() + '#' + QString::number(pos) + ".png");
QString path = thumbFolder.absoluteFilePath(hash() + "#" + QString::number(pos) + ".png");
QImage img(path);
if (!img.isNull()) {
ProjectSubClip *clip;
for (int i = 0; i < count(); ++i) {
......@@ -742,12 +745,13 @@ void ProjectClip::slotExtractSubImage(QList <int> frames)
}
int max = prod->get_out();
if (pos >= max) pos = max - 1;
if (pos < 0) pos = 0;
prod->seek(pos);
Mlt::Frame *frame = prod->get_frame();
if (frame && frame->is_valid()) {
QImage img = KThumb::getFrame(frame, fullWidth, 150);
if (!img.isNull()) {
img.save(thumbFolder.absoluteFilePath(hash() + '#' + QString::number(pos) + ".png"));
img.save(path);
ProjectSubClip *clip;
for (int i = 0; i < count(); ++i) {
clip = static_cast<ProjectSubClip *>(at(i));
......
......@@ -146,7 +146,7 @@ public:
void setProperties(QMap <QString, QString> properties, bool refreshPanel = false);
/** @brief Get an XML property from MLT produced xml. */
static QString getXmlProperty(const QDomElement &producer, const QString &propertyName);
static QString getXmlProperty(const QDomElement &producer, const QString &propertyName, const QString &defaultValue = QString());
virtual QString getToolTip() const;
......
......@@ -682,30 +682,20 @@ void MainWindow::slotUpdateClip(const QString &id, bool reload)
if (!clip) {
return;
}
//TODO
//if (clip->numReferences() > 0) {
pCore->projectManager()->currentTimeline()->projectView()->slotUpdateClip(id, reload);
//}
//TODO Should probably be removed
if (m_clipMonitor->activeClipId() == id) {
m_clipMonitor->openClip(pCore->binController()->getController(id));
}
//TODO
//clip->cleanupProducers();
pCore->projectManager()->currentTimeline()->projectView()->slotUpdateClip(id, reload);
}
void MainWindow::slotConnectMonitors()
{
//connect(m_projectList, SIGNAL(deleteProjectClips(QStringList,QMap<QString,QString>)), this, SLOT(slotDeleteProjectClips(QStringList,QMap<QString,QString>)));
connect(m_projectMonitor->render, SIGNAL(replyGetImage(QString,QImage)), pCore->bin(), SLOT(slotThumbnailReady(QString,QImage)));
connect(m_projectMonitor->render, SIGNAL(replyGetImage(QString,QImage,bool)), pCore->bin(), SLOT(slotThumbnailReady(QString,QImage,bool)));
connect(m_projectMonitor->render, SIGNAL(gotFileProperties(requestClipInfo,ClipController *)), pCore->bin(), SLOT(slotProducerReady(requestClipInfo,ClipController *)), Qt::DirectConnection);
connect(m_projectMonitor->render, SIGNAL(removeInvalidClip(QString,bool)), pCore->bin(), SLOT(slotRemoveInvalidClip(QString,bool)), Qt::DirectConnection);
//DirectConnection was necessary not to mess the analyze queue, but the monitor thread shouldn't show any UI widget (profile dialog), so adding an AutoConnection in between?
/*connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(QString,bool)), pCore->bin(), SLOT(slotRemoveInvalidProxy(QString,bool)));
connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(QString,bool)), pCore->bin(), SLOT(slotRefreshClipThumbnail(QString,bool)));*/
/*connect(m_projectMonitor->render, SIGNAL(removeInvalidProxy(QString,bool)), pCore->bin(), SLOT(slotRemoveInvalidProxy(QString,bool)));*/
connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(QString)), pCore->bin(), SLOT(slotRefreshClipThumbnail(QString)));
connect(m_projectMonitor, SIGNAL(requestFrameForAnalysis(bool)), this, SLOT(slotMonitorRequestRenderFrame(bool)));
//TODO
......
......@@ -701,9 +701,8 @@ void Monitor::slotSetThumbFrame()
if (m_controller == NULL) {
return;
}
//TODO
/*m_controller->setClipThumbFrame((uint) render->seekFramePosition());
emit refreshClipThumbnail(m_controller->clipId(), true);*/
m_controller->setProperty("kdenlive:thumbnailFrame", (int) render->seekFramePosition());
emit refreshClipThumbnail(m_controller->clipId());
}
void Monitor::slotExtractCurrentZone()
......
......@@ -244,7 +244,7 @@ public slots:
signals:
void renderPosition(int);
void durationChanged(int);
void refreshClipThumbnail(const QString &, bool);
void refreshClipThumbnail(const QString &);
void zoneUpdated(const QPoint&);
//void saveZone(Render *, const QPoint&, DocClipBase *);
/** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
......
......@@ -593,7 +593,7 @@ void Render::processFileProperties()
prod->attach(scaler);
prod->attach(converter);
}
int frameNumber = info.xml.attribute("thumbnail", "-1").toInt();
int frameNumber = ProjectClip::getXmlProperty(info.xml, "kdenlive:thumbnailFrame", "-1").toInt();
if (frameNumber > 0) prod->seek(frameNumber);
Mlt::Frame *frame = prod->get_frame();
if (frame && frame->is_valid()) {
......@@ -787,7 +787,7 @@ void Render::processFileProperties()
producer->set("templatetext", info.xml.attribute("templatetext").toUtf8().constData());
int fullWidth = (int)((double) info.imageHeight * m_qmlView->profile()->dar() + 0.5);
int frameNumber = info.xml.attribute("thumbnail", "-1").toInt();
int frameNumber = ProjectClip::getXmlProperty(info.xml, "kdenlive:thumbnailFrame", "-1").toInt();
if ((!info.replaceProducer && info.xml.hasAttribute("kdenlive:file_hash")) || proxyProducer) {
// Clip already has all properties
......@@ -969,7 +969,7 @@ void Render::processFileProperties()
}
} while (variance == -1);
delete frame;
if (frameNumber > -1) filePropertyMap["thumbnail"] = QString::number(frameNumber);
if (frameNumber > -1) filePropertyMap["thumbnailFrame"] = QString::number(frameNumber);
emit replyGetImage(info.clipId, img);
} else if (frame->get_int("test_audio") == 0) {
QIcon icon = QIcon::fromTheme("audio-x-generic");
......
......@@ -423,7 +423,7 @@ signals:
void gotFileProperties(requestClipInfo,ClipController *);
/** @brief The renderer received a reply to a getImage request. */
void replyGetImage(const QString &, const QImage &);
void replyGetImage(const QString &, const QImage &,bool fromFile = false);
/** @brief The renderer stopped, either playing or rendering. */
void stopped();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment