Fix importing library clip hanging with relative paths, improve error reporting

Patch by Harald Albrecht
REVIEW: 129011
parent 8d0de8c9
......@@ -2546,6 +2546,7 @@ void Bin::slotExpandUrl(ItemInfo info, QUrl url, QUndoCommand *command)
return;
}
QMap <QString, QString> idMap;
QDir mltRoot(doc.documentElement().attribute(QStringLiteral("root")));
for (int i = 0; i < producers.count(); i++) {
QDomElement prod = producers.at(i).toElement();
QString originalId = prod.attribute(QStringLiteral("id"));
......@@ -2561,6 +2562,24 @@ void Bin::slotExpandUrl(ItemInfo info, QUrl url, QUndoCommand *command)
// Add clip
QDomElement clone = prod.cloneNode(true).toElement();
EffectsList::setProperty(clone, QStringLiteral("kdenlive:folderid"), folderId);
QString mltService = EffectsList::property(clone, QStringLiteral("mlt_service"));
// Do we have a producer that uses a resource property that contains a path?
if (mltService == QLatin1String("avformat-novalidate") // av clip
|| mltService == QLatin1String("avformat") // av clip
|| mltService == QLatin1String("pixbuf") // image (sequence) clip
|| mltService == QLatin1String("qimage") // image (sequence) clip
|| mltService == QLatin1String("xml") // MLT playlist clip, someone likes recursion :)
) {
// Make sure to correctly resolve relative resource paths based on
// the playlist's root, not on this project's root
QString resource = EffectsList::property(clone, QStringLiteral("resource"));
if (QFileInfo(resource).isRelative()) {
QFileInfo rootedResource(mltRoot, resource);
qDebug() << "fixed resource path for producer, newId:" << newId << "resource:" << rootedResource.absoluteFilePath();
EffectsList::setProperty(clone, QStringLiteral("resource"), rootedResource.absoluteFilePath());
}
}
ClipCreationDialog::createClipsCommand(this, clone, newId, command);
}
pCore->projectManager()->currentTimeline()->importPlaylist(info, idMap, doc, command);
......
......@@ -213,15 +213,15 @@ LibraryWidget::LibraryWidget(ProjectManager *manager, QWidget *parent) : QWidget
void LibraryWidget::setupActions(QList <QAction *>list)
{
QList <QAction *> menuList;
m_addAction = new QAction(KoIconUtils::themedIcon(QStringLiteral("list-add")), i18n("Add Clip to Project"), this);
m_addAction = new QAction(KoIconUtils::themedIcon(QStringLiteral("kdenlive-add-clip")), i18n("Add Clip to Project"), this);
connect(m_addAction, SIGNAL(triggered(bool)), this, SLOT(slotAddToProject()));
m_addAction->setData(1);
m_deleteAction = new QAction(KoIconUtils::themedIcon(QStringLiteral("edit-delete")), i18n("Delete Clip from Library"), this);
connect(m_deleteAction, SIGNAL(triggered(bool)), this, SLOT(slotDeleteFromLibrary()));
m_deleteAction->setData(1);
QAction *addFolder = new QAction(KoIconUtils::themedIcon(QStringLiteral("folder-new")), i18n("Create Folder"), this);
QAction *addFolder = new QAction(KoIconUtils::themedIcon(QStringLiteral("folder-new")), i18n("Create Library Folder"), this);
connect(addFolder, SIGNAL(triggered(bool)), this, SLOT(slotAddFolder()));
QAction *renameFolder = new QAction(QIcon(), i18n("Rename Item"), this);
QAction *renameFolder = new QAction(QIcon(), i18n("Rename Library Clip"), this);
renameFolder->setData(1);
connect(renameFolder, SIGNAL(triggered(bool)), this, SLOT(slotRenameItem()));
menuList << m_addAction << addFolder << renameFolder << m_deleteAction;
......
......@@ -1415,7 +1415,7 @@ void MainWindow::setupActions()
addAction(QStringLiteral("save_selection"), i18n("Save Selection"), pCore->projectManager(), SLOT(slotSaveSelection()), KoIconUtils::themedIcon(QStringLiteral("document-save")));
QAction *sentToLibrary = addAction(QStringLiteral("send_library"), i18n("Add Selection to Library"), pCore->library(), SLOT(slotAddToLibrary()), KoIconUtils::themedIcon(QStringLiteral("bookmark-new")));
QAction *sentToLibrary = addAction(QStringLiteral("send_library"), i18n("Add Timeline Selection to Library"), pCore->library(), SLOT(slotAddToLibrary()), KoIconUtils::themedIcon(QStringLiteral("bookmark-new")));
pCore->library()->setupActions(QList <QAction *>() << sentToLibrary);
KStandardAction::showMenubar(this, SLOT(showMenuBar(bool)), actionCollection());
......
......@@ -4808,7 +4808,7 @@ void CustomTrackView::addClip(const QString &clipId, ItemInfo info, EffectsList
{
ProjectClip *binClip = m_document->getBinClip(clipId);
if (!binClip) {
emit displayMessage(i18n("Cannot insert clip..."), ErrorMessage);
emit displayMessage(i18n("Cannot insert clip."), ErrorMessage);
return;
}
if (!binClip->isReady()) {
......@@ -8305,6 +8305,7 @@ void CustomTrackView::importPlaylist(ItemInfo info, QMap <QString, QString> idMa
}
if (lowerTrack <1) {
qWarning()<<" / / / TOO many tracks in playlist for our timeline ";
emit displayMessage(i18n("Not enough timeline tracks to expand selected playlist clip, need %1 tracks.", playlistTracks), MltError);
delete command;
return;
}
......@@ -8317,6 +8318,7 @@ void CustomTrackView::importPlaylist(ItemInfo info, QMap <QString, QString> idMa
for (int i = 0; i < selection.count(); ++i) {
if (selection.at(i)->type() == TransitionWidget || selection.at(i)->type() == AVWidget) {
qWarning()<<" / / /There are clips in timeline preventing expand actions";
emit displayMessage(i18n("No free track space above and below the selected playlist clip, thus the clip cannot be expanded."), MltError);
delete command;
return;
}
......
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