X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.cpp;h=d60e3081db98577306709b5a425629c4e1a0344e;hb=6a00e6e1cea6551345d64e8c74b4939f767e4a61;hp=ff9d17481a57d5a2fd7b68fa4352ec4082a9bae2;hpb=b4a0ec0fffc1cbbf21d2ea9fc418885e3b34bce8;p=kdenlive diff --git a/src/projectlist.cpp b/src/projectlist.cpp index ff9d1748..d60e3081 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -58,6 +58,8 @@ #include #include #include +#include +#include #ifdef USE_NEPOMUK #include @@ -77,6 +79,17 @@ #include #include #include +#include + + +MyMessageWidget::MyMessageWidget(QWidget *parent) : KMessageWidget(parent) {} +MyMessageWidget::MyMessageWidget(const QString &text, QWidget *parent) : KMessageWidget(text, parent) {} + + +bool MyMessageWidget::event(QEvent* ev) { + if (ev->type() == QEvent::Hide || ev->type() == QEvent::Close) emit messageClosing(); + return KMessageWidget::event(ev); +} SmallInfoLabel::SmallInfoLabel(QWidget *parent) : QPushButton(parent) { @@ -278,10 +291,11 @@ ProjectList::ProjectList(QWidget *parent) : m_listView = new ProjectListView(this); layout->addWidget(m_listView); -#if KDE_IS_VERSION(4,7,0) - m_infoMessage = new KMessageWidget; +#if KDE_IS_VERSION(4,7,0) + m_infoMessage = new MyMessageWidget; layout->addWidget(m_infoMessage); m_infoMessage->setCloseButtonVisible(true); + connect(m_infoMessage, SIGNAL(messageClosing()), this, SLOT(slotResetInfoMessage())); //m_infoMessage->setWordWrap(true); m_infoMessage->hide(); m_logAction = new QAction(i18n("Show Log"), this); @@ -518,7 +532,7 @@ void ProjectList::editClipSelection(QList list) if (clip->getProperty("transparency").isEmpty() || clip->getProperty("transparency").toInt() == 0) { if (transparency == "-") { // first non transparent image - transparency = "0"; + transparency = '0'; } else if (transparency == "1") { // we have transparent and non transparent clips @@ -528,7 +542,7 @@ void ProjectList::editClipSelection(QList list) else { if (transparency == "-") { // first transparent image - transparency = "1"; + transparency = '1'; } else if (transparency == "0") { // we have transparent and non transparent clips @@ -733,6 +747,10 @@ void ProjectList::slotMissingClip(const QString &id) if (item) { item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); int height = m_listView->iconSize().height(); + if (m_render == NULL) { + kDebug() << "********* ERROR, NULL RENDR"; + return; + } int width = (int)(height * m_render->dar()); QPixmap pixmap = qVariantValue(item->data(0, Qt::DecorationRole)); if (pixmap.isNull()) { @@ -746,10 +764,6 @@ void ProjectList::slotMissingClip(const QString &id) item->setData(0, Qt::DecorationRole, pixmap); if (item->referencedClip()) { item->referencedClip()->setPlaceHolder(true); - if (m_render == NULL) { - kDebug() << "********* ERROR, NULL RENDR"; - return; - } Mlt::Producer *newProd = m_render->invalidProducer(id); if (item->referencedClip()->getProducer()) { Mlt::Properties props(newProd->get_properties()); @@ -932,7 +946,7 @@ void ProjectList::slotUpdateClipProperties(const QString &id, QMap setEnabled(false); const QString parent = clip->getProperty("groupid"); + QString groupName = clip->getProperty("groupname"); ProjectItem *item = NULL; monitorItemEditing(false); if (!parent.isEmpty()) { FolderProjectItem *parentitem = getFolderItemById(parent); if (!parentitem) { QStringList text; - QString groupName = clip->getProperty("groupname"); //kDebug() << "Adding clip to new group: " << groupName; if (groupName.isEmpty()) groupName = i18n("Folder"); text << groupName; @@ -1307,6 +1321,10 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) //item->setFlags(Qt::ItemIsSelectable); m_listView->processLayout(); QDomElement e = clip->toXML().cloneNode().toElement(); + if (!groupName.isEmpty()) { + e.setAttribute("groupId", parent); + e.setAttribute("group", groupName); + } e.removeAttribute("file_hash"); resetThumbsProducer(clip); m_render->getFileProperties(e, clip->getId(), m_listView->iconSize().height(), true); @@ -1465,7 +1483,7 @@ void ProjectList::getCachedThumbnail(SubProjectItem *item) DocClipBase *clip = parentItem->referencedClip(); if (!clip) return; int pos = item->zone().x(); - QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + "#" + QString::number(pos) + ".png"; + QString cachedPixmap = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "thumbs/" + clip->getClipHash() + '#' + QString::number(pos) + ".png"; if (QFile::exists(cachedPixmap)) { QPixmap pix(cachedPixmap); if (pix.isNull()) { @@ -1598,10 +1616,16 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, QStr QString ProjectList::getExtensions() { // Build list of mime types - QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain" - << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime" << "video/webm" - << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "audio/x-aiff" << "audio/aiff" << "application/ogg" << "application/mxf" << "application/x-shockwave-flash" - << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr"; + QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain"; + + // Video mimes + mimeTypes << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime" << "video/webm" << "video/3gpp"; + + // Audio mimes + mimeTypes << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "audio/x-aiff" << "audio/aiff" << "application/ogg" << "application/mxf" << "application/x-shockwave-flash" << "audio/ac3"; + + // Image mimes + mimeTypes << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr"; QString allExtensions; foreach(const QString & mimeType, mimeTypes) { @@ -1642,7 +1666,7 @@ void ProjectList::slotAddClip(const QList givenList, const QString &group l->addWidget(c); l->addStretch(5); f->setLayout(l); - KFileDialog *d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), f); + QPointer d = new KFileDialog(KUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), f); d->setOperationMode(KFileDialog::Opening); d->setMode(KFile::Files); if (d->exec() == QDialog::Accepted) { @@ -1713,9 +1737,15 @@ void ProjectList::slotAddClip(const QList givenList, const QString &group if (givenList.isEmpty() && !list.isEmpty()) { QStringList groupInfo = getGroup(); - m_doc->slotAddClipList(list, groupInfo.at(0), groupInfo.at(1)); + QMap data; + data.insert("group", groupInfo.at(0)); + data.insert("groupId", groupInfo.at(1)); + m_doc->slotAddClipList(list, data); } else if (!list.isEmpty()) { - m_doc->slotAddClipList(list, groupName, groupId); + QMap data; + data.insert("group", groupName); + data.insert("groupId", groupId); + m_doc->slotAddClipList(list, data); } if (!foldersList.isEmpty()) { @@ -1732,8 +1762,12 @@ void ProjectList::slotAddClip(const QList givenList, const QString &group folder = getFolderItemByName(folderName); } } - if (folder) - m_doc->slotAddClipList(urls, folder->groupName(), folder->clipId()); + if (folder) { + QMap data; + data.insert("group", folder->groupName()); + data.insert("groupId", folder->clipId()); + m_doc->slotAddClipList(urls, data); + } else m_doc->slotAddClipList(urls); } } @@ -1808,7 +1842,7 @@ void ProjectList::slotAddColorClip() if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK"; - QDialog *dia = new QDialog(this); + QPointer dia = new QDialog(this); Ui::ColorClip_UI dia_ui; dia_ui.setupUi(dia); dia->setWindowTitle(i18n("Color Clip")); @@ -1879,7 +1913,7 @@ void ProjectList::slotAddTitleTemplateClip() const QString path = m_doc->projectFolder().path(KUrl::AddTrailingSlash) + "titles/"; QStringList templateFiles = QDir(path).entryList(filter, QDir::Files); - QDialog *dia = new QDialog(this); + QPointer dia = new QDialog(this); Ui::TemplateClip_UI dia_ui; dia_ui.setupUi(dia); for (int i = 0; i < templateFiles.size(); ++i) @@ -2077,12 +2111,12 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update) int dwidth = (int)(height * m_render->dar() + 0.5); if (clip->clipType() == AUDIO) pix = KIcon("audio-x-generic").pixmap(QSize(dwidth, height)); - else if (clip->clipType() == IMAGE) + else if (clip->clipType() == IMAGE) { img = KThumb::getFrame(item->referencedClip()->getProducer(), 0, swidth, dwidth, height); + } else { img = item->referencedClip()->extractImage(frame, dwidth, height); } - if (!pix.isNull() || !img.isNull()) { monitorItemEditing(false); if (!img.isNull()) { @@ -2145,7 +2179,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce if (clip->getProperty("proxy").isEmpty()) { KUrl proxyPath = m_doc->projectFolder(); proxyPath.addPath("proxy/"); - proxyPath.addPath(clip->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension"))); + proxyPath.addPath(clip->getClipHash() + '.' + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension"))); QMap newProps; // insert required duration for proxy if (t != IMAGE) newProps.insert("proxy_out", clip->producerProperty("out")); @@ -2690,8 +2724,12 @@ void ProjectList::slotCreateProxy(const QString id) slotGotProxy(path); return; } - - ProxyJob *job = new ProxyJob(item->clipType(), id, QStringList() << path << item->clipUrl().path() << item->referencedClip()->producerProperty("_exif_orientation") << m_doc->getDocumentProperty("proxyparams").simplified() << QString::number(m_render->frameRenderWidth()) << QString::number(m_render->renderHeight())); + QString sourcePath = item->clipUrl().path(); + if (item->clipType() == PLAYLIST) { + // Special case: playlists use the special 'consumer' producer to support resizing + sourcePath.prepend("consumer:"); + } + ProxyJob *job = new ProxyJob(item->clipType(), id, QStringList() << path << sourcePath << item->referencedClip()->producerProperty("_exif_orientation") << m_doc->getDocumentProperty("proxyparams").simplified() << QString::number(m_render->frameRenderWidth()) << QString::number(m_render->renderHeight())); if (job->isExclusive() && hasPendingJob(item, job->jobType)) { delete job; return; @@ -2708,7 +2746,7 @@ void ProjectList::slotCutClipJob(const QString &id, QPoint zone) if (!item|| item->referencedClip()->isPlaceHolder()) return; QString source = item->clipUrl().path(); QString ext = source.section('.', -1); - QString dest = source.section('.', 0, -2) + "_" + QString::number(zone.x()) + "." + ext; + QString dest = source.section('.', 0, -2) + '_' + QString::number(zone.x()) + '.' + ext; double clipFps = item->referencedClip()->getProperty("fps").toDouble(); if (clipFps == 0) clipFps = m_fps; @@ -2722,11 +2760,11 @@ void ProjectList::slotCutClipJob(const QString &id, QPoint zone) QString timeIn = Timecode::getStringTimecode(in, clipFps, true); QString timeOut = Timecode::getStringTimecode(duration, clipFps, true); - QDialog *d = new QDialog(this); + QPointer d = new QDialog(this); Ui::CutJobDialog_UI ui; ui.setupUi(d); ui.extra_params->setVisible(false); - ui.add_clip->setChecked(KdenliveSettings::add_clip_cut()); + ui.add_clip->setChecked(KdenliveSettings::add_new_clip()); ui.file_url->fileDialog()->setOperationMode(KFileDialog::Saving); ui.extra_params->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5); ui.file_url->setUrl(KUrl(dest)); @@ -2759,11 +2797,11 @@ void ProjectList::slotCutClipJob(const QString &id, QPoint zone) } } QString extraParams = ui.extra_params->toPlainText().simplified(); - KdenliveSettings::setAdd_clip_cut(ui.add_clip->isChecked()); + KdenliveSettings::setAdd_new_clip(ui.add_clip->isChecked()); delete d; QStringList jobParams; - jobParams << dest << item->clipUrl().path() << timeIn << timeOut << QString::number(duration) << QString::number(KdenliveSettings::add_clip_cut()); + jobParams << dest << item->clipUrl().path() << timeIn << timeOut << QString::number(duration) << QString::number(KdenliveSettings::add_new_clip()); if (!extraParams.isEmpty()) jobParams << extraParams; CutClipJob *job = new CutClipJob(item->clipType(), id, jobParams); if (job->isExclusive() && hasPendingJob(item, job->jobType)) { @@ -2807,24 +2845,27 @@ void ProjectList::slotTranscodeClipJob(const QString &condition, QString params, ui.extra_params->setVisible(false); d->adjustSize(); ui.button_more->setIcon(KIcon("configure")); - ui.add_clip->setChecked(KdenliveSettings::add_clip_cut()); - ui.extra_params->setPlainText(params.simplified().section(" ", 0, -2)); + ui.add_clip->setChecked(KdenliveSettings::add_new_clip()); + ui.extra_params->setPlainText(params.simplified().section(' ', 0, -2)); QString mess = desc; - mess.append(" " + i18np("(%1 clip)", "(%1 clips)", ids.count())); + mess.append(' ' + i18np("(%1 clip)", "(%1 clips)", ids.count())); ui.info_label->setText(mess); if (d->exec() != QDialog::Accepted) { delete d; return; } params = ui.extra_params->toPlainText().simplified(); - KdenliveSettings::setAdd_clip_cut(ui.add_clip->isChecked()); - + KdenliveSettings::setAdd_new_clip(ui.add_clip->isChecked()); + int index = 0; foreach(const QString &id, ids) { ProjectItem *item = getItemById(id); if (!item || !item->referencedClip()) continue; QString src = item->clipUrl().path(); QString dest; - if (ids.count() > 1) dest = params.section(' ', -1).replace("%1", src); + if (ids.count() > 1) { + dest = destinations.at(index); + index++; + } else dest = ui.file_url->url().path(); QStringList jobParams; jobParams << dest << src << QString() << QString(); @@ -2833,7 +2874,7 @@ void ProjectList::slotTranscodeClipJob(const QString &condition, QString params, int max = item->clipMaxDuration(); QString duration = QString::number(max); jobParams << duration; - jobParams << QString::number(KdenliveSettings::add_clip_cut()); + jobParams << QString::number(KdenliveSettings::add_new_clip()); jobParams << params; CutClipJob *job = new CutClipJob(item->clipType(), id, jobParams); if (job->isExclusive() && hasPendingJob(item, job->jobType)) { @@ -2943,7 +2984,7 @@ void ProjectList::slotProcessJobs() if (job->jobType == MLTJOB) { MeltJob *jb = static_cast (job); - jb->setProducer(currentClip->getProducer()); + jb->setProducer(currentClip->getProducer(), currentClip->fileURL()); } job->startJob(); if (job->jobStatus == JOBDONE) { @@ -2989,7 +3030,7 @@ void ProjectList::updateProxyConfig() QMap oldProps;// = clip->properties(); oldProps.insert("proxy", QString()); QMap newProps; - newProps.insert("proxy", proxydir + item->referencedClip()->getClipHash() + "." + m_doc->getDocumentProperty("proxyextension")); + newProps.insert("proxy", proxydir + item->referencedClip()->getClipHash() + '.' + m_doc->getDocumentProperty("proxyextension")); new EditClipCommand(this, clip->getId(), oldProps, newProps, true, command); } } @@ -3093,7 +3134,7 @@ void ProjectList::slotProxyCurrentItem(bool doProxy, ProjectItem *itemToProxy) //oldProps = clip->properties(); if (doProxy) { newProps.clear(); - QString path = proxydir + clip->getClipHash() + "." + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension")); + QString path = proxydir + clip->getClipHash() + '.' + (t == IMAGE ? "png" : m_doc->getDocumentProperty("proxyextension")); // insert required duration for proxy newProps.insert("proxy_out", clip->producerProperty("out")); newProps.insert("proxy", path); @@ -3287,14 +3328,11 @@ void ProjectList::slotUpdateJobStatus(ProjectItem *item, int type, int status, c item->setJobStatus((JOBTYPE) type, (CLIPJOBSTATUS) status); if (status != JOBCRASHED) return; #if KDE_IS_VERSION(4,7,0) - m_infoMessage->animatedHide(); - m_errorLog.clear(); - m_infoMessage->setText(label); - m_infoMessage->setWordWrap(label.length() > 35); - m_infoMessage->setMessageType(KMessageWidget::Warning); QList actions = m_infoMessage->actions(); - for (int i = 0; i < actions.count(); i++) { - m_infoMessage->removeAction(actions.at(i)); + if (m_infoMessage->isHidden()) { + m_infoMessage->setText(label); + m_infoMessage->setWordWrap(m_infoMessage->text().length() > 35); + m_infoMessage->setMessageType(KMessageWidget::Warning); } if (!actionName.isEmpty()) { @@ -3305,27 +3343,47 @@ void ProjectList::slotUpdateJobStatus(ProjectItem *item, int type, int status, c action = coll->action(actionName); if (action) break; } - if (action) m_infoMessage->addAction(action); + if (action && !actions.contains(action)) m_infoMessage->addAction(action); } if (!details.isEmpty()) { - m_errorLog = details; - m_infoMessage->addAction(m_logAction); + m_errorLog.append(details); + if (!actions.contains(m_logAction)) m_infoMessage->addAction(m_logAction); } m_infoMessage->animatedShow(); +#else + // warning for KDE < 4.7 + KPassivePopup *passivePop = new KPassivePopup( this ); + passivePop->setAutoDelete(true); + connect(passivePop, SIGNAL(clicked()), this, SLOT(slotClosePopup())); + m_errorLog.append(details); + KVBox *vb = new KVBox( passivePop ); + KHBox *vh1 = new KHBox( vb ); + KIcon icon("dialog-warning"); + QLabel *iconLabel = new QLabel(vh1); + iconLabel->setPixmap(icon.pixmap(m_listView->iconSize())); + (void) new QLabel( label, vh1); + KHBox *box = new KHBox( vb ); + QPushButton *but = new QPushButton( "Show log", box ); + connect(but, SIGNAL(clicked(bool)), this, SLOT(slotShowJobLog())); + + passivePop->setView( vb ); + passivePop->show(); + #endif } void ProjectList::slotShowJobLog() { -#if KDE_IS_VERSION(4,7,0) KDialog d(this); d.setButtons(KDialog::Close); QTextEdit t(&d); - t.setPlainText(m_errorLog); + for (int i = 0; i < m_errorLog.count(); i++) { + if (i > 0) t.insertHtml("


"); + t.insertPlainText(m_errorLog.at(i)); + } t.setReadOnly(true); d.setMainWidget(&t); d.exec(); -#endif } QStringList ProjectList::getPendingJobs(const QString &id) @@ -3384,7 +3442,7 @@ void ProjectList::startClipFilterJob(const QString &filterName, const QString &c else { destination = item->clipUrl().directory(); } - ClipStabilize *d = new ClipStabilize(destination, ids.count(), filterName); + QPointer d = new ClipStabilize(destination, ids.count(), filterName); if (d->exec() == QDialog::Accepted) { processClipJob(ids, d->destination(), d->autoAddClip(), d->params(), d->desc()); } @@ -3408,15 +3466,17 @@ void ProjectList::processClipJob(QStringList ids, const QString&destination, boo foreach(const QString&id, ids) { ProjectItem *item = getItemById(id); if (!item) continue; + QStringList jobArgs; + jobArgs << preParams; if (ids.count() == 1) { - consumer += ":" + destination; + jobArgs << consumer + ':' + destination; } else { - consumer += ":" + destination + item->clipUrl().fileName() + ".mlt"; + jobArgs << consumer + ':' + destination + item->clipUrl().fileName() + ".mlt"; } - preParams << consumer << jobParams; + jobArgs << jobParams; - MeltJob *job = new MeltJob(item->clipType(), id, preParams); + MeltJob *job = new MeltJob(item->clipType(), id, jobArgs); if (autoAdd) { job->setAddClipToProject(true); kDebug()<<"// ADDING TRUE"; @@ -3466,4 +3526,20 @@ void ProjectList::updatePalette() m_listView->updateStyleSheet(); } +void ProjectList::slotResetInfoMessage() +{ +#if KDE_IS_VERSION(4,7,0) + m_errorLog.clear(); + QList actions = m_infoMessage->actions(); + for (int i = 0; i < actions.count(); i++) { + m_infoMessage->removeAction(actions.at(i)); + } +#endif +} + +void ProjectList::slotClosePopup() +{ + m_errorLog.clear(); +} + #include "projectlist.moc"