From eb9f7923ad07e099949a76d57bd6fc2c2719ee86 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 26 May 2008 10:52:47 +0000 Subject: [PATCH] Display some progress info when opening document svn path=/branches/KDE4/; revision=2198 --- src/clipmanager.cpp | 4 ++-- src/clipmanager.h | 2 +- src/mainwindow.cpp | 31 +++++++++++++++++++++---------- src/mainwindow.h | 3 ++- src/trackview.cpp | 15 ++++++++++++--- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index a47e6a70..7eb4145b 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -42,8 +42,8 @@ void ClipManager::checkAudioThumbs() { } } -void ClipManager::setThumbsProgress(KUrl url, int progress) { - m_doc->setThumbsProgress(url, progress); +void ClipManager::setThumbsProgress(const QString &message, int progress) { + m_doc->setThumbsProgress(message, progress); } QList ClipManager::documentClipList() { diff --git a/src/clipmanager.h b/src/clipmanager.h index 2fac528a..164d49a6 100644 --- a/src/clipmanager.h +++ b/src/clipmanager.h @@ -54,7 +54,7 @@ Q_OBJECT public: void slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, bool loop, const QString group, const int groupId); DocClipBase *getClipById(int clipId); void slotDeleteClip(uint clipId); - void setThumbsProgress(KUrl url, int progress); + void setThumbsProgress(const QString &message, int progress); void checkAudioThumbs(); QList documentClipList(); int getFreeClipId(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a45f0301..97daf70f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -572,17 +572,20 @@ void MainWindow::newFile() { } MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName); if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal"); - KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack); + KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack, this); TrackView *trackView = new TrackView(doc, this); m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description); - if (m_timelineArea->count() == 1) + if (m_timelineArea->count() == 1) { + connectDocumentInfo(doc); connectDocument(trackView, doc); + } else m_timelineArea->setTabBarHidden(false); } void MainWindow::activateDocument() { TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); KdenliveDoc *currentDoc = currentTab->document(); + connectDocumentInfo(currentDoc); connectDocument(currentTab, currentDoc); } @@ -627,7 +630,7 @@ void MainWindow::saveFile() { } void MainWindow::openFile() { //changed - KUrl url = KFileDialog::getOpenUrl(KUrl(), "application/vnd.kde.kdenlive;*.kdenlive"); + KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlive|Kdenlive project files (*.kdenlive)\n*.westley|MLT project files (*.westley)"); if (url.isEmpty()) return; m_fileOpenRecent->addUrl(url); openFile(url); @@ -637,11 +640,13 @@ void MainWindow::openFile(const KUrl &url) { //new //TODO: get video profile from url before opening it MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile()); if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal"); - KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack); + KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack, this); + connectDocumentInfo(doc); TrackView *trackView = new TrackView(doc, this); m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description())); m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path()); if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false); + slotGotProgressInfo(QString(), -1); //connectDocument(trackView, doc); } @@ -780,6 +785,14 @@ void MainWindow::slotUpdateDocumentState(bool modified) { } } +void MainWindow::connectDocumentInfo(KdenliveDoc *doc) { + if (m_activeDocument) { + if (m_activeDocument == doc) return; + disconnect(m_activeDocument, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int))); + } + connect(doc, SIGNAL(progressInfo(const QString &, int)), this, SLOT(slotGotProgressInfo(const QString &, int))); +} + void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //changed //m_projectMonitor->stop(); kDebug() << "/////////////////// CONNECTING DOC TO PROJECT VIEW ////////////////"; @@ -795,7 +808,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int))); disconnect(m_activeDocument, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int))); disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int))); - disconnect(m_activeDocument, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int))); disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*))); disconnect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView())); disconnect(m_activeTimeline, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*))); @@ -828,7 +840,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha connect(doc, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int))); connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int))); - connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int))); connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool))); @@ -986,13 +997,13 @@ void MainWindow::slotFitZoom() { } } -void MainWindow::slotGotProgressInfo(KUrl url, int progress) { +void MainWindow::slotGotProgressInfo(const QString &message, int progress) { statusProgressBar->setValue(progress); - if (progress > 0) { - statusLabel->setText(tr("Creating Audio Thumbs")); + if (progress >= 0) { + if (!message.isEmpty()) statusLabel->setText(message); statusProgressBar->setVisible(true); } else { - statusLabel->setText(""); + statusLabel->setText(QString()); statusProgressBar->setVisible(false); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index ee58677a..78c56391 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -131,9 +131,11 @@ private: void saveOptions(); void activateShuttleDevice(); void slotShuttleAction(int code); + void connectDocumentInfo(KdenliveDoc *doc); public slots: void openFile(const KUrl &url); + void slotGotProgressInfo(const QString &message, int progress); private slots: void newFile(); @@ -156,7 +158,6 @@ private slots: void slotEditProfiles(); void slotEditProjectSettings(); void slotDisplayActionMessage(QAction *a); - void slotGotProgressInfo(KUrl url, int progress); void slotSwitchVideoThumbs(); void slotSwitchAudioThumbs(); void slotSwitchMarkersComments(); diff --git a/src/trackview.cpp b/src/trackview.cpp index 8117e5eb..9c45abbd 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -136,8 +136,9 @@ void TrackView::parseDocument(QDomDocument doc) { QDomElement e; QDomElement p; bool videotrack; - kDebug() << "//////////// TIMELINE FOUND: " << m_projectTracks << " tracks"; + int pos = m_projectTracks - 1; + for (int i = 0; i < m_projectTracks; i++) { e = tracks.item(i).toElement(); QString playlist_name = e.attribute("producer"); @@ -153,10 +154,16 @@ void TrackView::parseDocument(QDomDocument doc) { pos--; kDebug() << " PRO DUR: " << trackduration << ", TRACK DUR: " << duration; if (trackduration > duration) duration = trackduration; - } else pos--; + } else { + // background black track + int black_clips = e.childNodes().count(); + for (int i = 0; i < black_clips; i++) + m_doc->loadingProgressed(); + qApp->processEvents(); + pos--; + } } - // parse transitions QDomNodeList transitions = doc.elementsByTagName("transition"); int projectTransitions = transitions.count(); @@ -283,6 +290,8 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool videotrack) { 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 id = elem.attribute("producer").toInt(); -- 2.39.2