From: Jean-Baptiste Mardelle Date: Mon, 9 May 2011 23:09:06 +0000 (+0000) Subject: Show progress when archiving compressed project X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=34d730a4cfff25e2481ff7a6d16cc68f99f8ce3b;p=kdenlive Show progress when archiving compressed project svn path=/trunk/kdenlive/; revision=5579 --- diff --git a/src/archivewidget.cpp b/src/archivewidget.cpp index 7e3c60dd..a7830bed 100644 --- a/src/archivewidget.cpp +++ b/src/archivewidget.cpp @@ -50,6 +50,7 @@ ArchiveWidget::ArchiveWidget(QString projectName, QDomDocument doc, QList setUrl(KUrl(QDir::homePath())); connect(archive_url, SIGNAL(textChanged (const QString &)), this, SLOT(slotCheckSpace())); connect(this, SIGNAL(archivingFinished(bool)), this, SLOT(slotArchivingFinished(bool))); + connect(this, SIGNAL(archiveProgress(int)), this, SLOT(slotArchivingProgress(int))); // Setup categories QTreeWidgetItem *videos = new QTreeWidgetItem(files_list, QStringList() << i18n("Video clips")); @@ -308,10 +309,6 @@ bool ArchiveWidget::slotStartArchiving(bool firstPass) repaint(); archive_url->setEnabled(false); compressed_archive->setEnabled(false); - m_progressTimer = new QTimer(this); - connect(m_progressTimer, SIGNAL(timeout()), this, SLOT(updateProgress())); - m_progressTimer->setSingleShot(false); - m_progressTimer->setInterval(700); } KUrl::List files; KUrl destUrl; @@ -535,7 +532,6 @@ bool ArchiveWidget::processProjectFile() m_temp->write(m_doc.toString().toUtf8()); m_temp->close(); m_archiveThread = QtConcurrent::run(this, &ArchiveWidget::createArchive); - m_progressTimer->start(); return true; } @@ -562,19 +558,22 @@ void ArchiveWidget::createArchive() QFileInfo dirInfo(archive_url->url().path()); QString user = dirInfo.owner(); QString group = dirInfo.group(); - KTar archive(archive_url->url().path(KUrl::AddTrailingSlash) + m_name + ".tar.gz"); + KTar archive(archive_url->url().path(KUrl::AddTrailingSlash) + m_name + ".tar.gz", "application/x-gzip"); archive.open( QIODevice::WriteOnly ); - kDebug()<<"ARCHIVE: "< i(m_filesList); while (i.hasNext()) { i.next(); archive.addLocalFile(i.key(), i.value()); + emit archiveProgress((int) 100 * ix / m_filesList.count()); + ix++; } // Add project file @@ -594,6 +593,7 @@ void ArchiveWidget::slotArchivingFinished(bool result) icon_info->setPixmap(KIcon("dialog-close").pixmap(16, 16)); text_info->setText(i18n("There was an error processing project file")); } + progressBar->setValue(100); buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive")); archive_url->setEnabled(true); compressed_archive->setEnabled(true); @@ -602,10 +602,9 @@ void ArchiveWidget::slotArchivingFinished(bool result) for (int j = 0; j < files_list->topLevelItem(i)->childCount(); j++) files_list->topLevelItem(i)->child(j)->setDisabled(false); } - m_progressTimer->stop(); } -void ArchiveWidget::updateProgress() +void ArchiveWidget::slotArchivingProgress(int p) { - int process = 100; + progressBar->setValue(p); } diff --git a/src/archivewidget.h b/src/archivewidget.h index 90b64d67..4ca08ec0 100644 --- a/src/archivewidget.h +++ b/src/archivewidget.h @@ -57,7 +57,7 @@ private slots: virtual void done ( int r ); bool closeAccepted(); void createArchive(); - void updateProgress(); + void slotArchivingProgress(int); void slotArchivingFinished(bool result); protected: @@ -75,7 +75,6 @@ private: QFuture m_archiveThread; QStringList m_foldersList; QMap m_filesList; - QTimer *m_progressTimer; /** @brief Generate tree widget subitems from a string list of urls. */ void generateItems(QTreeWidgetItem *parentItem, QStringList items); @@ -84,6 +83,7 @@ private: signals: void archivingFinished(bool); + void archiveProgress(int); };