#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;
}
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);
}
// 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);
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 > -1) 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 (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;
}
}
+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"
#include <KTreeWidgetSearchLine>
#include <KUrl>
#include <KIcon>
+#include <kdeversion.h>
+
+#if KDE_IS_VERSION(4,7,0)
+#include <KMessageWidget>
+#endif
#ifdef NEPOMUK
#include <nepomuk/kratingpainter.h>
InvalidDialog *m_invalidClipDialog;
QMenu *m_jobsMenu;
SmallInfoLabel *m_infoLabel;
+#if KDE_IS_VERSION(4,7,0)
+ KMessageWidget *m_infoMessage;
+ /** @brief A string containing the last error log for a clip job. */
+ QString m_errorLog;
+ /** @brief The action that will trigger the log dialog. */
+ QAction *m_logAction;
+#endif
void requestClipThumbnail(const QString id);
* @param item The clip item to set status
* @param status The job status (see definitions.h) */
void setJobStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress = 0, JOBTYPE jobType = NOJOBTYPE);
- /** @brief Process ffmpeg output to find out process progress. */
- void processLogInfo(QList <ProjectItem *>items, int progress, JOBTYPE jobType);
void monitorItemEditing(bool enable);
/** @brief Get cached thumbnail for a project's clip or create it if no cache. */
void getCachedThumbnail(ProjectItem *item);
void slotCancelJobs();
/** @brief Discard a running clip jobs. */
void slotCancelRunningJob(const QString id, stringMap);
+ /** @brief Update a clip's job status. */
+ void slotProcessLog(ProjectItem *item, int progress, int);
+ /** @brief A clip fob crashed, inform user. */
+ void slotJobCrashed(ProjectItem *item, const QString &label, const QString &actionName = QString(), const QString details = QString());
+ /** @brief Display error log for last failed job. */
+ void slotShowJobLog();
signals:
void clipSelected(DocClipBase *, QPoint zone = QPoint(), bool forceUpdate = false);
/** @brief Set number of running jobs. */
void jobCount(int);
void cancelRunningJob(const QString, stringMap);
+ void processLog(ProjectItem *, int , int);
void addClip(const QString, const QString &, const QString &);
+ void jobCrashed(ProjectItem *item, const QString &label, const QString &actionName = QString(), const QString details = QString());
};
#endif