X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.cpp;h=52e4287113b88ce571d6eeb87d17693543c68600;hb=8c24ca01e2b4cda2f56db6561ba795b29ae531a8;hp=79612ca94d29ce93076a478e840a43e43f3f1caa;hpb=b78a8ab4e28c842e5758d4273f65760009a46f5a;p=kdenlive diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 79612ca9..52e42871 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -33,7 +33,7 @@ #include "projectlistview.h" #include "editclipcommand.h" #include "editfoldercommand.h" - +#include "ui_templateclip_ui.h" #include #include @@ -63,6 +63,7 @@ ProjectList::ProjectList(QWidget *parent) : m_deleteAction(NULL), m_openAction(NULL), m_reloadAction(NULL), + m_transcodeAction(NULL), m_selectedItem(NULL), m_refreshed(false), m_infoQueue(), @@ -87,6 +88,10 @@ ProjectList::ProjectList(QWidget *parent) : layout->addWidget(m_listView); setLayout(layout); + m_queueTimer.setInterval(100); + connect(&m_queueTimer, SIGNAL(timeout()), this, SLOT(slotProcessNextClipInQueue())); + m_queueTimer.setSingleShot(true); + connect(m_listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected())); @@ -94,12 +99,12 @@ ProjectList::ProjectList(QWidget *parent) : connect(m_listView, SIGNAL(pauseMonitor()), this, SLOT(slotPauseMonitor())); connect(m_listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *))); connect(m_listView, SIGNAL(addClip()), this, SLOT(slotAddClip())); - connect(m_listView, SIGNAL(addClip(const QList , const QString &)), this, SLOT(slotAddClip(const QList , const QString &))); + connect(m_listView, SIGNAL(addClip(const QList , const QString &, const QString &)), this, SLOT(slotAddClip(const QList , const QString &, const QString &))); connect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int))); connect(m_listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *))); - ItemDelegate *listViewDelegate = new ItemDelegate(m_listView); - m_listView->setItemDelegate(listViewDelegate); + m_listViewDelegate = new ItemDelegate(m_listView); + m_listView->setItemDelegate(m_listViewDelegate); if (KdenliveSettings::activate_nepomuk()) { Nepomuk::ResourceManager::instance()->init(); @@ -114,6 +119,9 @@ ProjectList::~ProjectList() { delete m_menu; delete m_toolbar; + m_listView->blockSignals(true); + m_listView->clear(); + delete m_listViewDelegate; } void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction) @@ -160,6 +168,7 @@ void ProjectList::setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu) if (addMenu->isEmpty()) addMenu->setEnabled(false); m_menu->addMenu(transcodeMenu); if (transcodeMenu->isEmpty()) transcodeMenu->setEnabled(false); + m_transcodeAction = transcodeMenu; m_menu->addAction(m_reloadAction); m_menu->addAction(m_editAction); m_menu->addAction(m_openAction); @@ -203,9 +212,11 @@ void ProjectList::slotOpenClip() } } -void ProjectList::slotReloadClip() +void ProjectList::slotReloadClip(const QString &id) { - QList selected = m_listView->selectedItems(); + QList selected; + if (id.isEmpty()) selected = m_listView->selectedItems(); + else selected.append(getItemById(id)); ProjectItem *item; for (int i = 0; i < selected.count(); i++) { item = static_cast (selected.at(i)); @@ -216,6 +227,7 @@ void ProjectList::slotReloadClip() if (!item->referencedClip()->getProperty("xmltemplate").isEmpty()) regenerateTemplate(item); } //requestClipInfo(item->toXml(), item->clipId(), true); + // Clear the file_hash value, which will cause a complete reload of the clip emit getFileProperties(item->toXml(), item->clipId(), true); } } @@ -238,6 +250,7 @@ void ProjectList::slotClipSelected() m_editAction->setEnabled(true); m_deleteAction->setEnabled(true); m_reloadAction->setEnabled(true); + m_transcodeAction->setEnabled(true); if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) { m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp())); m_openAction->setEnabled(true); @@ -251,6 +264,7 @@ void ProjectList::slotClipSelected() m_deleteAction->setEnabled(false); m_openAction->setEnabled(false); m_reloadAction->setEnabled(false); + m_transcodeAction->setEnabled(false); } } @@ -264,7 +278,10 @@ void ProjectList::slotUpdateClipProperties(const QString &id, QMap changeDuration(properties.value("out").toInt()); } } @@ -273,6 +290,7 @@ void ProjectList::slotUpdateClipProperties(ProjectItem *clip, QMap isGroup()) clip->setProperties(properties); + //if (properties.contains("xmldata")) regenerateTemplateImage(clip); if (properties.contains("name")) { m_listView->blockSignals(true); clip->setText(1, properties.value("name")); @@ -302,13 +320,18 @@ void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column) QMap newprops; oldprops["description"] = clip->referencedClip()->getProperty("description"); newprops["description"] = item->text(2); - slotUpdateClipProperties(clip, newprops); - EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false); - m_commandStack->push(command); - if (!clip->referencedClip()->getProperty("xmltemplate").isEmpty()) { + + if (clip->clipType() == TEXT && !clip->referencedClip()->getProperty("xmldata").isEmpty()) { // This is a text template clip, update the image - regenerateTemplate(clip); + /*oldprops.insert("xmldata", clip->referencedClip()->getProperty("xmldata")); + newprops.insert("xmldata", generateTemplateXml(clip->referencedClip()->getProperty("xmltemplate"), item->text(2)).toString());*/ + oldprops.insert("templatetext", clip->referencedClip()->getProperty("templatetext")); + newprops.insert("templatetext", item->text(2)); } + + slotUpdateClipProperties(clip->clipId(), newprops); + EditClipCommand *command = new EditClipCommand(this, clip->clipId(), oldprops, newprops, false); + m_commandStack->push(command); } } else if (column == 1) { if (clip->isGroup()) { @@ -344,6 +367,7 @@ void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) m_editAction->setEnabled(enable); m_deleteAction->setEnabled(enable); m_reloadAction->setEnabled(enable); + m_transcodeAction->setEnabled(enable); if (enable) { ProjectItem *clip = static_cast (item); if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) { @@ -386,6 +410,7 @@ void ProjectList::slotRemoveClip() m_deleteAction->setEnabled(false); m_openAction->setEnabled(false); m_reloadAction->setEnabled(false); + m_transcodeAction->setEnabled(false); } } @@ -403,7 +428,11 @@ void ProjectList::slotDeleteClip(const QString &clipId) kDebug() << "/// Cannot find clip to delete"; return; } + m_listView->blockSignals(true); delete item; + m_doc->clipManager()->deleteClip(clipId); + m_listView->blockSignals(false); + slotClipSelected(); } @@ -431,7 +460,6 @@ void ProjectList::slotAddFolder(const QString foldername, const QString &clipId, } else { if (edit) { ProjectItem *item = getFolderItemById(clipId); - QTreeWidgetItemIterator it(m_listView); if (item) { m_listView->blockSignals(true); item->setGroupName(foldername); @@ -447,7 +475,7 @@ void ProjectList::slotAddFolder(const QString foldername, const QString &clipId, QStringList text; text << QString() << foldername; m_listView->blockSignals(true); - (void) new ProjectItem(m_listView, text, clipId); + m_listView->setCurrentItem(new ProjectItem(m_listView, text, clipId)); m_doc->clipManager()->addFolder(clipId, foldername); m_listView->blockSignals(false); } @@ -471,8 +499,10 @@ void ProjectList::deleteProjectFolder(QMap map) void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) { - if (getProperties) m_listView->setEnabled(false); - m_listView->blockSignals(true); + if (getProperties) { + m_listView->setEnabled(false); + m_listView->blockSignals(true); + } const QString parent = clip->getProperty("groupid"); kDebug() << "Adding clip with groupid: " << parent; ProjectItem *item = NULL; @@ -491,8 +521,15 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) if (parentitem) item = new ProjectItem(parentitem, clip); } if (item == NULL) item = new ProjectItem(m_listView, clip); - KUrl url = clip->fileURL(); + + if (getProperties == false && !clip->getClipHash().isEmpty()) { + QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png"; + if (QFile::exists(cachedPixmap)) { + item->setIcon(0, QPixmap(cachedPixmap)); + } + } + if (!url.isEmpty() && KdenliveSettings::activate_nepomuk()) { // if file has Nepomuk comment, use it Nepomuk::Resource f(url.path()); @@ -500,7 +537,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) if (!annotation.isEmpty()) item->setText(2, annotation); item->setText(3, QString::number(f.rating())); } - m_listView->blockSignals(false); + if (getProperties) m_listView->blockSignals(false); } void ProjectList::slotResetProjectList() @@ -514,26 +551,27 @@ void ProjectList::slotResetProjectList() void ProjectList::requestClipInfo(const QDomElement xml, const QString id) { - kDebug() << " PRG LIST REQUEST CLP INFO: " << id; m_infoQueue.insert(id, xml); m_listView->setEnabled(false); - if (m_infoQueue.count() == 1) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue())); + if (!m_queueTimer.isActive()) m_queueTimer.start(); + //if (m_infoQueue.count() == 1 || ) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue())); } void ProjectList::slotProcessNextClipInQueue() { if (m_infoQueue.isEmpty()) { - m_listView->setEnabled(true); + slotProcessNextThumbnail(); return; } - QMap::const_iterator i = m_infoQueue.constBegin(); - if (i != m_infoQueue.constEnd()) { - const QDomElement dom = i.value(); - const QString id = i.key(); - m_infoQueue.remove(i.key()); + + QMap::const_iterator j = m_infoQueue.constBegin(); + if (j != m_infoQueue.constEnd()) { + const QDomElement dom = j.value(); + const QString id = j.key(); + m_infoQueue.remove(j.key()); emit getFileProperties(dom, id, false); } - if (m_infoQueue.isEmpty()) m_listView->setEnabled(true); + if (!m_infoQueue.isEmpty()) m_queueTimer.start(); } void ProjectList::slotUpdateClip(const QString &id) @@ -546,56 +584,58 @@ void ProjectList::slotUpdateClip(const QString &id) void ProjectList::updateAllClips() { + m_listView->setSortingEnabled(false); + QTreeWidgetItemIterator it(m_listView); + DocClipBase *clip; + ProjectItem *item; + m_listView->blockSignals(true); while (*it) { - ProjectItem *item = static_cast (*it); + item = static_cast (*it); if (!item->isGroup()) { + clip = item->referencedClip(); + /*if (clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) { + // regenerate text clip image if required + TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this); + QDomDocument doc; + doc.setContent(clip->getProperty("xmldata")); + dia_ui->setXml(doc); + QImage pix = dia_ui->renderedPixmap(); + pix.save(clip->fileURL().path()); + delete dia_ui; + }*/ if (item->referencedClip()->producer() == NULL) { - DocClipBase *clip = item->referencedClip(); - if (clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) { - // regenerate text clip image if required - TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this); - QDomDocument doc; - doc.setContent(clip->getProperty("xmldata")); - dia_ui->setXml(doc); - QImage pix = dia_ui->renderedPixmap(); - pix.save(clip->fileURL().path()); - delete dia_ui; - } - if (clip->isPlaceHolder() == false) requestClipInfo(clip->toXML(), clip->getId()); - else item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + if (clip->isPlaceHolder() == false) { + requestClipInfo(clip->toXML(), clip->getId()); + } else item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } else { - QString cachedPixmap = m_doc->projectFolder().path() + "/thumbs/" + item->getClipHash() + ".png"; - if (QFile::exists(cachedPixmap)) { - //kDebug()<<"// USING CACHED PIX: "<blockSignals(true); - item->setIcon(0, QPixmap(cachedPixmap)); - m_listView->blockSignals(false); - } else requestClipThumbnail(item->clipId()); - + if (item->icon(0).isNull()) { + requestClipThumbnail(clip->getId()); + } if (item->data(1, DurationRole).toString().isEmpty()) { - m_listView->blockSignals(true); item->changeDuration(item->referencedClip()->producer()->get_playtime()); - m_listView->blockSignals(false); } } - m_listView->blockSignals(true); item->setData(1, UsageRole, QString::number(item->numReferences())); - m_listView->blockSignals(false); qApp->processEvents(); } ++it; } - QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue())); + + m_listView->blockSignals(false); + m_listView->setSortingEnabled(true); + if (m_infoQueue.isEmpty()) slotProcessNextThumbnail(); } -void ProjectList::slotAddClip(const QList givenList, QString group) +void ProjectList::slotAddClip(const QList givenList, const QString &groupName, const QString &groupId) { - if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + if (!m_commandStack) { + kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + } KUrl::List list; if (givenList.isEmpty()) { // Build list of mime types - QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/mpeg" << "video/x-ms-wmv" << "audio/mpeg" << "audio/x-mp3" << "audio/x-wav" << "application/ogg" << "video/mp4" << "video/quicktime" << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr" << "video/mlt-playlist" << "audio/x-flac" << "audio/mp4" << "video/x-matroska" << "audio/x-matroska" << "video/ogg" << "audio/ogg"; + QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mlt-playlist" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "application/ogg" << "video/mp4" << "video/quicktime" << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr"; QString allExtensions; foreach(const QString& mimeType, mimeTypes) { @@ -605,8 +645,7 @@ void ProjectList::slotAddClip(const QList givenList, QString group) allExtensions.append(' '); } } - QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files"); - dialogFilter.append("\n*" + QLatin1Char('|') + i18n("All Files")); + const QString dialogFilter = allExtensions.simplified() + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files"); list = KFileDialog::getOpenUrls(KUrl("kfiledialog:///clipfolder"), dialogFilter, this); } else { @@ -615,15 +654,16 @@ void ProjectList::slotAddClip(const QList givenList, QString group) } if (list.isEmpty()) return; - if (group.isEmpty()) { + if (givenList.isEmpty()) { QStringList groupInfo = getGroup(); m_doc->slotAddClipList(list, groupInfo.at(0), groupInfo.at(1)); - } else m_doc->slotAddClipList(list, group, QString()); + } else m_doc->slotAddClipList(list, groupName, groupId); } void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace) { ProjectItem *item = getItemById(id); + QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue())); if (item) { const QString path = item->referencedClip()->fileURL().path(); if (!path.isEmpty()) { @@ -636,39 +676,38 @@ void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace) ids << id; if (replace) m_doc->deleteProjectClip(ids); } - if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue())); - else m_listView->setEnabled(true); } void ProjectList::slotAddColorClip() { - if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + if (!m_commandStack) { + kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + } QDialog *dia = new QDialog(this); - Ui::ColorClip_UI *dia_ui = new Ui::ColorClip_UI(); - dia_ui->setupUi(dia); - dia_ui->clip_name->setText(i18n("Color Clip")); - dia_ui->clip_duration->setText(KdenliveSettings::color_duration()); + Ui::ColorClip_UI dia_ui; + dia_ui.setupUi(dia); + dia_ui.clip_name->setText(i18n("Color Clip")); + dia_ui.clip_duration->setText(KdenliveSettings::color_duration()); if (dia->exec() == QDialog::Accepted) { - QString color = dia_ui->clip_color->color().name(); + QString color = dia_ui.clip_color->color().name(); color = color.replace(0, 1, "0x") + "ff"; QStringList groupInfo = getGroup(); - m_doc->clipManager()->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), groupInfo.at(0), groupInfo.at(1)); - m_doc->setModified(true); + m_doc->slotCreateColorClip(dia_ui.clip_name->text(), color, dia_ui.clip_duration->text(), groupInfo.at(0), groupInfo.at(1)); } - delete dia_ui; delete dia; } void ProjectList::slotAddSlideshowClip() { - if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + if (!m_commandStack) { + kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + } SlideshowClip *dia = new SlideshowClip(m_timecode, this); if (dia->exec() == QDialog::Accepted) { QStringList groupInfo = getGroup(); - m_doc->clipManager()->slotAddSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), groupInfo.at(0), groupInfo.at(1)); - m_doc->setModified(true); + m_doc->slotCreateSlideshowClipFile(dia->clipName(), dia->selectedPath(), dia->imageCount(), dia->clipDuration(), dia->loop(), dia->fade(), dia->lumaDuration(), dia->lumaFile(), dia->softness(), groupInfo.at(0), groupInfo.at(1)); } delete dia; } @@ -682,7 +721,39 @@ void ProjectList::slotAddTitleClip() void ProjectList::slotAddTitleTemplateClip() { QStringList groupInfo = getGroup(); - m_doc->slotCreateTextTemplateClip(groupInfo.at(0), groupInfo.at(1)); + if (!m_commandStack) { + kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + } + + // Get the list of existing templates + QStringList filter; + filter << "*.kdenlivetitle"; + const QString path = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "titles/"; + QStringList templateFiles = QDir(path).entryList(filter, QDir::Files); + + QDialog *dia = new QDialog(this); + Ui::TemplateClip_UI dia_ui; + dia_ui.setupUi(dia); + for (int i = 0; i < templateFiles.size(); ++i) { + dia_ui.template_list->comboBox()->addItem(templateFiles.at(i), path + templateFiles.at(i)); + } + dia_ui.template_list->fileDialog()->setFilter("*.kdenlivetitle"); + //warning: setting base directory doesn't work?? + KUrl startDir(path); + dia_ui.template_list->fileDialog()->setUrl(startDir); + dia_ui.description->setHidden(true); + if (dia->exec() == QDialog::Accepted) { + QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString(); + if (textTemplate.isEmpty()) textTemplate = dia_ui.template_list->comboBox()->currentText(); + if (dia_ui.normal_clip->isChecked()) { + // Create a normal title clip + m_doc->slotCreateTextClip(groupInfo.at(0), groupInfo.at(1), textTemplate); + } else { + // Create a cloned template clip + m_doc->slotCreateTextTemplateClip(groupInfo.at(0), groupInfo.at(1), KUrl(textTemplate)); + } + } + delete dia; } QStringList ProjectList::getGroup() const @@ -706,10 +777,16 @@ void ProjectList::setDocument(KdenliveDoc *doc) { m_listView->blockSignals(true); m_listView->clear(); + m_listView->setSortingEnabled(false); emit clipSelected(NULL); m_thumbnailQueue.clear(); m_infoQueue.clear(); m_refreshed = false; + m_fps = doc->fps(); + m_timecode = doc->timecode(); + m_commandStack = doc->commandStack(); + m_doc = doc; + QMap flist = doc->clipManager()->documentFolderList(); QMapIterator f(flist); while (f.hasNext()) { @@ -722,14 +799,10 @@ void ProjectList::setDocument(KdenliveDoc *doc) slotAddClip(list.at(i), false); } - m_fps = doc->fps(); - m_timecode = doc->timecode(); - m_commandStack = doc->commandStack(); - m_doc = doc; - QTreeWidgetItem *first = m_listView->topLevelItem(0); - if (first) m_listView->setCurrentItem(first); m_listView->blockSignals(false); m_toolbar->setEnabled(true); + connect(m_doc->clipManager(), SIGNAL(reloadClip(const QString &)), this, SLOT(slotReloadClip(const QString &))); + connect(m_doc->clipManager(), SIGNAL(checkAllClips()), this, SLOT(updateAllClips())); } QDomElement ProjectList::producersList() @@ -752,7 +825,7 @@ void ProjectList::slotCheckForEmptyQueue() if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) { m_refreshed = true; emit loadingIsOver(); - } else QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue())); + } else QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue())); } void ProjectList::reloadClipThumbnails() @@ -767,15 +840,20 @@ void ProjectList::reloadClipThumbnails() QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail())); } -void ProjectList::requestClipThumbnail(const QString &id) +void ProjectList::requestClipThumbnail(const QString id) { m_thumbnailQueue.append(id); - if (m_thumbnailQueue.count() == 1) QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail())); } void ProjectList::slotProcessNextThumbnail() { - if (m_thumbnailQueue.isEmpty()) { + if (m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) { + m_listView->setEnabled(true); + slotCheckForEmptyQueue(); + return; + } + if (!m_infoQueue.isEmpty()) { + //QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail())); return; } slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false); @@ -791,20 +869,25 @@ void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update) void ProjectList::slotRefreshClipThumbnail(ProjectItem *item, bool update) { if (item) { - if (!item->referencedClip()) return; - int height = 50; - int width = (int)(height * m_render->dar()); DocClipBase *clip = item->referencedClip(); - if (!clip) slotProcessNextThumbnail(); + if (!clip) { + slotProcessNextThumbnail(); + return; + } QPixmap pix; + int height = 50; + int width = (int)(height * m_render->dar()); if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(width, height)); + else if (clip->clipType() == IMAGE) pix = KThumb::getFrame(item->referencedClip()->producer(), 0, width, height); else pix = item->referencedClip()->thumbProducer()->extractImage(item->referencedClip()->getClipThumbFrame(), width, height); - m_listView->blockSignals(true); - item->setIcon(0, pix); - m_listView->blockSignals(false); - m_doc->cachePixmap(item->getClipHash(), pix); + if (!pix.isNull()) { + m_listView->blockSignals(true); + item->setIcon(0, pix); + m_listView->blockSignals(false); + m_doc->cachePixmap(item->getClipHash(), pix); + } if (update) emit projectModified(); - if (!m_thumbnailQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail())); + QTimer::singleShot(100, this, SLOT(slotProcessNextThumbnail())); } } @@ -828,15 +911,18 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce delete producer; }*/ m_listView->blockSignals(false); + if (item->icon(0).isNull()) { + requestClipThumbnail(clipId); + } } else kDebug() << "//////// COULD NOT FIND CLIP TO UPDATE PRPS..."; - if (!m_infoQueue.isEmpty()) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue())); - else m_listView->setEnabled(true); + + slotProcessNextClipInQueue(); } void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix) { ProjectItem *item = getItemById(clipId); - if (item) { + if (item && !pix.isNull()) { m_listView->blockSignals(true); item->setIcon(0, pix); m_doc->cachePixmap(item->getClipHash(), pix); @@ -879,6 +965,7 @@ void ProjectList::slotSelectClip(const QString &ix) m_editAction->setEnabled(true); m_deleteAction->setEnabled(true); m_reloadAction->setEnabled(true); + m_transcodeAction->setEnabled(true); if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) { m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp())); m_openAction->setEnabled(true); @@ -904,30 +991,53 @@ void ProjectList::regenerateTemplate(const QString &id) void ProjectList::regenerateTemplate(ProjectItem *clip) { + //TODO: remove this unused method, only force_reload is necessary // Generate image for template clip - const QString comment = clip->referencedClip()->getProperty("description"); - const QString path = clip->referencedClip()->getProperty("xmltemplate"); + /*const QString comment = clip->referencedClip()->getProperty("description"); + const QString path = clip->referencedClip()->getProperty("resource"); + QDomDocument doc = generateTemplateXml(path, comment); + TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this); + dia_ui->setXml(doc); + QImage pix = dia_ui->renderedPixmap(); + pix.save(clip->clipUrl().path()); + delete dia_ui;*/ + clip->referencedClip()->producer()->set("force_reload", 1); +} + +void ProjectList::regenerateTemplateImage(ProjectItem *clip) +{ + //TODO: remove this unused method + // Generate image for template clip + /*TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this); + QDomDocument doc; + doc.setContent(clip->referencedClip()->getProperty("xmldata")); + dia_ui->setXml(doc); + QImage pix = dia_ui->renderedPixmap(); + pix.save(clip->clipUrl().path()); + delete dia_ui;*/ +} + +QDomDocument ProjectList::generateTemplateXml(QString path, const QString &replaceString) +{ QDomDocument doc; QFile file(path); - if (!file.open(QIODevice::ReadOnly)) - return; + if (!file.open(QIODevice::ReadOnly)) { + kWarning() << "ERROR, CANNOT READ: " << path; + return doc; + } if (!doc.setContent(&file)) { + kWarning() << "ERROR, CANNOT READ: " << path; file.close(); - return; + return doc; } file.close(); QDomNodeList texts = doc.elementsByTagName("content"); for (int i = 0; i < texts.count(); i++) { QString data = texts.item(i).firstChild().nodeValue(); - data.replace("%s", comment); + data.replace("%s", replaceString); texts.item(i).firstChild().setNodeValue(data); } - TitleWidget *dia_ui = new TitleWidget(KUrl(), QString(), m_render, this); - dia_ui->setXml(doc); - QImage pix = dia_ui->renderedPixmap(); - pix.save(clip->clipUrl().path()); - delete dia_ui; - clip->referencedClip()->producer()->set("force_reload", 1); + return doc; } #include "projectlist.moc"