X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.h;h=3d25bc71eaddb7356008719feb8f62cb3f83f82f;hb=72afb974a98c4ecde0a892c5ed35519d63a576d2;hp=1803c3627665f5f4fc879ee35d9010e906b8aacb;hpb=09aae6cd42927b370af1b7bc7a94db03fd6a7cf6;p=kdenlive diff --git a/src/projectlist.h b/src/projectlist.h index 1803c362..3d25bc71 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -22,6 +22,7 @@ #define PROJECTLIST_H #include +#include #include #include #include @@ -33,10 +34,17 @@ #include #include #include +#include +#include #include #include #include +#include + +#if KDE_IS_VERSION(4,7,0) +#include +#endif #ifdef NEPOMUK #include @@ -48,6 +56,7 @@ #include "kdenlivesettings.h" #include "folderprojectitem.h" #include "subprojectitem.h" +#include "projecttree/abstractclipjob.h" #include namespace Mlt @@ -55,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 @@ -90,7 +110,7 @@ class ItemDelegate: public QStyledItemDelegate public: ItemDelegate(QAbstractItemView* parent = 0): QStyledItemDelegate(parent) { } - + /*void drawFocus(QPainter *, const QStyleOptionViewItem &, const QRect &) const { }*/ @@ -107,7 +127,8 @@ public: } const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1; QPixmap pixmap = qVariantValue(index.data(Qt::DecorationRole)); - painter->drawPixmap(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2, pixmap); + QPoint pixmapPoint(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2); + painter->drawPixmap(pixmapPoint, pixmap); int decoWidth = pixmap.width() + 2 * textMargin; QFont font = painter->font(); @@ -117,7 +138,7 @@ public: r1.adjust(decoWidth, 0, 0, -mid); QRect r2 = option.rect; r2.adjust(decoWidth, mid, 0, 0); - painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom , index.data().toString()); + painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom, index.data().toString()); font.setBold(false); painter->setFont(font); QString subText = index.data(DurationRole).toString(); @@ -128,45 +149,43 @@ public: painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText, &bounding); int proxy = index.data(Qt::UserRole + 5).toInt(); - if (proxy != 0) { - QRectF txtBounding; + if (proxy != 0 && proxy != JOBDONE) { QString proxyText; - QBrush brush; QColor color; - if (proxy > 0) { - proxyText = QString::number(proxy) + "% "; - proxyText.append(i18n("Generating proxy ...")); - brush = option.palette.highlight(); - color = option.palette.color(QPalette::HighlightedText); - - } - else if (proxy == PROXYDONE) { - proxyText = i18n("Proxy"); - brush = option.palette.mid(); - color = option.palette.color(QPalette::WindowText); + if (proxy != JOBCRASHED) { + // Draw proxy progress bar + color = option.palette.alternateBase().color(); + painter->setPen(Qt::NoPen); + color.setAlpha(180); + painter->setBrush(QBrush(color)); + QRect progress(pixmapPoint.x() + 1, pixmapPoint.y() + pixmap.height() - 5, pixmap.width() - 2, 4); + painter->drawRect(progress); + painter->setBrush(option.palette.text()); + if (proxy > 0) { + progress.adjust(1, 1, 0, -1); + progress.setWidth((pixmap.width() - 4) * proxy / 100); + painter->drawRect(progress); + } + else if (proxy == JOBWAITING) { + // Draw kind of a pause icon + progress.adjust(1, 1, 0, -1); + progress.setWidth(2); + painter->drawRect(progress); + progress.moveLeft(progress.right() + 2); + painter->drawRect(progress); + } } - else { - switch (proxy) { - case CREATINGPROXY: - proxyText = i18n("Generating proxy ..."); - break; - case PROXYWAITING: - proxyText = i18n("Waiting proxy ..."); - break; - case PROXYCRASHED: - default: - proxyText = i18n("Proxy crashed"); + else if (proxy == JOBCRASHED) { + proxyText = index.data(Qt::UserRole + 7).toString(); + if (!proxyText.isEmpty()) { + QRectF txtBounding = painter->boundingRect(r2, Qt::AlignRight | Qt::AlignVCenter, " " + proxyText + " "); + painter->setPen(Qt::NoPen); + painter->setBrush(option.palette.highlight()); + painter->drawRoundedRect(txtBounding, 2, 2); + painter->setPen(option.palette.highlightedText().color()); + painter->drawText(txtBounding, Qt::AlignHCenter | Qt::AlignVCenter , proxyText); } - brush = option.palette.highlight(); - color = option.palette.color(QPalette::HighlightedText); } - - txtBounding = painter->boundingRect(r2, Qt::AlignRight | Qt::AlignVCenter, " " + proxyText + " "); - painter->setPen(Qt::NoPen); - painter->setBrush(brush); - painter->drawRoundedRect(txtBounding, 2, 2); - painter->setPen(option.palette.highlightedText().color()); - painter->drawText(txtBounding, Qt::AlignHCenter | Qt::AlignVCenter , proxyText); } painter->restore(); @@ -203,7 +222,7 @@ public: void setHeaderInfo(const QByteArray &state); void updateProjectFormat(Timecode t); void setupMenu(QMenu *addMenu, QAction *defaultAction); - void setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu, QMenu *inTimelineMenu); + void setupGeneratorMenu(const QHash& menus); QString currentClipUrl() const; KUrl::List getConditionalUrls(const QString &condition) const; QDomDocument generateTemplateXml(QString data, const QString &replaceString); @@ -236,13 +255,17 @@ public: bool generateImageProxy() const; /** @brief Returns a list of the expanded folder ids. */ QStringList expandedFolders() const; + /** @brief Deselect all clips in project tree. */ + void clearSelection(); + /** @brief Print required overlays over clip thumb (proxy, stabilized,...). */ + void processThumbOverlays(ProjectItem *item, QPixmap &pix); public slots: void setDocument(KdenliveDoc *doc); - void updateAllClips(bool displayRatioChanged, bool fpsChanged); + void updateAllClips(bool displayRatioChanged, bool fpsChanged, QStringList brokenClips); void slotReplyGetImage(const QString &clipId, const QImage &img); void slotReplyGetImage(const QString &clipId, const QString &name, int width, int height); - void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace, bool refreshThumbnail); + void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace); void slotAddClip(DocClipBase *clip, bool getProperties); void slotDeleteClip(const QString &clipId); void slotUpdateClip(const QString &id); @@ -254,6 +277,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 givenList = QList (), const QString &groupName = QString(), const QString &groupId = QString()); /** @brief Adds, edits or deletes a folder item. @@ -273,6 +297,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; @@ -288,10 +314,13 @@ private: QAction *m_openAction; QAction *m_reloadAction; QMenu *m_transcodeAction; + QMenu *m_stabilizeAction; KdenliveDoc *m_doc; ItemDelegate *m_listViewDelegate; /** @brief False if we have not yet finished opening the document. */ bool m_refreshed; + /** @brief False if we have not yet finished checking all project tree thumbs. */ + bool m_allClipsProcessed; QToolButton *m_addButton; QToolButton *m_deleteButton; QToolButton *m_editButton; @@ -305,11 +334,21 @@ private: /** @brief Holds a list of proxy urls that are currently being created. */ QStringList m_processingProxy; QMutex m_mutex; - bool m_abortAllProxies; - QList m_proxyList; + bool m_abortAllJobs; + /** @brief We are cleaning up the project list, so stop processing signals. */ + bool m_closing; + QList m_jobList; QFutureSynchronizer m_proxyThreads; InvalidDialog *m_invalidClipDialog; - QTimer m_refreshMonitorTimer; + 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); @@ -323,6 +362,8 @@ private: /** @brief Enables and disables transcode actions based on the selected clip's type. */ void adjustTranscodeActions(ProjectItem *clip) const; + /** @brief Enables and disables stabilize actions based on the selected clip's type. */ + void adjustStabilizeActions(ProjectItem *clip) const; /** @brief Enables and disables proxy action based on the selected clip. */ void adjustProxyActions(ProjectItem *clip) const; @@ -331,16 +372,23 @@ 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(const QString proxyPath, PROXYSTATUS status, int progress = 0); - void setProxyStatus(ProjectItem *item, PROXYSTATUS status, int progress = 0); - /** @brief Process ffmpeg output to find out process progress. */ - void processLogInfo(const QString &path, int *duration, const QString &log); + * @param status The job status (see definitions.h) + * @param progress The job progress (in percents) + * @param jobType The job type + * @param statusMessage The job info message */ + void setJobStatus(ProjectItem *item, CLIPJOBSTATUS status, int progress = 0, JOBTYPE jobType = NOJOBTYPE, const QString &statusMessage = QString()); void monitorItemEditing(bool enable); - /** @brief Set thumbnail for a project's clip. */ - void setThumbnail(const QString &clipId, const QPixmap &pix); /** @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(); @@ -374,18 +422,26 @@ private slots: void slotGotProxy(const QString &proxyPath); void slotGotProxy(ProjectItem *item); /** @brief Enable / disable proxy for current clip. */ - void slotProxyCurrentItem(bool doProxy); + void slotProxyCurrentItem(bool doProxy, ProjectItem *itemToProxy = NULL); /** @brief Put clip in the proxy waiting list. */ 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();//const QString destPath, const QString sourcePath, int clipType, int exif); - /** @brief Timer triggering a refresh of the clip monitor. */ - void slotRefreshMonitor(); + /** @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()); + void clipSelected(DocClipBase *, QPoint zone = QPoint(), bool forceUpdate = false); void receivedClipDuration(const QString &); void showClipProperties(DocClipBase *); void showClipProperties(QList , QMap commonproperties); @@ -393,7 +449,7 @@ signals: void loadingIsOver(); void displayMessage(const QString, int progress); void clipNameChanged(const QString, const QString); - void clipNeedsReload(const QString&, bool); + void clipNeedsReload(const QString&); /** @brief A property affecting display was changed, so we need to update monitors and thumbnails * @param id: The clip's id string * @param resetThumbs Should we recreate the timeline thumbnails. */ @@ -404,6 +460,14 @@ signals: /** @brief Request a profile change for current document. */ void updateProfile(const QString &); 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