]> git.sesse.net Git - kdenlive/commitdiff
reindent + nice (working) progress bar for document loading
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 28 Sep 2009 18:50:26 +0000 (18:50 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 28 Sep 2009 18:50:26 +0000 (18:50 +0000)
svn path=/trunk/kdenlive/; revision=3960

14 files changed:
src/abstractgroupitem.cpp
src/clipmanager.cpp
src/clipmanager.h
src/customtrackview.cpp
src/docclipbase.cpp
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h
src/recmonitor.cpp
src/statusbarmessagelabel.cpp
src/trackview.cpp
src/wizard.cpp

index 642f50f6d2f97c37a7ef08ef00bcc2d89928a8aa..aed9c10837da7393ee33ca90ba8891723d678511 100644 (file)
@@ -200,7 +200,7 @@ QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant
         for (int i = 0; i < children.count(); i++) {
             collindingItems.removeAll(children.at(i));
         }
-        
+
         if (!collindingItems.isEmpty()) {
             bool forwardMove = xpos > start.x();
             int offset = 0;
index 0e8133f459a33dea7f56ce6d66a6091741c403e8..874a0287fa1a5de5fea996dfe9efceefdddcd563 100644 (file)
@@ -519,3 +519,9 @@ void ClipManager::slotClipModified(const QString &path)
     }
 }
 
+int ClipManager::clipsCount() const
+{
+    return m_clipList.count();
+}
+
+
index 470de23d7f236aba6e7c23b11c7ac7e5a927007d..09d2c2c08c0cedf691c6648cba4e13a2070e78f6 100644 (file)
@@ -83,6 +83,7 @@ Q_OBJECT public:
     AbstractGroupItem *createGroup();
     void removeGroup(AbstractGroupItem *group);
     QDomElement groupsXml() const;
+    int clipsCount() const;
 
 public slots:
     void updatePreviewSettings();
index f20332332493c07d56a8bbb8ce3821993f5946cd..c65d3b91001bf2c4738c96c7d5757bb4ed8e6e2c 100644 (file)
@@ -417,7 +417,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                     }
                 }
             }
-            
+
             if (!collision)
                 m_selectionGroup->translate(snappedPos - m_selectionGroup->sceneBoundingRect().left(), 0);
             //m_selectionGroup->setPos(mappedXPos + (((int) m_selectionGroup->boundingRect().topLeft().x() + 0.5) - mappedClick) , m_selectionGroup->pos().y());
@@ -1054,8 +1054,7 @@ void CustomTrackView::groupSelectedItems(bool force, bool createNewGroup)
     for (int i = 0; i < selection.count(); i++) {
         if (selection.at(i)->parentItem() == 0 && (selection.at(i)->type() == AVWIDGET || selection.at(i)->type() == TRANSITIONWIDGET || selection.at(i)->type() == GROUPWIDGET)) {
             rectUnion = rectUnion.united(selection.at(i)->sceneBoundingRect());
-        }
-        else if (selection.at(i)->parentItem()) {
+        } else if (selection.at(i)->parentItem()) {
             rectUnion = rectUnion.united(selection.at(i)->parentItem()->sceneBoundingRect());
         }
     }
@@ -2274,7 +2273,7 @@ void CustomTrackView::slotRemoveSpace()
 
     // Make sure there is no group in the way
     QRectF rect(pos.frames(m_document->fps()), track * m_tracksHeight + m_tracksHeight / 2, sceneRect().width() - pos.frames(m_document->fps()), m_tracksHeight / 2 - 2);
-    
+
     bool isOk;
     QList<QGraphicsItem *> items = checkForGroups(rect, isOk);
     if (!isOk) {
index 3221ef8ee9ed68795318f8348f70325980016c35..2669a878673f0f6db43592e300599f5d09f4b3cc 100644 (file)
@@ -451,7 +451,6 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
         deleteProducers();
     }
     QString id = producer->get("id");
-    kDebug() << "// set prod: " << id;
     if (id.contains('_')) {
         // this is a subtrack producer, insert it at correct place
         id = id.section('_', 1);
index 0c927b71a3d3ba9319aa7a1f62c9035e50e489af..632af1444bb0189840f2939084e9371ab6090e1f 100644 (file)
@@ -55,8 +55,6 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
         m_commandStack(new QUndoStack(undoGroup)),
         m_modified(false),
         m_projectFolder(projectFolder),
-        m_documentLoadingStep(0.0),
-        m_documentLoadingProgress(0),
         m_abortLoading(false)
 {
     m_clipManager = new ClipManager(this);
@@ -85,14 +83,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);
+                parent->slotGotProgressInfo(i18n("Validating"), 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()), 0);
-                }
-                else {
+                    parent->slotGotProgressInfo(i18n("File %1 is not a Kdenlive project file", m_url.path()), 0);
+                } else {
                     /*
                      * Validate the file against the current version (upgrade
                      * and recover it if needed). It is NOT a passive operation
@@ -100,7 +97,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);
+                        parent->slotGotProgressInfo(i18n("Loading"), 0);
                         QDomElement mlt = m_document.firstChildElement("mlt");
                         QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
 
@@ -134,6 +131,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                         }
                         QDomNodeList producers = m_document.elementsByTagName("producer");
                         QDomNodeList infoproducers = m_document.elementsByTagName("kdenlive_producer");
+                        parent->slotGotProgressInfo(i18n("Check missing clips"), 0);
                         if (checkDocumentClips(infoproducers) == false) m_abortLoading = true;
                         const int max = producers.count();
                         const int infomax = infoproducers.count();
@@ -144,19 +142,8 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                             m_clipManager->addFolder(e.attribute("id"), e.attribute("name"));
                         }
 
-                        /*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) {
-                                m_documentLoadingProgress += m_documentLoadingStep;
-                                parent->slotGotProgressInfo(QString(), (int) m_documentLoadingProgress);
-                                // QApp->processEvents();
-                            }*/
                             QString prodId = e.attribute("id");
                             if (!e.isNull() && prodId != "black" && !prodId.startsWith("slowmotion") && !m_abortLoading) {
                                 e.setTagName("producer");
@@ -724,12 +711,6 @@ void KdenliveDoc::setThumbsProgress(const QString &message, int progress)
     emit progressInfo(message, progress);
 }
 
-void KdenliveDoc::loadingProgressed()
-{
-    m_documentLoadingProgress += m_documentLoadingStep;
-    emit progressInfo(QString(), (int) m_documentLoadingProgress);
-}
-
 QUndoStack *KdenliveDoc::commandStack()
 {
     return m_commandStack;
index 423705444f05e6ded8e69d740225325f9f321133..06e4f7337614666f8d77ea1506e529ec49ea3bb2 100644 (file)
@@ -88,8 +88,6 @@ Q_OBJECT public:
     bool isModified() const;
     /** Returns project folder, used to store project files (titles, effects,...) */
     KUrl projectFolder() const;
-    /** Used to inform main app of the current document loading progress */
-    void loadingProgressed();
     void syncGuides(QList <Guide *> guides);
     void setZoom(int horizontal, int vertical);
     QPoint zoom() const;
@@ -134,8 +132,6 @@ private:
     bool m_modified;
     /** Project folder, used to store project files (titles, effects,...) */
     KUrl m_projectFolder;
-    double m_documentLoadingStep;
-    double m_documentLoadingProgress;
     bool m_abortLoading;
     QMap <QString, QString> m_documentProperties;
 
index e50ab6b3892064235656941c28263fb2b1ff4a29..1d9267991dd3c0ddeb698fa36757e7a46ab86e2c 100644 (file)
@@ -377,8 +377,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent
         QTimer::singleShot(500, this, SLOT(openFile()));
     } else if (KdenliveSettings::openlastproject()) {
         QTimer::singleShot(500, this, SLOT(openLastFile()));
-    }
-    else { //if (m_timelineArea->count() == 0) {
+    } else { //if (m_timelineArea->count() == 0) {
         newFile(false);
     }
 
@@ -1790,7 +1789,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
             disconnect(m_activeTimeline->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
             disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
             disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs()));
-            disconnect(m_projectList, SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
+            disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
             m_effectStack->clear();
         }
         //m_activeDocument->setRenderer(NULL);
@@ -1859,7 +1858,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc)   //cha
     connect(trackView->projectView(), SIGNAL(activateDocumentMonitor()), m_projectMonitor, SLOT(activateMonitor()));
     connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int)));
     connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs()));
-    connect(m_projectList, SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
+    connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int)));
 
 
     trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup);
index fe503c87f85f67f8cc00d65f97f725054c4da1d0..45e67c85177c73cd3360ff3c47b69d6c94811270 100644 (file)
@@ -544,7 +544,6 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
         //m_render->getFileProperties(clip->toXML(), clip->getId(), true);
     }
     const QString parent = clip->getProperty("groupid");
-    kDebug() << "Adding clip with groupid: " << parent;
     ProjectItem *item = NULL;
     if (!parent.isEmpty()) {
         ProjectItem *parentitem = getFolderItemById(parent);
@@ -852,7 +851,7 @@ void ProjectList::slotCheckForEmptyQueue()
     if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
         m_refreshed = true;
         emit loadingIsOver();
-        emit displayMessage(QString(), DefaultMessage);
+        emit displayMessage(QString(), -1);
         m_listView->blockSignals(false);
         m_listView->setEnabled(true);
     } else if (!m_refreshed) QTimer::singleShot(300, this, SLOT(slotCheckForEmptyQueue()));
@@ -860,6 +859,7 @@ void ProjectList::slotCheckForEmptyQueue()
 
 void ProjectList::reloadClipThumbnails()
 {
+    kDebug() << "//////////////  RELOAD CLIPS THUMBNAILS!!!";
     m_thumbnailQueue.clear();
     QTreeWidgetItemIterator it(m_listView);
     while (*it) {
@@ -872,7 +872,7 @@ void ProjectList::reloadClipThumbnails()
 
 void ProjectList::requestClipThumbnail(const QString id)
 {
-    m_thumbnailQueue.append(id);
+    if (!m_thumbnailQueue.contains(id)) m_thumbnailQueue.append(id);
 }
 
 void ProjectList::slotProcessNextThumbnail()
@@ -885,10 +885,11 @@ void ProjectList::slotProcessNextThumbnail()
         //QTimer::singleShot(300, this, SLOT(slotProcessNextThumbnail()));
         return;
     }
-    slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
     if (m_thumbnailQueue.count() > 1) {
-        emit displayMessage(i18n("Loading thumbnails (%1)", m_thumbnailQueue.count()), InformationMessage);
+        int max = m_doc->clipManager()->clipsCount();
+        emit displayMessage(i18n("Loading thumbnails"), (int)(100 * (max - m_thumbnailQueue.count()) / max));
     }
+    slotRefreshClipThumbnail(m_thumbnailQueue.takeFirst(), false);
 }
 
 void ProjectList::slotRefreshClipThumbnail(const QString &clipId, bool update)
@@ -947,8 +948,8 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
             requestClipThumbnail(clipId);
         }
     } else kDebug() << "////////  COULD NOT FIND CLIP TO UPDATE PRPS...";
-    emit displayMessage(i18n("Loading clips (%1)", m_infoQueue.count()), InformationMessage);
-    
+    int max = m_doc->clipManager()->clipsCount();
+    emit displayMessage(i18n("Loading clips"), (int)(100 * (max - m_infoQueue.count()) / max));
     // small delay so that the app can display the progress info
     QTimer::singleShot(30, this, SLOT(slotProcessNextClipInQueue()));
 }
index d7beae4ff5a064ab487ed5d307c690272f149701..53d62900c421bef06be5d7a4989c0fc6cf35bb1a 100644 (file)
@@ -213,7 +213,7 @@ signals:
     void showClipProperties(DocClipBase *);
     void projectModified();
     void loadingIsOver();
-    void displayMessage(const QString, MessageType);
+    void displayMessage(const QString, int progress);
     void clipNameChanged(const QString, const QString);
     void refreshClip();
 };
index 4ce37fff6e30aa0df83bfc9e3e00f89322a4beb0..5671ccf4e5afa6edda6eade360d6e4bc471fb887 100644 (file)
@@ -164,8 +164,7 @@ void RecMonitor::slotUpdateCaptureFolder()
         if (device_selector->currentIndex() == FIREWIRE)
             KMessageBox::information(this, i18n("You need to disconnect and reconnect in the capture monitor to apply your changes"), i18n("Capturing"));
         else KMessageBox::information(this, i18n("You need to stop capture before your changes can be applied"), i18n("Capturing"));
-    }
-    else slotVideoDeviceChanged(device_selector->currentIndex());
+    } else slotVideoDeviceChanged(device_selector->currentIndex());
     kDebug() << "// UPDATE CAPT FOLD: " << KdenliveSettings::capturefolder();
 
 #if KDE_IS_VERSION(4,2,0)
index b7a5581257378e34924c0f98eed275b2245b7cfd..814d6ef0d05779fdbf45fad33a99b8042eb4ea43 100644 (file)
@@ -119,7 +119,12 @@ void StatusBarMessageLabel::setMessage(const QString& text,
     }
 
     m_pixmap = (iconName == 0) ? QPixmap() : SmallIcon(iconName);
-    QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
+
+    /*QFontMetrics fontMetrics(font());
+    setMaximumWidth(fontMetrics.boundingRect(m_text).width() + m_pixmap.width() + (BorderGap * 4));
+    updateGeometry();*/
+
+    //QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
     update();
 }
 
@@ -173,7 +178,7 @@ void StatusBarMessageLabel::resizeEvent(QResizeEvent* event)
 {
     QWidget::resizeEvent(event);
     updateCloseButtonPosition();
-    QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
+    //QTimer::singleShot(GeometryTimeout, this, SLOT(assureVisibleText()));
 }
 
 void StatusBarMessageLabel::timerDone()
index 6dd3824161e86fbb1368137bc5471560941ecfe6..c89075c80a1ea08898e25f84827e0c2add6160ce 100644 (file)
@@ -242,9 +242,6 @@ void TrackView::parseDocument(QDomDocument doc)
                 if (p.attribute("id") == playlist_name) break;
             }
             int black_clips = p.childNodes().count();
-            for (int i = 0; i < black_clips; i++)
-                m_doc->loadingProgressed();
-            qApp->processEvents();
             pos--;
         }
     }
@@ -505,8 +502,6 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked)
         if (elem.tagName() == "blank") {
             position += elem.attribute("length").toInt();
         } else if (elem.tagName() == "entry") {
-            m_doc->loadingProgressed();
-            qApp->processEvents();
             // Found a clip
             int in = elem.attribute("in").toInt();
             int out = elem.attribute("out").toInt();
index 3bce569ce693d71b20a0ae9f6e67f6b5f11a0713..0d396c1bc68bdd240bdd28fa428f939e6fc09cc2 100644 (file)
@@ -336,7 +336,7 @@ void Wizard::slotCheckPrograms()
     if (KStandardDirs::findExe("dvdauthor").isEmpty()) item->setIcon(0, m_badIcon);
     else item->setIcon(0, m_okIcon);
 
-    
+
     item = new QTreeWidgetItem(m_check.programList, QStringList() << QString() << i18n("genisoimage or mkisofs"));
     item->setData(1, Qt::UserRole, i18n("Required for creation of DVD ISO images"));
     item->setSizeHint(0, itemSize);
@@ -344,10 +344,8 @@ void Wizard::slotCheckPrograms()
         // no GenIso, check for mkisofs
         if (!KStandardDirs::findExe("mkisofs").isEmpty()) {
             item->setIcon(0, m_okIcon);
-        }
-        else item->setIcon(0, m_badIcon);
-    }
-    else item->setIcon(0, m_okIcon);
+        } else item->setIcon(0, m_badIcon);
+    } else item->setIcon(0, m_okIcon);
 
     // set up some default applications
     QString program;