From: Jean-Baptiste Mardelle Date: Mon, 28 Sep 2009 18:50:26 +0000 (+0000) Subject: reindent + nice (working) progress bar for document loading X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=fec4b6aba639dac658d35475512c6f232c8aebe3;p=kdenlive reindent + nice (working) progress bar for document loading svn path=/trunk/kdenlive/; revision=3960 --- diff --git a/src/abstractgroupitem.cpp b/src/abstractgroupitem.cpp index 642f50f6..aed9c108 100644 --- a/src/abstractgroupitem.cpp +++ b/src/abstractgroupitem.cpp @@ -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; diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index 0e8133f4..874a0287 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -519,3 +519,9 @@ void ClipManager::slotClipModified(const QString &path) } } +int ClipManager::clipsCount() const +{ + return m_clipList.count(); +} + + diff --git a/src/clipmanager.h b/src/clipmanager.h index 470de23d..09d2c2c0 100644 --- a/src/clipmanager.h +++ b/src/clipmanager.h @@ -83,6 +83,7 @@ Q_OBJECT public: AbstractGroupItem *createGroup(); void removeGroup(AbstractGroupItem *group); QDomElement groupsXml() const; + int clipsCount() const; public slots: void updatePreviewSettings(); diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index f2033233..c65d3b91 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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 items = checkForGroups(rect, isOk); if (!isOk) { diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 3221ef8e..2669a878 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -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); diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 0c927b71..632af144 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -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; diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 42370544..06e4f733 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -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 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 m_documentProperties; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e50ab6b3..1d926799 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index fe503c87..45e67c85 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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())); } diff --git a/src/projectlist.h b/src/projectlist.h index d7beae4f..53d62900 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -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(); }; diff --git a/src/recmonitor.cpp b/src/recmonitor.cpp index 4ce37fff..5671ccf4 100644 --- a/src/recmonitor.cpp +++ b/src/recmonitor.cpp @@ -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) diff --git a/src/statusbarmessagelabel.cpp b/src/statusbarmessagelabel.cpp index b7a55812..814d6ef0 100644 --- a/src/statusbarmessagelabel.cpp +++ b/src/statusbarmessagelabel.cpp @@ -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() diff --git a/src/trackview.cpp b/src/trackview.cpp index 6dd38241..c89075c8 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -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(); diff --git a/src/wizard.cpp b/src/wizard.cpp index 3bce569c..0d396c1b 100644 --- a/src/wizard.cpp +++ b/src/wizard.cpp @@ -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;