m_listView->header()->restoreState(state);
}
+void ProjectList::updateProjectFormat(Timecode t)
+{
+ m_timecode = t;
+}
+
void ProjectList::slotEditClip()
{
QList<QTreeWidgetItem *> list = m_listView->selectedItems();
commonproperties.insert("video_index", "-");
commonproperties.insert("audio_index", "-");
+ bool allowDurationChange = true;
+ int commonDuration = -1;
ProjectItem *item;
for (int i = 0; i < list.count(); i++) {
item = NULL;
// check properties
DocClipBase *clip = item->referencedClip();
if (clipList.contains(clip)) continue;
+ if (clip->clipType() != COLOR && clip->clipType() != IMAGE && clip->clipType() != TEXT) {
+ allowDurationChange = false;
+ }
+ if (allowDurationChange && commonDuration != 0) {
+ if (commonDuration == -1) {
+ commonDuration = clip->duration().frames(m_fps);
+ } else if (commonDuration != clip->duration().frames(m_fps)) {
+ commonDuration = 0;
+ }
+ }
clipList.append(clip);
QMap <QString, QString> clipprops = clip->properties();
QMapIterator<QString, QString> p(commonproperties);
}
}
}
+ if (allowDurationChange) commonproperties.insert("out", QString::number(commonDuration));
QMapIterator<QString, QString> p(commonproperties);
while (p.hasNext()) {
p.next();
it2++;
}
- m_doc->deleteProjectClip(ids);
+ emit deleteProjectClips(ids, QMap <QString, QString>());
for (int i = 0; i < urls.count(); i++) {
KIO::NetAccess::del(KUrl(urls.at(i)), this);
}
if (clip == NULL) kDebug() << "-----------ERROR";
SubProjectItem *sub = static_cast <SubProjectItem*>(m_listView->currentItem());
emit clipSelected(clip->referencedClip(), sub->zone());
+ m_transcodeAction->setEnabled(false);
return;
}
clip = static_cast <ProjectItem*>(m_listView->currentItem());
- emit clipSelected(clip->referencedClip());
+ if (clip) emit clipSelected(clip->referencedClip());
m_editAction->setEnabled(true);
m_deleteAction->setEnabled(true);
m_reloadAction->setEnabled(true);
m_transcodeAction->setEnabled(true);
- if (clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
+ if (clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
m_openAction->setEnabled(true);
- } else if (clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
+ } else if (clip && clip->clipType() == AUDIO && !KdenliveSettings::defaultaudioapp().isEmpty()) {
m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
m_openAction->setEnabled(true);
} else m_openAction->setEnabled(false);
+ // Display relevant transcoding actions only
+ adjustTranscodeActions(clip);
}
} else {
emit clipSelected(NULL);
}
}
+void ProjectList::adjustTranscodeActions(ProjectItem *clip) const
+{
+ if (clip == NULL || clip->type() != PROJECTCLIPTYPE || clip->clipType() == COLOR || clip->clipType() == TEXT || clip->clipType() == PLAYLIST) {
+ m_transcodeAction->setEnabled(false);
+ return;
+ }
+ m_transcodeAction->setEnabled(true);
+ QList<QAction *> transcodeActions = m_transcodeAction->actions();
+ QStringList data;
+ QString condition;
+ for (int i = 0; i < transcodeActions.count(); i++) {
+ data = transcodeActions.at(i)->data().toStringList();
+ if (data.count() > 2) {
+ condition = data.at(2);
+ if (condition.startsWith("vcodec")) transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
+ else if (condition.startsWith("acodec")) transcodeActions.at(i)->setEnabled(clip->referencedClip()->hasVideoCodec(condition.section("=", 1, 1)));
+ }
+ }
+
+}
+
void ProjectList::slotPauseMonitor()
{
if (m_render) m_render->pause();
ProjectItem *clip = NULL;
if (m_listView->currentItem()->type() == PROJECTSUBCLIPTYPE) {
clip = static_cast <ProjectItem*>(item->parent());
- } else if (m_listView->currentItem()->type() == PROJECTCLIPTYPE) clip = static_cast <ProjectItem*>(item);
+ m_transcodeAction->setEnabled(false);
+ } else if (m_listView->currentItem()->type() == PROJECTCLIPTYPE) {
+ clip = static_cast <ProjectItem*>(item);
+ // Display relevant transcoding actions only
+ adjustTranscodeActions(clip);
+ } else m_transcodeAction->setEnabled(false);
if (clip && clip->clipType() == IMAGE && !KdenliveSettings::defaultimageapp().isEmpty()) {
m_openAction->setIcon(KIcon(KdenliveSettings::defaultimageapp()));
m_openAction->setEnabled(true);
m_openAction->setIcon(KIcon(KdenliveSettings::defaultaudioapp()));
m_openAction->setEnabled(true);
} else m_openAction->setEnabled(false);
+
} else m_openAction->setEnabled(false);
m_menu->popup(pos);
}
folderids[folder->groupName()] = folder->clipId();
int children = folder->childCount();
- if (children > 0 && KMessageBox::questionYesNo(this, i18np("Delete folder <b>%2</b>?<br>This will also remove the clip in that folder", "Delete folder <b>%2</b>?<br>This will also remove the %1 clips in that folder", children, folder->text(1)), i18n("Delete Folder")) != KMessageBox::Yes) return;
+ if (children > 0 && KMessageBox::questionYesNo(this, i18np("Delete folder <b>%2</b>?<br />This will also remove the clip in that folder", "Delete folder <b>%2</b>?<br />This will also remove the %1 clips in that folder", children, folder->text(1)), i18n("Delete Folder")) != KMessageBox::Yes) return;
for (int i = 0; i < children; ++i) {
ProjectItem *child = static_cast <ProjectItem *>(folder->child(i));
ids << child->clipId();
ProjectItem *item = static_cast <ProjectItem *>(selected.at(i));
ids << item->clipId();
if (item->numReferences() > 0) {
- if (KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b>?<br>This will also remove the clip in timeline", "Delete clip <b>%2</b>?<br>This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
+ if (KMessageBox::questionYesNo(this, i18np("Delete clip <b>%2</b>?<br />This will also remove the clip in timeline", "Delete clip <b>%2</b>?<br />This will also remove its %1 clips in timeline", item->numReferences(), item->names().at(1)), i18n("Delete Clip")) != KMessageBox::Yes) return;
}
}
}
if (delCommand->childCount() == 0) delete delCommand;
else m_commandStack->push(delCommand);
- if (!ids.isEmpty()) m_doc->deleteProjectClip(ids);
- if (!folderids.isEmpty()) deleteProjectFolder(folderids);
+ emit deleteProjectClips(ids, folderids);
+}
+
+void ProjectList::updateButtons() const
+{
if (m_listView->topLevelItemCount() == 0) {
- m_editAction->setEnabled(false);
m_deleteAction->setEnabled(false);
- m_openAction->setEnabled(false);
- m_reloadAction->setEnabled(false);
- m_transcodeAction->setEnabled(false);
+ } else {
+ m_deleteAction->setEnabled(true);
+ if (!m_listView->currentItem()) m_listView->setCurrentItem(m_listView->topLevelItem(0));
+ QTreeWidgetItem *item = m_listView->currentItem();
+ if (item && item->type() == PROJECTCLIPTYPE) {
+ m_editAction->setEnabled(true);
+ m_openAction->setEnabled(true);
+ m_reloadAction->setEnabled(true);
+ m_transcodeAction->setEnabled(true);
+ return;
+ }
}
+
+ m_editAction->setEnabled(false);
+ m_openAction->setEnabled(false);
+ m_reloadAction->setEnabled(false);
+ m_transcodeAction->setEnabled(false);
}
void ProjectList::selectItemById(const QString &clipId)
return;
}
m_listView->blockSignals(true);
+ QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
+ if (!newSelectedItem) newSelectedItem = m_listView->itemBelow(item);
delete item;
m_doc->clipManager()->deleteClip(clipId);
m_listView->blockSignals(false);
- slotClipSelected();
+ if (newSelectedItem) m_listView->setCurrentItem(newSelectedItem);
+ else updateButtons();
}
FolderProjectItem *item = getFolderItemById(clipId);
if (item) {
m_doc->clipManager()->deleteFolder(clipId);
+ QTreeWidgetItem *newSelectedItem = m_listView->itemAbove(item);
+ if (!newSelectedItem) newSelectedItem = m_listView->itemBelow(item);
delete item;
+ if (newSelectedItem) m_listView->setCurrentItem(newSelectedItem);
+ else updateButtons();
}
} else {
if (edit) {
m_doc->clipManager()->addFolder(clipId, foldername);
m_listView->blockSignals(false);
}
+ updateButtons();
}
m_doc->setModified(true);
}
QDomElement e = clip->toXML().cloneNode().toElement();
e.removeAttribute("file_hash");
m_infoQueue.insert(clip->getId(), e);
+ clip->askForAudioThumbs();
//m_render->getFileProperties(clip->toXML(), clip->getId(), true);
}
const QString parent = clip->getProperty("groupid");
if (getProperties == false && !clip->getClipHash().isEmpty()) {
QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + ".png";
if (QFile::exists(cachedPixmap)) {
- item->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap));
+ QPixmap pix(cachedPixmap);
+ if (pix.isNull()) KIO::NetAccess::del(KUrl(cachedPixmap), this);
+ item->setData(0, Qt::DecorationRole, pix);
}
}
#ifdef NEPOMUK
if (!clip->getClipHash().isEmpty()) {
QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + '#' + QString::number(cuts.at(i).zone.x()) + ".png";
if (QFile::exists(cachedPixmap)) {
- sub->setData(0, Qt::DecorationRole, QPixmap(cachedPixmap));
+ QPixmap pix(cachedPixmap);
+ if (pix.isNull()) KIO::NetAccess::del(KUrl(cachedPixmap), this);
+ sub->setData(0, Qt::DecorationRole, pix);
}
}
}
}
-
- if (getProperties && m_listView->isEnabled()) m_listView->blockSignals(false);
+ if (m_listView->isEnabled()) {
+ updateButtons();
+ if (getProperties) m_listView->blockSignals(false);
+ }
if (getProperties && !m_queueTimer.isActive()) m_queueTimer.start();
}
{
ProjectItem *item = getItemById(id);
m_listView->blockSignals(true);
- if (item) item->setData(1, UsageRole, QString::number(item->numReferences()));
+ if (item) item->setData(0, UsageRole, QString::number(item->numReferences()));
m_listView->blockSignals(false);
}
if (item->referencedClip()->producer() == NULL) {
if (clip->isPlaceHolder() == false) {
requestClipInfo(clip->toXML(), clip->getId());
- } else item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ } else if (!clip->isPlaceHolder()) item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
} else {
if (item->data(0, Qt::DecorationRole).isNull()) {
requestClipThumbnail(clip->getId());
item->changeDuration(item->referencedClip()->producer()->get_playtime());
}
}
- item->setData(1, UsageRole, QString::number(item->numReferences()));
+ item->setData(0, UsageRole, QString::number(item->numReferences()));
}
//qApp->processEvents();
++it;
QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
if (item) {
const QString path = item->referencedClip()->fileURL().path();
+ if (item->referencedClip()->isPlaceHolder()) replace = false;
if (!path.isEmpty()) {
- if (replace) KMessageBox::sorry(this, i18n("Clip <b>%1</b><br>is invalid, will be removed from project.", path));
+ if (replace) KMessageBox::sorry(this, i18n("Clip <b>%1</b><br />is invalid, will be removed from project.", path));
else {
- if (KMessageBox::questionYesNo(this, i18n("Clip <b>%1</b><br>is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes) replace = true;
+ if (KMessageBox::questionYesNo(this, i18n("Clip <b>%1</b><br />is missing or invalid. Remove it from project?", path), i18n("Invalid clip")) == KMessageBox::Yes) replace = true;
}
}
QStringList ids;
ids << id;
- if (replace) m_doc->deleteProjectClip(ids);
+ if (replace) emit deleteProjectClips(ids, QMap <QString, QString>());
}
}
QDialog *dia = new QDialog(this);
Ui::ColorClip_UI dia_ui;
dia_ui.setupUi(dia);
+ dia->setWindowTitle(i18n("Color Clip"));
dia_ui.clip_name->setText(i18n("Color Clip"));
- dia_ui.clip_duration->setText(KdenliveSettings::color_duration());
+ dia_ui.clip_duration->setInputMask(m_timecode.inputMask());
+ dia_ui.clip_duration->setText(m_timecode.reformatSeparators(KdenliveSettings::color_duration()));
if (dia->exec() == QDialog::Accepted) {
QString color = dia_ui.clip_color->color().name();
color = color.replace(0, 1, "0x") + "ff";
emit displayMessage(QString(), -1);
m_listView->blockSignals(false);
m_listView->setEnabled(true);
+ updateButtons();
} else if (!m_refreshed) QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
}
void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace)
{
+ QString toReload;
ProjectItem *item = getItemById(clipId);
if (item && producer) {
m_listView->blockSignals(true);
item->setProperties(properties, metadata);
+ if (item->referencedClip()->isPlaceHolder() && producer->is_valid()) {
+ item->referencedClip()->setValid();
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
+ toReload = clipId;
+ }
//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);
+ item->referencedClip()->askForAudioThumbs();
if (!replace && item->data(0, Qt::DecorationRole).isNull()) {
requestClipThumbnail(clipId);
}
m_listView->setCurrentItem(item);
emit clipSelected(item->referencedClip());
}
+ if (!toReload.isEmpty()) emit clipNeedsReload(toReload, true);
QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
}