]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.cpp
Fix warning when several proxy clips fail, also add passive popup warning for KDE...
[kdenlive] / src / projectlist.cpp
index df1ac4f52a08930414fe273d5d3a8c552d6d7e67..a3bae049775f2e481eed2862b3260400c908a36c 100644 (file)
@@ -58,6 +58,8 @@
 #include <KColorScheme>
 #include <KActionCollection>
 #include <KUrlRequester>
+#include <KVBox>
+#include <KHBox>
 
 #ifdef USE_NEPOMUK
 #include <nepomuk/global.h>
 #include <QInputDialog>
 #include <QtConcurrentRun>
 #include <QVBoxLayout>
+#include <KPassivePopup>
+
+
+MyMessageWidget::MyMessageWidget(QWidget *parent) : KMessageWidget(parent) {}
+MyMessageWidget::MyMessageWidget(const QString &text, QWidget *parent) : KMessageWidget(text, parent) {}
+
+
+bool MyMessageWidget::event(QEvent* ev) {
+    if (ev->type() == QEvent::Hide || ev->type() == QEvent::Close) emit messageClosing();
+    return KMessageWidget::event(ev);
+}
 
 SmallInfoLabel::SmallInfoLabel(QWidget *parent) : QPushButton(parent)
 {
@@ -278,10 +291,11 @@ ProjectList::ProjectList(QWidget *parent) :
     m_listView = new ProjectListView(this);
     layout->addWidget(m_listView);
     
-#if KDE_IS_VERSION(4,7,0)    
-    m_infoMessage = new KMessageWidget;
+#if KDE_IS_VERSION(4,7,0)
+    m_infoMessage = new MyMessageWidget;
     layout->addWidget(m_infoMessage);
     m_infoMessage->setCloseButtonVisible(true);
+    connect(m_infoMessage, SIGNAL(messageClosing()), this, SLOT(slotResetInfoMessage()));
     //m_infoMessage->setWordWrap(true);
     m_infoMessage->hide();
     m_logAction = new QAction(i18n("Show Log"), this);
@@ -733,6 +747,10 @@ void ProjectList::slotMissingClip(const QString &id)
     if (item) {
         item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
         int height = m_listView->iconSize().height();
+        if (m_render == NULL) {
+            kDebug() << "*********  ERROR, NULL RENDR";
+            return;
+        }
         int width = (int)(height  * m_render->dar());
         QPixmap pixmap = qVariantValue<QPixmap>(item->data(0, Qt::DecorationRole));
         if (pixmap.isNull()) {
@@ -746,10 +764,6 @@ void ProjectList::slotMissingClip(const QString &id)
         item->setData(0, Qt::DecorationRole, pixmap);
         if (item->referencedClip()) {
             item->referencedClip()->setPlaceHolder(true);
-            if (m_render == NULL) {
-                kDebug() << "*********  ERROR, NULL RENDR";
-                return;
-            }
             Mlt::Producer *newProd = m_render->invalidProducer(id);
             if (item->referencedClip()->getProducer()) {
                 Mlt::Properties props(newProd->get_properties());
@@ -1278,6 +1292,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     //m_listView->setEnabled(false);
     const QString parent = clip->getProperty("groupid");
     ProjectItem *item = NULL;
+    kDebug()<<"// Adding clip 1";
     monitorItemEditing(false);
     if (!parent.isEmpty()) {
         FolderProjectItem *parentitem = getFolderItemById(parent);
@@ -1296,6 +1311,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     if (item == NULL) {
         item = new ProjectItem(m_listView, clip);
     }
+    kDebug()<<"// Adding clip 2";
     if (item->data(0, DurationRole).isNull()) item->setData(0, DurationRole, i18n("Loading"));
     connect(clip, SIGNAL(createProxy(const QString &)), this, SLOT(slotCreateProxy(const QString &)));
     connect(clip, SIGNAL(abortProxy(const QString &, const QString &)), this, SLOT(slotAbortProxy(const QString, const QString)));
@@ -1598,10 +1614,16 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, QStr
 QString ProjectList::getExtensions()
 {
     // Build list of mime types
-    QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain"
-                            << "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime" << "video/webm"
-                            << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "audio/x-aiff" << "audio/aiff" << "application/ogg" << "application/mxf" << "application/x-shockwave-flash"
-                            << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
+    QStringList mimeTypes = QStringList() << "application/x-kdenlive" << "application/x-kdenlivetitle" << "video/mlt-playlist" << "text/plain";
+
+    // Video mimes
+    mimeTypes <<  "video/x-flv" << "application/vnd.rn-realmedia" << "video/x-dv" << "video/dv" << "video/x-msvideo" << "video/x-matroska" << "video/mpeg" << "video/ogg" << "video/x-ms-wmv" << "video/mp4" << "video/quicktime" << "video/webm" << "video/3gpp";
+
+    // Audio mimes
+    mimeTypes << "audio/x-flac" << "audio/x-matroska" << "audio/mp4" << "audio/mpeg" << "audio/x-mp3" << "audio/ogg" << "audio/x-wav" << "audio/x-aiff" << "audio/aiff" << "application/ogg" << "application/mxf" << "application/x-shockwave-flash" << "audio/ac3";
+
+    // Image mimes
+    mimeTypes << "image/gif" << "image/jpeg" << "image/png" << "image/x-tga" << "image/x-bmp" << "image/svg+xml" << "image/tiff" << "image/x-xcf" << "image/x-xcf-gimp" << "image/x-vnd.adobe.photoshop" << "image/x-pcx" << "image/x-exr";
 
     QString allExtensions;
     foreach(const QString & mimeType, mimeTypes) {
@@ -2110,6 +2132,7 @@ void ProjectList::slotRefreshClipThumbnail(QTreeWidgetItem *it, bool update)
 void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace)
 {
     QString toReload;
+    kDebug()<<"// CLIP LOADED 1;";
     ProjectItem *item = getItemById(clipId);
     int queue = m_render->processingItems();
     if (item && producer) {
@@ -2167,6 +2190,7 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
     if (queue == 0) {
         monitorItemEditing(true);
         if (item && m_thumbnailQueue.isEmpty()) {
+           kDebug()<<"// CLIP LOADED;";
             if (!item->hasProxy() || m_render->activeClipId() == item->clipId())
                 m_listView->setCurrentItem(item);
             bool updatedProfile = false;
@@ -3287,14 +3311,11 @@ void ProjectList::slotUpdateJobStatus(ProjectItem *item, int type, int status, c
     item->setJobStatus((JOBTYPE) type, (CLIPJOBSTATUS) status);
     if (status != JOBCRASHED) return;
 #if KDE_IS_VERSION(4,7,0)
-    m_infoMessage->animatedHide();
-    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 (m_infoMessage->isHidden()) {
+       m_infoMessage->setText(label);
+       m_infoMessage->setWordWrap(m_infoMessage->text().length() > 35);
+       m_infoMessage->setMessageType(KMessageWidget::Warning);
     }
     
     if (!actionName.isEmpty()) {
@@ -3305,27 +3326,47 @@ void ProjectList::slotUpdateJobStatus(ProjectItem *item, int type, int status, c
             action = coll->action(actionName);
             if (action) break;
         }
-        if (action) m_infoMessage->addAction(action);
+        if (action && !actions.contains(action)) m_infoMessage->addAction(action);
     }
     if (!details.isEmpty()) {
-        m_errorLog = details;
-        m_infoMessage->addAction(m_logAction);
+        m_errorLog.append(details);
+        if (!actions.contains(m_logAction)) m_infoMessage->addAction(m_logAction);
     }
     m_infoMessage->animatedShow();
+#else
+    // warning for KDE < 4.7
+    KPassivePopup *passivePop = new KPassivePopup( this );
+    passivePop->setAutoDelete(true);
+    connect(passivePop, SIGNAL(clicked()), this, SLOT(slotClosePopup()));
+    m_errorLog.append(details);
+    KVBox *vb = new KVBox( passivePop );
+    KHBox *vh1 = new KHBox( vb );
+    KIcon icon("dialog-warning");
+    QLabel *iconLabel = new QLabel(vh1);
+    iconLabel->setPixmap(icon.pixmap(m_listView->iconSize()));
+    (void) new QLabel( label, vh1);
+    KHBox *box = new KHBox( vb );
+    QPushButton *but = new QPushButton( "Show log", box );
+    connect(but, SIGNAL(clicked(bool)), this, SLOT(slotShowJobLog()));
+
+    passivePop->setView( vb );
+    passivePop->show();
+    
 #endif
 }
 
 void ProjectList::slotShowJobLog()
 {
-#if KDE_IS_VERSION(4,7,0)
     KDialog d(this);
     d.setButtons(KDialog::Close);
     QTextEdit t(&d);
-    t.setPlainText(m_errorLog);
+    for (int i = 0; i < m_errorLog.count(); i++) {
+       if (i > 0) t.insertHtml("<br><hr /><br>");
+       t.insertPlainText(m_errorLog.at(i));
+    }
     t.setReadOnly(true);
     d.setMainWidget(&t);
     d.exec();
-#endif
 }
 
 QStringList ProjectList::getPendingJobs(const QString &id)
@@ -3466,4 +3507,20 @@ void ProjectList::updatePalette()
     m_listView->updateStyleSheet();
 }
 
+void ProjectList::slotResetInfoMessage()
+{
+#if KDE_IS_VERSION(4,7,0)
+    m_errorLog.clear();
+    QList<QAction *> actions = m_infoMessage->actions();
+    for (int i = 0; i < actions.count(); i++) {
+       m_infoMessage->removeAction(actions.at(i));
+    }
+#endif
+}
+
+void ProjectList::slotClosePopup()
+{
+    m_errorLog.clear();
+}
+
 #include "projectlist.moc"