]> git.sesse.net Git - kdenlive/commitdiff
Fix archiving sometimes not saving playlist clips & subclips:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 8 Jan 2012 19:31:12 +0000 (20:31 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 8 Jan 2012 19:31:12 +0000 (20:31 +0100)
http://kdenlive.org/mantis/view.php?id=2475

src/archivewidget.cpp
src/archivewidget.h
src/projectsettings.cpp
src/widgets/archivewidget_ui.ui

index cee0ab5468062fe8dba11887fd2141fb7486797e..e19e68c831ef86b5cde594772edf5135591b782d 100644 (file)
@@ -32,6 +32,9 @@
 #include <KDebug>
 #include <KApplication>
 #include <kio/directorysizejob.h>
+#if KDE_IS_VERSION(4,7,0)
+#include <KMessageWidget>
+#endif
 
 #include <QTreeWidget>
 #include <QtConcurrentRun>
@@ -46,7 +49,8 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
         m_doc(doc),
         m_abortArchive(false),
         m_extractMode(false),
-        m_extractArchive(NULL)
+        m_extractArchive(NULL),
+        m_missingClips(0)
 {
     setAttribute(Qt::WA_DeleteOnClose);
     setupUi(this);
@@ -77,6 +81,10 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
     texts->setIcon(0, KIcon("text-plain"));
     texts->setData(0, Qt::UserRole, "texts");
     texts->setExpanded(false);
+    QTreeWidgetItem *playlists = new QTreeWidgetItem(files_list, QStringList() << i18n("Playlist clips"));
+    playlists->setIcon(0, KIcon("video-mlt-playlist"));
+    playlists->setData(0, Qt::UserRole, "playlist");
+    playlists->setExpanded(false);
     QTreeWidgetItem *others = new QTreeWidgetItem(files_list, QStringList() << i18n("Other clips"));
     others->setIcon(0, KIcon("unknown"));
     others->setData(0, Qt::UserRole, "others");
@@ -102,6 +110,7 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
     QStringList videoUrls;
     QStringList imageUrls;
     QStringList otherUrls;
+    QStringList playlistUrls;
     QStringList proxyUrls;
 
     for (int i = 0; i < list.count(); i++) {
@@ -119,6 +128,7 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
             imageUrls << imagefiles;
             allFonts << fonts;
         } else if (t == PLAYLIST) {
+            playlistUrls << clip->fileURL().path();
             QStringList files = ProjectSettings::extractPlaylistUrls(clip->fileURL().path());
             otherUrls << files;
         }
@@ -137,11 +147,33 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
     generateItems(videos, videoUrls);
     generateItems(images, imageUrls);
     generateItems(slideshows, slideUrls);
+    generateItems(playlists, playlistUrls);
     generateItems(others, otherUrls);
     generateItems(proxies, proxyUrls);
     
     allFonts.removeDuplicates();
 
+#if KDE_IS_VERSION(4,7,0)
+        m_infoMessage = new KMessageWidget(this);
+        QVBoxLayout *s =  static_cast <QVBoxLayout*> (layout());
+        s->insertWidget(5, m_infoMessage);
+        m_infoMessage->setCloseButtonVisible(false);
+        m_infoMessage->setWordWrap(true);
+        m_infoMessage->hide();
+#endif
+        
+        // missing clips, warn user
+    if (m_missingClips > 0) {
+        QString infoText = i18np("You have %1 missing clip in your project.", "You have %1 missing clips in your project.", m_missingClips);
+#if KDE_IS_VERSION(4,7,0)
+        m_infoMessage->setMessageType(KMessageWidget::Warning);
+        m_infoMessage->setText(infoText);
+        m_infoMessage->animatedShow();
+#else
+        KMessageBox::sorry(this, infoText);
+#endif
+    }
+
     //TODO: fonts
 
     // Hide unused categories, add item count
@@ -170,7 +202,7 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList <DocCl
     buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive"));
     connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotStartArchiving()));
     buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
-    
+
     slotCheckSpace();
 }
 
@@ -194,7 +226,7 @@ ArchiveWidget::ArchiveWidget(const KUrl &url, QWidget * parent):
     archive_url->setUrl(KUrl(QDir::homePath()));
     buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Extract"));
     connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotStartExtracting()));
-    buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+    buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
     adjustSize();
     m_archiveThread = QtConcurrent::run(this, &ArchiveWidget::openArchiveForExtraction);
 }
@@ -206,11 +238,24 @@ ArchiveWidget::~ArchiveWidget()
 }
 
 void ArchiveWidget::slotDisplayMessage(const QString &icon, const QString &text)
-{
+{    
     icon_info->setPixmap(KIcon(icon).pixmap(16, 16));
     text_info->setText(text);
 }
 
+void ArchiveWidget::slotJobResult(bool success, const QString &text)
+{
+#if KDE_IS_VERSION(4,7,0)
+    m_infoMessage->setMessageType(success ? KMessageWidget::Positive : KMessageWidget::Warning);
+    m_infoMessage->setText(text);
+    m_infoMessage->animatedShow();
+#else
+    if (success) icon_info->setPixmap(KIcon("dialog-ok").pixmap(16, 16));
+    else icon_info->setPixmap(KIcon("dialog-close").pixmap(16, 16));
+    text_info->setText(text);
+#endif
+}
+
 void ArchiveWidget::openArchiveForExtraction()
 {
     emit showMessage("system-run", i18n("Opening archive..."));
@@ -329,7 +374,12 @@ void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, QStringList items
             item->setData(0, Qt::UserRole, fileName);
         }
         if (!isSlideshow) {
-            m_requestedSize += QFileInfo(file).size();
+            qint64 fileSize = QFileInfo(file).size();
+            if (fileSize <= 0) {
+                item->setIcon(0, KIcon("edit-delete"));
+                m_missingClips++;
+            }
+            else m_requestedSize += fileSize;
             filesList << fileName;
         }
     }
@@ -476,16 +526,16 @@ void ArchiveWidget::slotArchivingFinished(KJob *job)
             // Archiving finished
             progressBar->setValue(100);
             if (processProjectFile()) {
-                slotDisplayMessage("dialog-ok", i18n("Project was successfully archived."));
+                slotJobResult(true, i18n("Project was successfully archived."));
             }
             else {
-                slotDisplayMessage("dialog-close", i18n("There was an error processing project file"));
+                slotJobResult(false, i18n("There was an error processing project file"));
             }
         } else processProjectFile();
     }
     else {
         m_copyJob = NULL;
-        slotDisplayMessage("dialog-close", i18n("There was an error while copying the files: %1", job->errorString()));
+        slotJobResult(false, i18n("There was an error while copying the files: %1", job->errorString()));
     }
     if (!compressed_archive->isChecked()) {
         buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive"));
@@ -666,10 +716,11 @@ void ArchiveWidget::createArchive()
 void ArchiveWidget::slotArchivingFinished(bool result)
 {
     if (result) {
-        slotDisplayMessage("dialog-ok", i18n("Project was successfully archived."));
+        slotJobResult(true, i18n("Project was successfully archived."));
+        buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
     }
     else {
-        slotDisplayMessage("dialog-close", i18n("There was an error processing project file"));
+        slotJobResult(false, i18n("There was an error processing project file"));
     }
     progressBar->setValue(100);
     buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive"));
index e76aa669255c604749797f57666629cb32a62695..82fcf392ce4bfe650d656be461853bf469dee4db 100644 (file)
 #include "docclipbase.h"
 
 #include <kio/global.h>
+#include <KIO/CopyJob>
+#include <KTemporaryFile>
+#include <kdeversion.h>
+
 #include <QLabel>
 #include <QDialog>
 #include <QList>
-#include <KIO/CopyJob>
-#include <KTemporaryFile>
+
 
 class KJob;
 class KArchive;
@@ -41,6 +44,10 @@ class KArchive;
  * @author Jean-Baptiste Mardelle
  */
 
+#if KDE_IS_VERSION(4,7,0)
+    class KMessageWidget;
+#endif
+
 class ArchiveWidget : public QDialog, public Ui::ArchiveWidget_UI
 {
     Q_OBJECT
@@ -70,6 +77,7 @@ private slots:
     void slotGotProgress(KJob*);
     void openArchiveForExtraction();
     void slotDisplayMessage(const QString &icon, const QString &text);
+    void slotJobResult(bool success, const QString &text);
 
 protected:
     virtual void closeEvent ( QCloseEvent * e );
@@ -91,6 +99,11 @@ private:
     QString m_projectName;
     QTimer *m_progressTimer;
     KArchive *m_extractArchive;
+    int m_missingClips;
+    
+#if KDE_IS_VERSION(4,7,0)
+    KMessageWidget *m_infoMessage;
+#endif
 
     /** @brief Generate tree widget subitems from a string list of urls. */
     void generateItems(QTreeWidgetItem *parentItem, QStringList items);
index 2e33ae3f4297f75b910a92da6a00c03f0e051830..ddc8d146974d5063b46f689b44f1e3b9a59d17e6 100644 (file)
@@ -255,6 +255,9 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
     QTreeWidgetItem *texts = new QTreeWidgetItem(files_list, QStringList() << i18n("Text clips"));
     texts->setIcon(0, KIcon("text-plain"));
     texts->setExpanded(true);
+    QTreeWidgetItem *playlists = new QTreeWidgetItem(files_list, QStringList() << i18n("Playlist clips"));
+    playlists->setIcon(0, KIcon("video-mlt-playlist"));
+    playlists->setExpanded(true);
     QTreeWidgetItem *others = new QTreeWidgetItem(files_list, QStringList() << i18n("Other clips"));
     others->setIcon(0, KIcon("unknown"));
     others->setExpanded(true);
@@ -285,6 +288,9 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
             case IMAGE:
                 new QTreeWidgetItem(images, QStringList() << clip->fileURL().path());
                 break;
+            case PLAYLIST:
+                new QTreeWidgetItem(playlists, QStringList() << clip->fileURL().path());
+                break;
             case UNKNOWN:
                 new QTreeWidgetItem(others, QStringList() << clip->fileURL().path());
                 break;
@@ -458,6 +464,9 @@ QStringList ProjectSettings::extractPlaylistUrls(QString path)
         QString type = EffectsList::property(e, "mlt_service");
         if (type != "colour") {
             QString url = EffectsList::property(e, "resource");
+            if (type == "framebuffer") {
+                url = url.section('?', 0, 0);
+            }
             if (!url.isEmpty()) {
                 if (!url.startsWith('/')) url.prepend(root);
                 if (url.section('.', 0, -2).endsWith("/.all")) {
index 24966d7e752a4435c6ca5cd89fc569e59e252529..94d8bc63451c5cf24012d8daf299ff2c55fd00bb 100644 (file)
@@ -6,15 +6,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>263</width>
-    <height>197</height>
+    <width>266</width>
+    <height>219</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Dialog</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0" colspan="2">
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
     <widget class="QGroupBox" name="groupBox">
      <property name="title">
       <string/>
      <property name="flat">
       <bool>true</bool>
      </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_2">
-      <property name="margin">
-       <number>0</number>
-      </property>
+     <layout class="QHBoxLayout" name="horizontalLayout">
       <item>
        <widget class="QLabel" name="label">
         <property name="text">
      </layout>
     </widget>
    </item>
-   <item row="1" column="0" colspan="2">
+   <item>
     <widget class="QCheckBox" name="compressed_archive">
      <property name="text">
       <string>Compressed archive</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="0" colspan="2">
-    <layout class="QHBoxLayout" name="horizontalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
       <widget class="QLabel" name="icon_info">
        <property name="sizePolicy">
      </item>
     </layout>
    </item>
-   <item row="3" column="0" colspan="2">
+   <item>
     <widget class="QLabel" name="project_files">
      <property name="text">
       <string/>
      </property>
     </widget>
    </item>
-   <item row="4" column="0" colspan="2">
+   <item>
     <widget class="QTreeWidget" name="files_list">
      <property name="alternatingRowColors">
       <bool>true</bool>
      </column>
     </widget>
    </item>
-   <item row="5" column="0">
-    <widget class="QProgressBar" name="progressBar">
-     <property name="value">
-      <number>0</number>
-     </property>
-    </widget>
-   </item>
-   <item row="5" column="1">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Apply|QDialogButtonBox::Close</set>
-     </property>
-    </widget>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QProgressBar" name="progressBar">
+       <property name="value">
+        <number>0</number>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Apply|QDialogButtonBox::Close</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>