]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.h
Improve feedback when a job fails (needs KDE >= 4.7) using messagewidget that shows...
[kdenlive] / src / projectlist.h
index ed448fea176f32ae059c647ec69852dbae7ab2d7..a0f87f3bad135009b10df8ebc0a26f7fe77935ea 100644 (file)
 #include <QFuture>
 #include <QFutureSynchronizer>
 #include <QListWidget>
+#include <QTimeLine>
+#include <QPushButton>
 
 #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>
@@ -49,6 +56,7 @@
 #include "kdenlivesettings.h"
 #include "folderprojectitem.h"
 #include "subprojectitem.h"
+#include "projecttree/abstractclipjob.h"
 #include <kdialog.h>
 
 namespace Mlt
@@ -56,23 +64,34 @@ namespace Mlt
 class Producer;
 };
 
-struct PROXYINFO {
-    QString dest;
-    QString src;
-    CLIPTYPE type;
-    int exif;
-};
-
 class ProjectItem;
 class ProjectListView;
 class Render;
 class KdenliveDoc;
 class DocClipBase;
+class AbstractClipJob;
 
 const int NameRole = Qt::UserRole;
 const int DurationRole = NameRole + 1;
 const int UsageRole = NameRole + 2;
 
+class SmallInfoLabel: public QPushButton
+{
+    Q_OBJECT
+public:
+    SmallInfoLabel(QWidget *parent = 0);
+
+private:
+    QTimeLine* m_timeLine;
+
+public slots:
+    void slotSetJobCount(int jobCount);
+
+private slots:
+    void slotTimeLineChanged(qreal value);
+    void slotTimeLineFinished();
+};
+    
 class InvalidDialog: public KDialog
 {
     Q_OBJECT
@@ -130,10 +149,10 @@ public:
             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText, &bounding);
             
             int proxy = index.data(Qt::UserRole + 5).toInt();
-            if (proxy != 0 && proxy != PROXYDONE) {
+            if (proxy != 0 && proxy != JOBDONE) {
                 QString proxyText;
                 QColor color;
-                if (proxy != PROXYCRASHED) {
+                if (proxy != JOBCRASHED) {
                     // Draw proxy progress bar
                     color = option.palette.alternateBase().color();
                     painter->setPen(Qt::NoPen);
@@ -147,7 +166,7 @@ public:
                         progress.setWidth((pixmap.width() - 4) * proxy / 100);
                         painter->drawRect(progress);
                     }
-                    else if (proxy == PROXYWAITING) {
+                    else if (proxy == JOBWAITING) {
                         // Draw kind of a pause icon
                         progress.adjust(1, 1, 0, -1);
                         progress.setWidth(2);
@@ -156,7 +175,8 @@ public:
                         painter->drawRect(progress);
                     }
                 }
-                else if (proxy == PROXYCRASHED) {
+                else if (proxy == JOBCRASHED) {
+                    proxyText = index.data(Qt::UserRole + 7).toString();
                     QRectF txtBounding = painter->boundingRect(r2, Qt::AlignRight | Qt::AlignVCenter, " " + proxyText + " ");
                     painter->setPen(Qt::NoPen);
                     painter->setBrush(option.palette.highlight());
@@ -255,6 +275,7 @@ public slots:
 
     /** @brief Prepares removing the selected items. */
     void slotRemoveClip();
+    void slotAddClip(const QString url, const QString &groupName, const QString &groupId);
     void slotAddClip(const QList <QUrl> givenList = QList <QUrl> (), const QString &groupName = QString(), const QString &groupId = QString());
 
     /** @brief Adds, edits or deletes a folder item.
@@ -274,6 +295,8 @@ public slots:
     void slotForceProcessing(const QString &id);
     /** @brief Remove all instances of a proxy and delete the file. */
     void slotDeleteProxy(const QString proxyPath);
+    /** @brief Start a hard cut clip job. */
+    void slotCutClipJob(const QString &id, QPoint zone);
 
 private:
     ProjectListView *m_listView;
@@ -309,10 +332,21 @@ private:
     /** @brief Holds a list of proxy urls that are currently being created. */
     QStringList m_processingProxy;
     QMutex m_mutex;
-    bool m_abortAllProxies;
-    QList <PROXYINFO> m_proxyList;
+    bool m_abortAllJobs;
+    /** @brief We are cleaning up the project list, so stop processing signals. */
+    bool m_closing;
+    QList <AbstractClipJob *> m_jobList;
     QFutureSynchronizer<void> m_proxyThreads;
     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);
 
@@ -336,16 +370,20 @@ private:
 
     /** @brief Set the Proxy status on a clip. 
      * @param item The clip item to set status
-     * @param status The proxy status (see definitions.h) */
-    void setProxyStatus(ProjectItem *item, PROXYSTATUS status, int progress = 0);
-    /** @brief Process ffmpeg output to find out process progress. */
-    void processLogInfo(QList <ProjectItem *>items, int *duration, const QString &log);
+     * @param status The job status (see definitions.h) */
+    void setJobStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress = 0, JOBTYPE jobType = NOJOBTYPE);
     void monitorItemEditing(bool enable);
     /** @brief Get cached thumbnail for a project's clip or create it if no cache. */
     void getCachedThumbnail(ProjectItem *item);
     void getCachedThumbnail(SubProjectItem *item);
     /** @brief The clip is about to be reloaded, cancel thumbnail requests. */
     void resetThumbsProducer(DocClipBase *clip);
+    /** @brief Check if it is necessary to start a job thread. */
+    void startJobProcess();
+    /** @brief Check if a clip has a running or pending proxy process. */
+    bool hasPendingProxy(ProjectItem *item);
+    /** @brief Delete pending jobs for a clip. */
+    void deleteJobsForClip(const QString &clipId);
 
 private slots:
     void slotClipSelected();
@@ -384,8 +422,18 @@ private slots:
     void slotCreateProxy(const QString id);
     /** @brief Stop creation of this clip's proxy. */
     void slotAbortProxy(const QString id, const QString path);
-    /** @brief Start creation of proxy clip. */
-    void slotGenerateProxy();
+    /** @brief Start creation of clip jobs. */
+    void slotProcessJobs();
+    /** @brief Discard running and pending clip jobs. */
+    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);
@@ -409,6 +457,12 @@ signals:
     void processNextThumbnail();
     /** @brief Activate the clip monitor. */
     void raiseClipMonitor();
+    /** @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