From: Jean-Baptiste Mardelle Date: Tue, 3 May 2011 19:49:17 +0000 (+0000) Subject: New feature: Archive project (in progress) X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4ea740d89bef3af2870a2578f252f889be897516;p=kdenlive New feature: Archive project (in progress) svn path=/trunk/kdenlive/; revision=5569 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e0a15eb4..9cb5093d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,6 +134,7 @@ kde4_add_ui_files(kdenlive_UI widgets/smconfig_ui.ui widgets/bezierspline_ui.ui widgets/monitoreditwidget_ui.ui + widgets/archivewidget_ui.ui ) set(kdenlive_SRCS @@ -280,6 +281,7 @@ set(kdenlive_SRCS simplekeyframes/simpletimelinewidget.cpp simplekeyframes/simplekeyframewidget.cpp noteswidget.cpp + archivewidget.cpp ) add_definitions(${KDE4_DEFINITIONS}) diff --git a/src/archivewidget.cpp b/src/archivewidget.cpp new file mode 100644 index 00000000..d74a8e8a --- /dev/null +++ b/src/archivewidget.cpp @@ -0,0 +1,151 @@ +/*************************************************************************** + * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#include "archivewidget.h" +#include "titlewidget.h" + +#include +#include +#include +#include + +#include +#include +#include "projectsettings.h" + + +ArchiveWidget::ArchiveWidget(QList list, QStringList lumas, QWidget * parent) : + QDialog(parent), + m_requestedSize(0), + m_copyJob(NULL) +{ + setupUi(this); + setWindowTitle(i18n("Archive Project")); + archive_url->setUrl(KUrl(QDir::homePath())); + connect(archive_url, SIGNAL(textChanged (const QString &)), this, SLOT(slotCheckSpace())); + + // process all files + QStringList allFonts; + foreach(const QString & file, lumas) { + kDebug()<<"LUMA: "<addItem(file); + m_requestedSize += QFileInfo(file).size(); + } + + for (int i = 0; i < list.count(); i++) { + DocClipBase *clip = list.at(i); + if (clip->clipType() == SLIDESHOW) { + QStringList subfiles = ProjectSettings::extractSlideshowUrls(clip->fileURL()); + foreach(const QString & file, subfiles) { + kDebug()<<"SLIDE: "<addItem(file); + m_requestedSize += QFileInfo(file).size(); + } + } else if (!clip->fileURL().isEmpty()) { + files_list->addItem(clip->fileURL().path()); + m_requestedSize += QFileInfo(clip->fileURL().path()).size(); + } + if (clip->clipType() == TEXT) { + QStringList imagefiles = TitleWidget::extractImageList(clip->getProperty("xmldata")); + QStringList fonts = TitleWidget::extractFontList(clip->getProperty("xmldata")); + foreach(const QString & file, imagefiles) { + kDebug()<<"TXT IMAGE: "<addItem(file); + m_requestedSize += QFileInfo(file).size(); + } + allFonts << fonts; + } else if (clip->clipType() == PLAYLIST) { + QStringList files = ProjectSettings::extractPlaylistUrls(clip->fileURL().path()); + foreach(const QString & file, files) { + kDebug()<<"PLAYLIST: "<addItem(file); + m_requestedSize += QFileInfo(file).size(); + } + } + } +#if QT_VERSION >= 0x040500 + allFonts.removeDuplicates(); +#endif + project_files->setText(i18n("%1 files to archive, requires %2", files_list->count(), KIO::convertSize(m_requestedSize))); + buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive")); + connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotStartArchiving())); + buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + + slotCheckSpace(); +} + +ArchiveWidget::~ArchiveWidget() +{ +} + +void ArchiveWidget::slotCheckSpace() +{ + KDiskFreeSpaceInfo inf = KDiskFreeSpaceInfo::freeSpaceInfo( archive_url->url().path()); + KIO::filesize_t freeSize = inf.available();; + if (freeSize > m_requestedSize) { + // everything is ok + buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true); + icon_info->setPixmap(KIcon("dialog-ok").pixmap(16, 16)); + text_info->setText(i18n("Available space on drive: %1", KIO::convertSize(freeSize))); + } + else { + buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + icon_info->setPixmap(KIcon("dialog-close").pixmap(16, 16)); + text_info->setText(i18n("Not enough space on drive, free space: %1", KIO::convertSize(freeSize))); + } +} + +void ArchiveWidget::slotStartArchiving() +{ + if (m_copyJob) { + // archiving in progress, abort + m_copyJob->kill(KJob::EmitResult); + return; + } + KUrl::List files; + for (int i = 0; i < files_list->count(); i++) { + if (files_list->item(i)) + files << KUrl(files_list->item(i)->text()); + } + + progressBar->setValue(0); + buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Abort")); + m_copyJob = KIO::copy (files, archive_url->url(), KIO::HideProgressInfo); + connect(m_copyJob, SIGNAL(result(KJob *)), this, SLOT(slotArchivingFinished(KJob *))); + connect(m_copyJob, SIGNAL(processedSize(KJob *, qulonglong)), this, SLOT(slotArchivingProgress(KJob *, qulonglong))); +} + +void ArchiveWidget::slotArchivingFinished(KJob *job) +{ + progressBar->setValue(100); + buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Archive")); + if (job->error() == 0) text_info->setText(i18n("Project was successfully archived.")); + else { + icon_info->setPixmap(KIcon("dialog-close").pixmap(16, 16)); + text_info->setText(i18n("There was an error while copying the files: %1", job->errorString())); + } + m_copyJob = NULL; +} + +void ArchiveWidget::slotArchivingProgress(KJob *, qulonglong size) +{ + progressBar->setValue((int) 100 * size / m_requestedSize); +} + diff --git a/src/archivewidget.h b/src/archivewidget.h new file mode 100644 index 00000000..bbaf23c1 --- /dev/null +++ b/src/archivewidget.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef ARCHIVEWIDGET_H +#define ARCHIVEWIDGET_H + + +#include "ui_archivewidget_ui.h" +#include "docclipbase.h" + +#include +#include +#include +#include +#include +#include + +class KJob; + +/** + * @class ArchiveWidget + * @brief A widget allowing to archive a project (copy all project files to a new location) + * @author Jean-Baptiste Mardelle + */ + +class ArchiveWidget : public QDialog, public Ui::ArchiveWidget_UI +{ + Q_OBJECT + +public: + ArchiveWidget(QList list, QStringList lumas, QWidget * parent = 0); + ~ArchiveWidget(); + +private slots: + void slotCheckSpace(); + void slotStartArchiving(); + void slotArchivingFinished(KJob *job); + void slotArchivingProgress(KJob *, qulonglong); + +private: + KIO::filesize_t m_requestedSize; + KIO::CopyJob *m_copyJob; + +signals: + +}; + + +#endif + diff --git a/src/kdenliveui.rc b/src/kdenliveui.rc index c0fb9ba2..5a7eb602 100644 --- a/src/kdenliveui.rc +++ b/src/kdenliveui.rc @@ -1,6 +1,6 @@ - + Extra Toolbar @@ -10,6 +10,7 @@ + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1e18d029..a02d12a4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -61,6 +61,7 @@ #include "colorscopes/histogram.h" #include "audiospectrum.h" #include "spectrogram.h" +#include "archivewidget.h" #include #include @@ -1206,6 +1207,11 @@ void MainWindow::setupActions() collection.addAction("transcode_clip", transcodeClip); connect(transcodeClip, SIGNAL(triggered(bool)), this, SLOT(slotTranscodeClip())); + KAction *archiveProject = new KAction(KIcon("file-save"), i18n("Archive Project"), this); + collection.addAction("archive_project", archiveProject); + connect(archiveProject, SIGNAL(triggered(bool)), this, SLOT(slotArchiveProject())); + + KAction *markIn = collection.addAction("mark_in"); markIn->setText(i18n("Set Zone In")); markIn->setShortcut(Qt::Key_I); @@ -4240,6 +4246,14 @@ void MainWindow::slotInsertNotesTimecode() m_notesWidget->insertHtml("" + position + " "); } +void MainWindow::slotArchiveProject() +{ + QList list = m_projectList->documentClipList(); + ArchiveWidget *d = new ArchiveWidget(list, m_activeTimeline->projectView()->extractTransitionsLumas(), this); + d->exec(); +} + + #include "mainwindow.moc" #ifdef DEBUG_MAINW diff --git a/src/mainwindow.h b/src/mainwindow.h index 778b8777..6d26e393 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -474,6 +474,8 @@ private slots: void slotMaximizeCurrent(bool show); void slotTranscode(KUrl::List urls = KUrl::List()); void slotTranscodeClip(); + /** @brief Archive project: creates a copy of the project file with all clips in a new folder. */ + void slotArchiveProject(); void slotSetDocumentRenderProfile(QMap props); void slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile); diff --git a/src/widgets/archivewidget_ui.ui b/src/widgets/archivewidget_ui.ui new file mode 100644 index 00000000..23b5bfd3 --- /dev/null +++ b/src/widgets/archivewidget_ui.ui @@ -0,0 +1,130 @@ + + + ArchiveWidget_UI + + + + 0 + 0 + 320 + 220 + + + + Dialog + + + + + + + + Archive folder + + + + + + + KFile::Directory + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Apply|QDialogButtonBox::Close + + + + + + + + KUrlRequester + QFrame +
kurlrequester.h
+
+
+ + + + buttonBox + accepted() + ArchiveWidget_UI + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ArchiveWidget_UI + reject() + + + 316 + 260 + + + 286 + 274 + + + + +