X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.cpp;h=a8f76657421fdd781cef7ed2b89e7ebc7eda29f9;hb=5273a3b061a94e37ec3289211f67006731c93cab;hp=db61f5042a4065f375d08f8e9b692e8aa1a859d3;hpb=edf2e497b4361db1bce089b0ef58dd566bf1d997;p=kdenlive diff --git a/src/projectlist.cpp b/src/projectlist.cpp index db61f504..a8f76657 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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,24 @@ void ProjectList::slotOpenClip() } } -void ProjectList::slotReloadClip() +void ProjectList::cleanup() { - QList selected = m_listView->selectedItems(); + m_listView->clearSelection(); + QTreeWidgetItemIterator it(m_listView); + ProjectItem *item; + while (*it) { + item = static_cast (*it); + if (item->numReferences() == 0) item->setSelected(true); + it++; + } + slotRemoveClip(); +} + +void ProjectList::slotReloadClip(const QString &id) +{ + 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 +240,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 +263,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 +277,7 @@ void ProjectList::slotClipSelected() m_deleteAction->setEnabled(false); m_openAction->setEnabled(false); m_reloadAction->setEnabled(false); + m_transcodeAction->setEnabled(false); } } @@ -264,7 +291,7 @@ void ProjectList::slotUpdateClipProperties(const QString &id, 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")); @@ -307,10 +333,12 @@ void ProjectList::slotItemEdited(QTreeWidgetItem *item, int column) oldprops["description"] = clip->referencedClip()->getProperty("description"); newprops["description"] = item->text(2); - if (clip->clipType() == TEXT && !clip->referencedClip()->getProperty("xmltemplate").isEmpty()) { + if (clip->clipType() == TEXT) { // This is a text template clip, update the image - oldprops.insert("xmldata", clip->referencedClip()->getProperty("xmldata")); - newprops.insert("xmldata", generateTemplateXml(clip->referencedClip()->getProperty("xmltemplate"), item->text(2)).toString()); + /*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); @@ -351,6 +379,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()) { @@ -367,7 +396,7 @@ void ProjectList::slotContextMenu(const QPoint &pos, QTreeWidgetItem *item) void ProjectList::slotRemoveClip() { if (!m_listView->currentItem()) return; - QList ids; + QStringList ids; QMap folderids; QList selected = m_listView->selectedItems(); ProjectItem *item; @@ -379,7 +408,7 @@ void ProjectList::slotRemoveClip() if (KMessageBox::questionYesNo(this, i18np("Delete clip %2?
This will also remove the clip in timeline", "Delete clip %2?
This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return; } else if (item->isGroup() && item->childCount() > 0) { int children = item->childCount(); - if (KMessageBox::questionYesNo(this, i18n("Delete folder %2?
This will also remove the %1 clips in that folder", children, item->names().at(1)), i18n("Delete Folder")) != KMessageBox::Yes) return; + if (KMessageBox::questionYesNo(this, i18np("Delete folder %2?
This will also remove the clip in that folder", "Delete folder %2?
This will also remove the %1 clips in that folder", children, item->names().at(1)), i18n("Delete Folder")) != KMessageBox::Yes) return; for (int i = 0; i < children; ++i) { ProjectItem *child = static_cast (item->child(i)); ids << child->clipId(); @@ -393,6 +422,7 @@ void ProjectList::slotRemoveClip() m_deleteAction->setEnabled(false); m_openAction->setEnabled(false); m_reloadAction->setEnabled(false); + m_transcodeAction->setEnabled(false); } } @@ -410,7 +440,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(); } @@ -438,7 +472,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); @@ -454,7 +487,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); } @@ -478,8 +511,16 @@ void ProjectList::deleteProjectFolder(QMap map) void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) { - if (getProperties) m_listView->setEnabled(false); - m_listView->blockSignals(true); + m_listView->setEnabled(false); + if (getProperties) { + m_listView->blockSignals(true); + m_refreshed = false; + // remove file_hash so that we load all properties for the clip + QDomElement e = clip->toXML().cloneNode().toElement(); + e.removeAttribute("file_hash"); + m_infoQueue.insert(clip->getId(), e); + //m_render->getFileProperties(clip->toXML(), clip->getId(), true); + } const QString parent = clip->getProperty("groupid"); kDebug() << "Adding clip with groupid: " << parent; ProjectItem *item = NULL; @@ -498,8 +539,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()); @@ -507,7 +555,8 @@ 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->isEnabled()) m_listView->blockSignals(false); + if (getProperties && !m_queueTimer.isActive()) m_queueTimer.start(); } void ProjectList::slotResetProjectList() @@ -521,26 +570,27 @@ void ProjectList::slotResetProjectList() void ProjectList::requestClipInfo(const QDomElement xml, const QString id) { - kDebug() << " PRG LIST REQUEST CLP INFO: " << id; + m_refreshed = false; m_infoQueue.insert(id, xml); - m_listView->setEnabled(false); - if (m_infoQueue.count() == 1) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue())); + //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.isActive()) m_queueTimer.start(); } void ProjectList::slotUpdateClip(const QString &id) @@ -553,56 +603,50 @@ 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 (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(); + //qApp->processEvents(); } ++it; } - QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue())); + qApp->processEvents(); + if (!m_queueTimer.isActive()) m_queueTimer.start(); + + if (m_listView->isEnabled()) 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) { @@ -612,8 +656,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 { @@ -622,15 +665,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()) { @@ -639,17 +683,17 @@ void ProjectList::slotRemoveInvalidClip(const QString &id, bool replace) if (KMessageBox::questionYesNo(this, i18n("Clip %1
is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes) replace = true; } } - QList ids; + QStringList ids; 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; dia_ui.setupUi(dia); @@ -659,8 +703,7 @@ void ProjectList::slotAddColorClip() 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; } @@ -668,13 +711,14 @@ void ProjectList::slotAddColorClip() 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; } @@ -688,12 +732,14 @@ void ProjectList::slotAddTitleClip() void ProjectList::slotAddTitleTemplateClip() { QStringList groupInfo = getGroup(); - if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + if (!m_commandStack) { + kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; + } // Get the list of existing templates QStringList filter; filter << "*.kdenlivetitle"; - const QString path = m_doc->projectFolder().path() + "/titles/"; + const QString path = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "titles/"; QStringList templateFiles = QDir(path).entryList(filter, QDir::Files); QDialog *dia = new QDialog(this); @@ -706,17 +752,12 @@ void ProjectList::slotAddTitleTemplateClip() //warning: setting base directory doesn't work?? KUrl startDir(path); dia_ui.template_list->fileDialog()->setUrl(startDir); - dia_ui.description->setHidden(true); + dia_ui.text_box->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)); - } + // Create a cloned template clip + m_doc->slotCreateTextTemplateClip(groupInfo.at(0), groupInfo.at(1), KUrl(textTemplate)); } delete dia; } @@ -742,10 +783,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()) { @@ -758,14 +805,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() @@ -788,7 +831,10 @@ void ProjectList::slotCheckForEmptyQueue() if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) { m_refreshed = true; emit loadingIsOver(); - } else QTimer::singleShot(500, this, SLOT(slotCheckForEmptyQueue())); + emit displayMessage(QString(), DefaultMessage); + m_listView->blockSignals(false); + m_listView->setEnabled(true); + } else if (!m_refreshed) QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue())); } void ProjectList::reloadClipThumbnails() @@ -803,18 +849,26 @@ 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()) { + slotCheckForEmptyQueue(); + return; + } + if (!m_infoQueue.isEmpty()) { + //QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail())); return; } slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false); + if (m_thumbnailQueue.count() > 1) { + emit displayMessage(i18n("Loading clips (%1)", m_thumbnailQueue.count()), InformationMessage); + qApp->processEvents(); + } } void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update) @@ -827,20 +881,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 = QPixmap::fromImage(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); + if (m_listView->isEnabled()) 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())); } } @@ -853,7 +912,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce 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, replace); emit receivedClipDuration(clipId); - if (replace) { + if (m_listView->isEnabled() && replace) { // update clip in clip monitor emit clipSelected(NULL); emit clipSelected(item->referencedClip()); @@ -863,20 +922,23 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce emit receivedClipDuration(clipId); delete producer; }*/ - m_listView->blockSignals(false); + if (m_listView->isEnabled()) 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); - m_listView->blockSignals(false); + if (m_listView->isEnabled()) m_listView->blockSignals(false); } } @@ -915,6 +977,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); @@ -940,30 +1003,10 @@ void ProjectList::regenerateTemplate(const QString &id) void ProjectList::regenerateTemplate(ProjectItem *clip) { - // Generate image for template clip - const QString comment = clip->referencedClip()->getProperty("description"); - const QString path = clip->referencedClip()->getProperty("xmltemplate"); - 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; + //TODO: remove this unused method, only force_reload is necessary clip->referencedClip()->producer()->set("force_reload", 1); } -void ProjectList::regenerateTemplateImage(ProjectItem *clip) -{ - // 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;