#include <KApplication>
#include <KStandardDirs>
#include <KColorScheme>
+#include <KActionCollection>
#include <KUrlRequester>
#ifdef NEPOMUK
m_jobsMenu->addAction(cancelJobs);
m_infoLabel->setMenu(m_jobsMenu);
box->addWidget(m_infoLabel);
-
+
int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
QSize iconSize(size, size);
m_listView = new ProjectListView;
layout->addWidget(m_listView);
+
+#if KDE_IS_VERSION(4,7,0)
+ m_infoMessage = new KMessageWidget;
+ layout->addWidget(m_infoMessage);
+ m_infoMessage->setCloseButtonVisible(true);
+ //m_infoMessage->setWordWrap(true);
+ m_infoMessage->hide();
+ m_logAction = new QAction(i18n("Show Log"), this);
+ m_logAction->setCheckable(false);
+ connect(m_logAction, SIGNAL(triggered()), this, SLOT(slotShowJobLog()));
+#endif
+
setLayout(layout);
searchView->setTreeWidget(m_listView);
connect(m_listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
connect(this, SIGNAL(cancelRunningJob(const QString, stringMap )), this, SLOT(slotCancelRunningJob(const QString, stringMap)));
+ connect(this, SIGNAL(processLog(ProjectItem *, int , int)), this, SLOT(slotProcessLog(ProjectItem *, int , int)));
+
+ connect(this, SIGNAL(jobCrashed(ProjectItem *, const QString &, const QString &, const QString)), this, SLOT(slotJobCrashed(ProjectItem *, const QString &, const QString &, const QString)));
m_listViewDelegate = new ItemDelegate(m_listView);
m_listView->setItemDelegate(m_listViewDelegate);
m_listView->blockSignals(true);
m_listView->clear();
delete m_listViewDelegate;
+#if KDE_IS_VERSION(4,7,0)
+ delete m_infoMessage;
+#endif
}
void ProjectList::focusTree() const
kDebug() << "Proxy duration is wrong, try changing transcoding parameters.";
emit displayMessage(i18n("Proxy clip unusable (duration is different from original)."), -2);
}
- item->setJobStatus(JOBCRASHED);
+ slotJobCrashed(item, i18n("Failed to create proxy for %1. check parameters", item->text(0)), "project_settings");
QString path = item->referencedClip()->getProperty("proxy");
KUrl proxyFolder(m_doc->projectFolder().path( KUrl::AddTrailingSlash) + "proxy/");
if (!item || hasPendingProxy(item) || item->referencedClip()->isPlaceHolder()) return;
QString path = item->referencedClip()->getProperty("proxy");
if (path.isEmpty()) {
- setJobStatus(item, JOBCRASHED);
+ jobCrashed(item, i18n("Failed to create proxy, empty path."));
return;
}
slotGotProxy(path);
return;
}
- if (!item->isJobRunning()) setJobStatus(item, JOBWAITING);
m_processingProxy.append(path);
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()));
m_jobList.append(job);
+ if (!item->isJobRunning()) setJobStatus(item, JOBWAITING, 0, job->jobType, job->statusMessage(JOBWAITING));
startJobProcess();
}
{
ProjectItem *item = getItemById(id);
if (!item|| item->referencedClip()->isPlaceHolder()) return;
- QString dest = item->clipUrl().path();
- QString ext = dest.section('.', -1);
- dest = dest.section('.', 0, -2) + "_" + QString::number(zone.x()) + "." + ext;
+ QString source = item->clipUrl().path();
+ QString ext = source.section('.', -1);
+ QString dest = source.section('.', 0, -2) + "_" + QString::number(zone.x()) + "." + ext;
double clipFps = item->referencedClip()->getProperty("fps").toDouble();
if (clipFps == 0) clipFps = m_fps;
in = GenTime(in, m_timecode.fps()).frames(clipFps);
out = GenTime(out, m_timecode.fps()).frames(clipFps);
int max = GenTime(item->clipMaxDuration(), m_timecode.fps()).frames(clipFps);
- int duration = out - in;
+ int duration = out - in + 1;
QString timeIn = Timecode::getStringTimecode(in, clipFps, true);
QString timeOut = Timecode::getStringTimecode(duration, clipFps, true);
QDialog *d = new QDialog(this);
Ui::CutJobDialog_UI ui;
ui.setupUi(d);
+ ui.add_clip->setChecked(KdenliveSettings::add_clip_cut());
ui.file_url->fileDialog()->setOperationMode(KFileDialog::Saving);
ui.file_url->setUrl(KUrl(dest));
- ui.info_label->setText(i18n("Extracting %1 out of %2", timeOut, Timecode::getStringTimecode(max, clipFps, true)));
- if (d->exec() != QDialog::Accepted) return;
+ QString mess = i18n("Extracting %1 out of %2", timeOut, Timecode::getStringTimecode(max, clipFps, true));
+ ui.info_label->setText(mess);
+ if (d->exec() != QDialog::Accepted) {
+ delete d;
+ return;
+ }
dest = ui.file_url->url().path();
+ bool acceptPath = dest != source;
+ if (acceptPath && QFileInfo(dest).size() > 0) {
+ // destination file olready exists, overwrite?
+ acceptPath = false;
+ }
+ while (!acceptPath) {
+ // Do not allow to save over original clip
+ if (dest == source) ui.info_label->setText("<b>" + i18n("You cannot overwrite original clip.") + "</b><br>" + mess);
+ else if (KMessageBox::questionYesNo(this, i18n("Overwrite file %1", dest)) == KMessageBox::Yes) break;
+ if (d->exec() != QDialog::Accepted) {
+ delete d;
+ return;
+ }
+ dest = ui.file_url->url().path();
+ acceptPath = dest != source;
+ if (acceptPath && QFileInfo(dest).size() > 0) {
+ acceptPath = false;
+ }
+ }
QString extraParams = ui.extra_params->toPlainText().simplified();
+ KdenliveSettings::setAdd_clip_cut(ui.add_clip->isChecked());
delete d;
-
- if (QFileInfo(dest).size() > 0) {
- // Clip already created
- setJobStatus(item, JOBDONE);
- emit addClip(dest, QString(), QString());
- return;
- }
- if (!item->isJobRunning()) setJobStatus(item, JOBWAITING);
+
m_processingProxy.append(dest);
QStringList jobParams;
- jobParams << dest << item->clipUrl().path() << timeIn << timeOut << QString::number(duration);
+ jobParams << dest << item->clipUrl().path() << timeIn << timeOut << QString::number(duration) << QString::number(KdenliveSettings::add_clip_cut());
if (!extraParams.isEmpty()) jobParams << extraParams;
CutClipJob *job = new CutClipJob(item->clipType(), id, jobParams);
m_jobList.append(job);
+ if (!item->isJobRunning()) setJobStatus(item, JOBWAITING, 0, job->jobType, job->statusMessage(JOBWAITING));
startJobProcess();
}
}
// Get the list of clips that will need to get progress info
- QTreeWidgetItemIterator it(m_listView);
- QList <ProjectItem *> processingItems;
- ProjectItem *item = getItemById(job->clipId());
- processingItems.append(item);
+ ProjectItem *processingItem = getItemById(job->clipId());
+ if (processingItem == NULL) {
+ delete job;
+ continue;
+ }
/*while (*it && !m_abortAllJobs) {
if ((*it)->type() == PROJECTCLIPTYPE) {
++it;
}*/
- // Make sure proxy path is writable
+ // Make sure destination path is writable
QFile file(job->destination());
if (!file.open(QIODevice::WriteOnly)) {
- for (int i = 0; i < processingItems.count(); i++)
- setJobStatus(processingItems.at(i), JOBCRASHED);
+ emit jobCrashed(processingItem, i18n("Cannot write to path: %1", job->destination()));
m_processingProxy.removeAll(job->destination());
delete job;
continue;
file.close();
QFile::remove(job->destination());
- for (int i = 0; i < processingItems.count(); i++)
- setJobStatus(processingItems.at(i), CREATINGJOB, 0, job->jobType);
+ setJobStatus(processingItem, CREATINGJOB, 0, job->jobType, job->statusMessage(CREATINGJOB));
bool success;
QProcess *jobProcess = job->startJob(&success);
int result = -1;
if (jobProcess == NULL) {
// job is finished
- for (int i = 0; i < processingItems.count(); i++)
- setJobStatus(processingItems.at(i), success ? JOBDONE : JOBCRASHED);
if (success) {
+ setJobStatus(processingItem, JOBDONE);
if (job->jobType == PROXYJOB) slotGotProxy(job->destination());
//TODO: set folder for transcoded clips
else if (job->jobType == CUTJOB) emit addClip(job->destination(), QString(), QString());
}
else {
QFile::remove(job->destination());
+ emit jobCrashed(processingItem, job->errorMessage());
}
m_abortProxy.removeAll(job->destination());
m_processingProxy.removeAll(job->destination());
}
else {
int progress = job->processLogInfo();
- if (progress > -1) processLogInfo(processingItems, progress, job->jobType);
+ if (progress > 0) emit processLog(processingItem, progress, job->jobType);
}
jobProcess->waitForFinished(500);
}
if (result == -1) result = jobProcess->exitStatus();
if (result != -2 && QFileInfo(job->destination()).size() == 0) {
- result = QProcess::CrashExit;
+ job->processLogInfo();
+ emit jobCrashed(processingItem, i18n("Failed to create file"), QString(), job->errorMessage());
+ result = -2;
}
if (result == QProcess::NormalExit) {
// proxy successfully created
- for (int i = 0; i < processingItems.count(); i++)
- setJobStatus(processingItems.at(i), JOBDONE);
+ setJobStatus(processingItem, JOBDONE);
if (job->jobType == PROXYJOB) slotGotProxy(job->destination());
//TODO: set folder for transcoded clips
- else if (job->jobType == CUTJOB) emit addClip(job->destination(), QString(), QString());
+ else if (job->jobType == CUTJOB) {
+ CutClipJob *cutJob = static_cast<CutClipJob *>(job);
+ if (cutJob->addClipToProject) emit addClip(job->destination(), QString(), QString());
+ }
}
else if (result == QProcess::CrashExit) {
// Proxy process crashed
QFile::remove(job->destination());
- for (int i = 0; i < processingItems.count(); i++)
- setJobStatus(processingItems.at(i), JOBCRASHED);
+ emit jobCrashed(processingItem, i18n("Job crashed"), QString(), job->errorMessage());
}
delete job;
continue;
}
-void ProjectList::processLogInfo(QList <ProjectItem *>items, int progress, JOBTYPE jobType)
-{
- for (int i = 0; i < items.count(); i++)
- setJobStatus(items.at(i), CREATINGJOB, progress, jobType);
-}
-
void ProjectList::updateProxyConfig()
{
ProjectItem *item;
else delete command;
}
+void ProjectList::slotProcessLog(ProjectItem *item, int progress, int type)
+{
+ setJobStatus(item, CREATINGJOB, progress, (JOBTYPE) type);
+}
+
void ProjectList::slotProxyCurrentItem(bool doProxy, ProjectItem *itemToProxy)
{
QList<QTreeWidgetItem *> list;
QFile::remove(proxyPath);
}
-void ProjectList::setJobStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress, JOBTYPE jobType)
+void ProjectList::setJobStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress, JOBTYPE jobType, const QString &statusMessage)
{
if (item == NULL || m_abortAllJobs) return;
monitorItemEditing(false);
- item->setJobStatus(status, progress, jobType);
+ item->setJobStatus(status, progress, jobType, statusMessage);
if (status == JOBCRASHED) {
DocClipBase *clip = item->referencedClip();
if (!clip) {
}
}
+void ProjectList::slotJobCrashed(ProjectItem *item, const QString &label, const QString &actionName, const QString details)
+{
+#if KDE_IS_VERSION(4,7,0)
+ m_infoMessage->animatedHide();
+ item->setJobStatus(NOJOB);
+ m_errorLog.clear();
+ m_infoMessage->setText(label);
+ m_infoMessage->setWordWrap(label.length() > 35);
+ m_infoMessage->setMessageType(KMessageWidget::Warning);
+ QList<QAction *> actions = m_infoMessage->actions();
+ for (int i = 0; i < actions.count(); i++) {
+ m_infoMessage->removeAction(actions.at(i));
+ }
+
+ if (!actionName.isEmpty()) {
+ QAction *action;
+ QList< KActionCollection * > collections = KActionCollection::allCollections();
+ for (int i = 0; i < collections.count(); i++) {
+ KActionCollection *coll = collections.at(i);
+ action = coll->action(actionName);
+ if (action) break;
+ }
+ if (action) m_infoMessage->addAction(action);
+ }
+ if (!details.isEmpty()) {
+ m_errorLog = details;
+ m_infoMessage->addAction(m_logAction);
+ }
+ m_infoMessage->animatedShow();
+#else
+ item->setJobStatus(JOBCRASHED);
+#endif
+}
+void ProjectList::slotShowJobLog()
+{
+ KDialog d(this);
+ d.setButtons(KDialog::Close);
+ QTextEdit t(&d);
+ t.setPlainText(m_errorLog);
+ t.setReadOnly(true);
+ d.setMainWidget(&t);
+ d.exec();
+}
#include "projectlist.moc"