X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.h;h=25a222d9949a56707e4fcac5245cb6f9936ef8d7;hb=8fc16957ff5417b21e68ca5d84de89bec38c5a1c;hp=02c32199612b8e9c7db42807411ceeaf77fea6eb;hpb=674229de00f3b42f64251808087651b0ccd1d6c9;p=kdenlive diff --git a/src/projectlist.h b/src/projectlist.h index 02c32199..25a222d9 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -22,6 +22,7 @@ #define PROJECTLIST_H #include +#include #include #include #include @@ -33,10 +34,13 @@ #include #include #include +#include +#include #include #include #include +#include #ifdef NEPOMUK #include @@ -48,18 +52,41 @@ #include "kdenlivesettings.h" #include "folderprojectitem.h" #include "subprojectitem.h" +#include "projecttree/abstractclipjob.h" #include -namespace Mlt +#if KDE_IS_VERSION(4,7,0) +#include +#else +// Dummy KMessageWidget to allow compilation of MyMessageWidget class since Qt's moc doesn work inside #ifdef +#include + +class KMessageWidget: public QLabel { -class Producer; +public: + KMessageWidget(QWidget * = 0) {}; + KMessageWidget(const QString &, QWidget * = 0) {}; + virtual ~KMessageWidget(){}; +}; +#endif + +class MyMessageWidget: public KMessageWidget +{ + Q_OBJECT +public: + MyMessageWidget(QWidget *parent = 0); + MyMessageWidget(const QString &text, QWidget *parent = 0); + +protected: + bool event(QEvent* ev); + +signals: + void messageClosing(); }; -struct PROXYINFO { - QString dest; - QString src; - CLIPTYPE type; - int exif; +namespace Mlt +{ +class Producer; }; class ProjectItem; @@ -67,11 +94,29 @@ 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); + static const QString getStyleSheet(const QPalette &p); +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 +135,7 @@ class ItemDelegate: public QStyledItemDelegate public: ItemDelegate(QAbstractItemView* parent = 0): QStyledItemDelegate(parent) { } - + /*void drawFocus(QPainter *, const QStyleOptionViewItem &, const QRect &) const { }*/ @@ -107,7 +152,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,56 +163,47 @@ 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(); int usage = index.data(UsageRole).toInt(); if (usage != 0) subText.append(QString(" (%1)").arg(usage)); - if (option.state & (QStyle::State_Selected)) painter->setPen(option.palette.color(QPalette::Mid)); QRectF bounding; painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText, &bounding); - - int proxy = index.data(Qt::UserRole + 5).toInt(); - if (proxy != 0) { - QRectF txtBounding; - 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); - } - else { - switch (proxy) { - case CREATINGPROXY: - proxyText = i18n("Generating proxy ..."); - break; - case PROXYWAITING: - proxyText = i18n("Waiting proxy ..."); - break; - case PROXYCRASHED: - default: - proxyText = i18n("Proxy crashed"); + int jobProgress = index.data(Qt::UserRole + 5).toInt(); + if (jobProgress != 0 && jobProgress != JOBDONE && jobProgress != JOBABORTED) { + if (jobProgress != JOBCRASHED) { + // Draw job progress bar + QColor color = option.palette.alternateBase().color(); + color.setAlpha(150); + painter->setPen(option.palette.link().color()); + QRect progress(pixmapPoint.x() + 2, pixmapPoint.y() + pixmap.height() - 9, pixmap.width() - 4, 7); + painter->setBrush(QBrush(color)); + painter->drawRect(progress); + painter->setBrush(option.palette.link()); + progress.adjust(2, 2, -2, -2); + if (jobProgress == JOBWAITING) { + progress.setLeft(progress.right() - 2); + painter->drawRect(progress); + progress.moveLeft(progress.left() - 5); + painter->drawRect(progress); + } + else if (jobProgress > 0) { + progress.setWidth(progress.width() * jobProgress / 100); + painter->drawRect(progress); + } + } else if (jobProgress == JOBCRASHED) { + QString jobText = index.data(Qt::UserRole + 7).toString(); + if (!jobText.isEmpty()) { + QRectF txtBounding = painter->boundingRect(r2, Qt::AlignRight | Qt::AlignVCenter, " " + jobText + " "); + painter->setPen(Qt::NoPen); + painter->setBrush(option.palette.highlight()); + painter->drawRoundedRect(txtBounding, 2, 2); + painter->setPen(option.palette.highlightedText().color()); + painter->drawText(txtBounding, Qt::AlignCenter, jobText); } - 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,9 +240,11 @@ 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; + /** @brief Get a list of selected clip Id's and url's that match a condition. */ + QMap getConditionalIds(const QString &condition) const; QDomDocument generateTemplateXml(QString data, const QString &replaceString); void cleanup(); void trashUnusedClips(); @@ -238,9 +277,17 @@ public: 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); + /** @brief Start an MLT process job. */ + void startClipFilterJob(const QString &filterName, const QString &condition); + /** @brief Set current document for the project tree. */ + void setDocument(KdenliveDoc *doc); + + /** @brief Palette was changed, update style. */ + void updatePalette(); public slots: - void setDocument(KdenliveDoc *doc); 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); @@ -256,6 +303,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. @@ -275,6 +323,14 @@ 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); + /** @brief Start transcoding selected clips. */ + void slotTranscodeClipJob(const QString &condition, QString params, QString desc); + /** @brief Start an MLT process job. */ + void slotStartFilterJob(ItemInfo, const QString&,const QString&,const QString&,const QString&,const QString&,const QMap &); + void slotSetThumbnail(const QString &id, int framePos, QImage img); + private: ProjectListView *m_listView; @@ -287,9 +343,13 @@ private: ProjectItem *getItemById(const QString &id); QTreeWidgetItem *getAnyItemById(const QString &id); FolderProjectItem *getFolderItemById(const QString &id); + FolderProjectItem *getFolderItemByName(const QString &name); QAction *m_openAction; QAction *m_reloadAction; + QAction *m_discardCurrentClipJobs; + QMenu *m_extractAudioAction; QMenu *m_transcodeAction; + QMenu *m_clipsActionsMenu; KdenliveDoc *m_doc; ItemDelegate *m_listViewDelegate; /** @brief False if we have not yet finished opening the document. */ @@ -303,16 +363,24 @@ private: QMap m_producerQueue; QList m_thumbnailQueue; QAction *m_proxyAction; - QStringList m_processingClips; - /** @brief Holds a list of proxy urls that should be aborted. */ - QStringList m_abortProxy; - /** @brief Holds a list of proxy urls that are currently being created. */ - QStringList m_processingProxy; - QMutex m_mutex; - bool m_abortAllProxies; - QList m_proxyList; - QFutureSynchronizer m_proxyThreads; + QMutex m_jobMutex; + QMutex m_processMutex; + bool m_abortAllJobs; + /** @brief We are cleaning up the project list, so stop processing signals. */ + bool m_closing; + QList m_jobList; + QFutureSynchronizer m_jobThreads; InvalidDialog *m_invalidClipDialog; + QMenu *m_jobsMenu; + SmallInfoLabel *m_infoLabel; + /** @brief A list of strings containing the last error logs for clip jobs. */ + QStringList m_errorLog; + +#if KDE_IS_VERSION(4,7,0) + MyMessageWidget *m_infoMessage; + /** @brief The action that will trigger the log dialog. */ + QAction *m_logAction; +#endif void requestClipThumbnail(const QString id); @@ -326,6 +394,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; @@ -334,19 +404,34 @@ 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(QList items, int *duration, const QString &log); + * @param jobType The job type + * @param status The job status (see definitions.h) + * @param progress The job progress (in percents) + * @param statusMessage The job info message */ + void setJobStatus(ProjectItem *item, JOBTYPE jobType, CLIPJOBSTATUS status, int progress = 0, 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 a clip has a running or pending job process. */ + bool hasPendingJob(ProjectItem *item, JOBTYPE type); + /** @brief Delete pending jobs for a clip. */ + void deleteJobsForClip(const QString &clipId); + /** @brief Discard specific job type for a clip. */ + void discardJobs(const QString &id, JOBTYPE type = NOJOBTYPE); + /** @brief Get the list of job names for current clip. */ + QStringList getPendingJobs(const QString &id); + /** @brief Start an MLT process job. */ + void processClipJob(QStringList ids, const QString&destination, bool autoAdd, QStringList jobParams, const QString &description, stringMap extraParams = stringMap()); + /** @brief Create rounded shape pixmap for project tree thumb. */ + QPixmap roundedPixmap(QImage img); + QPixmap roundedPixmap(QPixmap source); + /** @brief Extract a clip's metadata with the exiftool program. */ + void extractMetadata(DocClipBase *clip); + /** @brief Add a special FFmpeg tag if clip matches some properties (for example set full_luma for Sony NEX camcorders. */ + //void checkCamcorderFilters(DocClipBase *clip, QMap meta); private slots: void slotClipSelected(); @@ -360,7 +445,7 @@ private slots: void slotContextMenu(const QPoint &pos, QTreeWidgetItem *item); /** @brief Creates an AddFolderCommand. */ - void slotAddFolder(); + void slotAddFolder(const QString &name = QString()); /** @brief This is triggered when a clip description has been modified. */ void slotItemEdited(QTreeWidgetItem *item, int column); @@ -385,17 +470,44 @@ 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(const QString, int progress, int, const QString = QString()); + /** @brief A clip job crashed, inform user. */ + void slotUpdateJobStatus(const QString id, int type, int status, const QString label, const QString actionName, const QString details); + void slotUpdateJobStatus(ProjectItem *item, int type, int status, const QString &label, const QString &actionName = QString(), const QString details = QString()); + /** @brief Display error log for last failed job. */ + void slotShowJobLog(); + /** @brief A proxy clip is ready. */ + void slotGotProxyForId(const QString); + /** @brief Check if it is necessary to start a job thread. */ + void slotCheckJobProcess(); + /** @brief Fill the jobs menu with current clip's jobs. */ + void slotPrepareJobsMenu(); + /** @brief Discard all jobs for current clip. */ + void slotDiscardClipJobs(); + /** @brief Make sure current clip is visible in project tree. */ + void slotCheckScrolling(); + /** @brief Reset all text and log data from info message widget. */ + void slotResetInfoMessage(); + /** @brief close warning info passive popup. */ + void slotClosePopup(); + /** @brief process clip job result. */ + void slotGotFilterJobResults(QString ,int , int, stringMap, stringMap); 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); void projectModified(); void loadingIsOver(); - void displayMessage(const QString, int progress); + void displayMessage(const QString, int progress, MessageType type = DefaultMessage); void clipNameChanged(const QString, const QString); void clipNeedsReload(const QString&); /** @brief A property affecting display was changed, so we need to update monitors and thumbnails @@ -409,8 +521,22 @@ signals: void updateProfile(const QString &); void processNextThumbnail(); /** @brief Activate the clip monitor. */ - void raiseClipMonitor(); + void raiseClipMonitor(bool forceRefresh); + /** @brief Set number of running jobs. */ + void jobCount(int); + void cancelRunningJob(const QString, stringMap); + void processLog(const QString, int , int, const QString = QString()); + void addClip(const QString, const QString &, const QString &); + void updateJobStatus(const QString, int, int, const QString label = QString(), const QString actionName = QString(), const QString details = QString()); + void gotProxy(const QString); + void checkJobProcess(); + /** @brief A Filter Job produced results, send them back to the clip. */ + void gotFilterJobResults(const QString &id, int startPos, int track, stringMap params, stringMap extra); + void pauseMonitor(); + void updateAnalysisData(DocClipBase *); + void addMarkers(const QString &, QList ); }; #endif +