+void ProjectSettings::slotDeleteUnused()
+{
+ QStringList toDelete;
+ QList <DocClipBase*> list = m_projectList->documentClipList();
+ for (int i = 0; i < list.count(); i++) {
+ DocClipBase *clip = list.at(i);
+ if (clip->numReferences() == 0 && clip->clipType() != SLIDESHOW) {
+ KUrl url = clip->fileURL();
+ if (!url.isEmpty() && !toDelete.contains(url.path())) toDelete << url.path();
+ }
+ }
+
+ // make sure our urls are not used in another clip
+ for (int i = 0; i < list.count(); i++) {
+ DocClipBase *clip = list.at(i);
+ if (clip->numReferences() > 0) {
+ KUrl url = clip->fileURL();
+ if (!url.isEmpty() && toDelete.contains(url.path())) toDelete.removeAll(url.path());
+ }
+ }
+
+ if (toDelete.count() == 0) {
+ // No physical url to delete, we only remove unused clips from project (color clips for example have no physical url)
+ if (KMessageBox::warningContinueCancel(this, i18n("This will remove all unused clips from your project."), i18n("Clean up project")) == KMessageBox::Cancel) return;
+ m_projectList->cleanup();
+ slotUpdateFiles();
+ return;
+ }
+ if (KMessageBox::warningYesNoList(this, i18n("This will remove the following files from your hard drive.\nThis action cannot be undone, only use if you know what you are doing.\nAre you sure you want to continue?"), toDelete, i18n("Delete unused clips")) != KMessageBox::Yes) return;
+ m_projectList->trashUnusedClips();
+ slotUpdateFiles();
+}
+
+void ProjectSettings::slotClearCache()
+{
+ buttonBox->setEnabled(false);
+ KIO::NetAccess::del(KUrl(project_folder->url().path(KUrl::AddTrailingSlash) + "thumbs/"), this);
+ KStandardDirs::makeDir(project_folder->url().path(KUrl::AddTrailingSlash) + "thumbs/");
+ buttonBox->setEnabled(true);
+ slotUpdateFiles(true);
+}
+
+void ProjectSettings::slotUpdateFiles(bool cacheOnly)
+{
+ KIO::DirectorySizeJob * job = KIO::directorySize(project_folder->url().path(KUrl::AddTrailingSlash) + "thumbs/");
+ job->exec();
+ thumbs_count->setText(QString::number(job->totalFiles()));
+ thumbs_size->setText(KIO::convertSize(job->totalSize()));
+ delete job;
+ if (cacheOnly) return;
+ int unused = 0;
+ int used = 0;
+ KIO::filesize_t usedSize = 0;
+ KIO::filesize_t unUsedSize = 0;
+ QList <DocClipBase*> list = m_projectList->documentClipList();
+ files_list->clear();
+
+ // List all files that are used in the project. That also means:
+ // images included in slideshow and titles, files in playlist clips
+ // TODO: images used in luma transitions, files used for LADSPA effects?
+
+ QStringList allFiles;
+ allFiles << m_lumas;
+ for (int i = 0; i < list.count(); i++) {
+ DocClipBase *clip = list.at(i);
+ if (clip->clipType() == SLIDESHOW) {
+ // special case, list all images
+ QStringList files = extractSlideshowUrls(clip->fileURL());
+ allFiles << files;
+ } else if (!clip->fileURL().isEmpty()) allFiles.append(clip->fileURL().path());
+ if (clip->clipType() == TEXT) {
+ QStringList images = TitleWidget::extractImageList(clip->getProperty("xmldata"));
+ allFiles << images;
+ } else if (clip->clipType() == PLAYLIST) {
+ QStringList files = extractPlaylistUrls(clip->fileURL().path());
+ allFiles << files;
+ }
+
+ if (clip->numReferences() == 0) {
+ unused++;
+ unUsedSize += clip->fileSize();
+ } else {
+ used++;
+ usedSize += clip->fileSize();
+ }
+ }
+#if QT_VERSION >= 0x040500
+ allFiles.removeDuplicates();
+#endif
+ files_count->setText(QString::number(allFiles.count()));
+ files_list->addItems(allFiles);
+ used_count->setText(QString::number(used));
+ used_size->setText(KIO::convertSize(usedSize));
+ unused_count->setText(QString::number(unused));
+ unused_size->setText(KIO::convertSize(unUsedSize));
+ delete_unused->setEnabled(unused > 0);
+}
+
+void ProjectSettings::accept()
+{
+ if (!m_savedProject && selectedProfile() != KdenliveSettings::current_profile())
+ if (KMessageBox::warningContinueCancel(this, i18n("Changing the profile of your project cannot be undone.\nIt is recommended to save your project before attempting this operation that might cause some corruption in transitions.\n Are you sure you want to proceed?"), i18n("Confirm profile change")) == KMessageBox::Cancel) return;
+ QDialog::accept();
+}