]> git.sesse.net Git - kdenlive/commitdiff
improve feedback to user when loading a document
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 28 Sep 2009 11:59:35 +0000 (11:59 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 28 Sep 2009 11:59:35 +0000 (11:59 +0000)
svn path=/trunk/kdenlive/; revision=3956

src/kdenlivedoc.cpp
src/mainwindow.cpp
src/mainwindow.h
src/projectlist.cpp

index bf96d7154fa7d3bb65502b36681842bc9558476e..0c927b71a3d3ba9319aa7a1f62c9035e50e489af 100644 (file)
@@ -85,10 +85,13 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
             if (!success) // It is corrupted
                 KMessageBox::error(parent, errorMsg);
             else {
+                parent->slotGotProgressInfo(i18n("Validating file %1", m_url.path()), 0);
                 DocumentValidator validator(m_document);
                 success = validator.isProject();
-                if (!success) // It is not a project file
-                    parent->slotGotProgressInfo(i18n("File %1 is not a Kdenlive project file.", m_url.path()), 100);
+                if (!success) {
+                    // It is not a project file
+                    parent->slotGotProgressInfo(i18n("File %1 is not a Kdenlive project file.", m_url.path()), 0);
+                }
                 else {
                     /*
                      * Validate the file against the current version (upgrade
@@ -97,6 +100,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                     // TODO: backup the document or alert the user?
                     success = validator.validate(DOCUMENTVERSION);
                     if (success) { // Let the validator handle error messages
+                        parent->slotGotProgressInfo(i18n("Loading file %1", m_url.path()), 0);
                         QDomElement mlt = m_document.firstChildElement("mlt");
                         QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
 
@@ -134,25 +138,25 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                         const int max = producers.count();
                         const int infomax = infoproducers.count();
 
-                        QDomNodeList folders = m_document.elementsByTagName("folder");
+                        QDomNodeList                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    folders = m_document.elementsByTagName("folder");
                         for (int i = 0; i < folders.count(); i++) {
                             e = folders.item(i).cloneNode().toElement();
                             m_clipManager->addFolder(e.attribute("id"), e.attribute("name"));
                         }
 
-                        if (max > 0) {
+                        /*if (max > 0) {
                             m_documentLoadingStep = 100.0 / (max + infomax + m_document.elementsByTagName("entry").count());
                             parent->slotGotProgressInfo(i18n("Loading project clips"), (int) m_documentLoadingProgress);
-                        }
+                        }*/
 
 
                         for (int i = 0; i < infomax && !m_abortLoading; i++) {
                             e = infoproducers.item(i).cloneNode().toElement();
-                            if (m_documentLoadingStep > 0) {
+                            /*if (m_documentLoadingStep > 0) {
                                 m_documentLoadingProgress += m_documentLoadingStep;
                                 parent->slotGotProgressInfo(QString(), (int) m_documentLoadingProgress);
-                                //qApp->processEvents();
-                            }
+                                // QApp->processEvents();
+                            }*/
                             QString prodId = e.attribute("id");
                             if (!e.isNull() && prodId != "black" && !prodId.startsWith("slowmotion") && !m_abortLoading) {
                                 e.setTagName("producer");
index 5c2f461ea2acbd4727b9afbef6fadac24b5dbc71..e50ab6b3892064235656941c28263fb2b1ff4a29 100644 (file)
@@ -372,13 +372,13 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
     // precedence, then "openlastproject", then just a plain empty file.
     // If opening Url fails, openlastproject will _not_ be used.
     if (!Url.isEmpty()) {
-        openFile(Url);
-    } else {
-        if (KdenliveSettings::openlastproject()) {
-            openLastFile();
-        }
+        // delay loading so that the window shows up
+        m_startUrl = Url;
+        QTimer::singleShot(500, this, SLOT(openFile()));
+    } else if (KdenliveSettings::openlastproject()) {
+        QTimer::singleShot(500, this, SLOT(openLastFile()));
     }
-    if (m_timelineArea->count() == 0) {
+    else { //if (m_timelineArea->count() == 0) {
         newFile(false);
     }
 
@@ -1400,6 +1400,11 @@ bool MainWindow::saveFile()
 
 void MainWindow::openFile()
 {
+    if (!m_startUrl.isEmpty()) {
+        openFile(m_startUrl);
+        m_startUrl = KUrl();
+        return;
+    }
     // Check that the Kdenlive mime type is correctly installed
     QString mimetype = "application/x-kdenlive";
     KMimeType::Ptr mime = KMimeType::mimeType(mimetype);
@@ -1457,6 +1462,8 @@ void MainWindow::openFile(const KUrl &url)
         }
     }
     if (!KdenliveSettings::activatetabs()) closeCurrentDocument();
+    m_messageLabel->setMessage(i18n("Opening file %1", url.path()), InformationMessage);
+    qApp->processEvents();
     doOpenFile(url, NULL);
 }
 
index 85d9863eeb557501e17ed2da809e28f4fbf1dfd0..4be462681417e46fbd4a4a8922787b2323787906 100644 (file)
@@ -143,6 +143,7 @@ private:
     QMenu *m_timelineContextMenu;
     QMenu *m_timelineContextClipMenu;
     QMenu *m_timelineContextTransitionMenu;
+    KUrl m_startUrl;
 
     /**
      * Shortcut to remove the focus of any element. Allows to get out
index 99cc712b80333f45da96d72ba205efd3417a4eaa..fe503c87f85f67f8cc00d65f97f725054c4da1d0 100644 (file)
@@ -611,8 +611,7 @@ void ProjectList::slotProcessNextClipInQueue()
         m_infoQueue.remove(j.key());
         emit getFileProperties(dom, id, false);
     }
-
-    if (!m_infoQueue.isEmpty() && !m_queueTimer.isActive()) m_queueTimer.start();
+    //if (!m_infoQueue.isEmpty() && !m_queueTimer.isActive()) m_queueTimer.start();
 }
 
 void ProjectList::slotUpdateClip(const QString &id)
@@ -888,8 +887,7 @@ void ProjectList::slotProcessNextThumbnail()
     }
     slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
     if (m_thumbnailQueue.count() > 1) {
-        emit displayMessage(i18n("Loading clips (%1)", m_thumbnailQueue.count()), InformationMessage);
-        qApp->processEvents();
+        emit displayMessage(i18n("Loading thumbnails (%1)", m_thumbnailQueue.count()), InformationMessage);
     }
 }
 
@@ -921,7 +919,7 @@ void ProjectList::slotRefreshClipThumbnail(ProjectItem *item, bool update)
             m_doc->cachePixmap(item->getClipHash(), pix);
         }
         if (update) emit projectModified();
-        QTimer::singleShot(100, this, SLOT(slotProcessNextThumbnail()));
+        QTimer::singleShot(30, this, SLOT(slotProcessNextThumbnail()));
     }
 }
 
@@ -949,8 +947,10 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             requestClipThumbnail(clipId);
         }
     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
-
-    slotProcessNextClipInQueue();
+    emit displayMessage(i18n("Loading clips (%1)", m_infoQueue.count()), InformationMessage);
+    
+    // small delay so that the app can display the progress info
+    QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
 }
 
 void ProjectList::slotReplyGetImage(const QString &clipId, const QPixmap &pix)