diff --git a/src/project/dialogs/projectsettings.cpp b/src/project/dialogs/projectsettings.cpp index 92276273d..dca6ac660 100644 --- a/src/project/dialogs/projectsettings.cpp +++ b/src/project/dialogs/projectsettings.cpp @@ -1,751 +1,746 @@ /*************************************************************************** * Copyright (C) 2016 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 "projectsettings.h" #include "kdenlivesettings.h" #include "core.h" #include "doc/kdenlivedoc.h" #include "utils/KoIconUtils.h" #include "titler/titlewidget.h" #include "utils/KoIconUtils.h" #include "effectslist/effectslist.h" #include "dialogs/profilesdialog.h" #include "dialogs/encodingprofilesdialog.h" #include "mltcontroller/clipcontroller.h" #include "mltcontroller/bincontroller.h" #include "bin/bin.h" #include #include #include #include #include #include #include #include #include #include -class NoEditDelegate: public QStyledItemDelegate -{ - public: - NoEditDelegate(QObject* parent=0): QStyledItemDelegate(parent) {} - virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { - return 0; - } -}; - - ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap metadata, const QStringList &lumas, int videotracks, int audiotracks, const QString &projectPath, bool readOnlyTracks, bool savedProject, QWidget * parent) : QDialog(parent), m_savedProject(savedProject), m_lumas(lumas) { setupUi(this); list_search->setTreeWidget(files_list); project_folder->setMode(KFile::Directory); project_folder->setUrl(QUrl(projectPath)); loadProfiles(); manage_profiles->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure"))); manage_profiles->setToolTip(i18n("Manage project profiles")); connect(manage_profiles, SIGNAL(clicked(bool)), this, SLOT(slotEditProfiles())); m_buttonOk = buttonBox->button(QDialogButtonBox::Ok); //buttonOk->setEnabled(false); audio_thumbs->setChecked(KdenliveSettings::audiothumbnails()); video_thumbs->setChecked(KdenliveSettings::videothumbnails()); audio_tracks->setValue(audiotracks); video_tracks->setValue(videotracks); connect(generate_proxy, SIGNAL(toggled(bool)), proxy_minsize, SLOT(setEnabled(bool))); connect(generate_imageproxy, SIGNAL(toggled(bool)), proxy_imageminsize, SLOT(setEnabled(bool))); QString currentProf; if (doc) { currentProf = KdenliveSettings::current_profile(); enable_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("enableproxy")).toInt()); generate_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateproxy")).toInt()); proxy_minsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyminsize")).toInt()); m_proxyparameters = doc->getDocumentProperty(QStringLiteral("proxyparams")); generate_imageproxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateimageproxy")).toInt()); proxy_imageminsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyimageminsize")).toInt()); m_proxyextension = doc->getDocumentProperty(QStringLiteral("proxyextension")); } else { currentProf = KdenliveSettings::default_profile(); enable_proxy->setChecked(KdenliveSettings::enableproxy()); generate_proxy->setChecked(KdenliveSettings::generateproxy()); proxy_minsize->setValue(KdenliveSettings::proxyminsize()); m_proxyparameters = KdenliveSettings::proxyparams(); generate_imageproxy->setChecked(KdenliveSettings::generateimageproxy()); proxy_imageminsize->setValue(KdenliveSettings::proxyimageminsize()); m_proxyextension = KdenliveSettings::proxyextension(); } // Select profile int ix = profiles_list->findData(currentProf); if (ix > -1) { profiles_list->setCurrentIndex(ix); } else { // Error, profile not found qWarning()<<"Project profile not found, disable editing"; } proxy_minsize->setEnabled(generate_proxy->isChecked()); proxy_imageminsize->setEnabled(generate_imageproxy->isChecked()); loadProxyProfiles(); // Proxy GUI stuff proxy_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about"))); proxy_showprofileinfo->setToolTip(i18n("Show default profile parameters")); proxy_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure"))); proxy_manageprofile->setToolTip(i18n("Manage proxy profiles")); connect(proxy_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile())); proxy_profile->setToolTip(i18n("Select default proxy profile")); connect(proxy_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateProxyParams())); proxyparams->setVisible(false); proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5); connect(proxy_showprofileinfo, SIGNAL(clicked(bool)), proxyparams, SLOT(setVisible(bool))); if (readOnlyTracks) { video_tracks->setEnabled(false); audio_tracks->setEnabled(false); } - metadata_list->setItemDelegateForColumn(0, new NoEditDelegate(this)); + connect(metadata_list, &QTreeWidget::itemDoubleClicked, this, &ProjectSettings::slotEditMetadata); // Metadata list QTreeWidgetItem *item = new QTreeWidgetItem(metadata_list, QStringList() << i18n("Title")); item->setData(0, Qt::UserRole, QStringLiteral("meta.attr.title.markup")); if (metadata.contains(QStringLiteral("meta.attr.title.markup"))) { item->setText(1, metadata.value(QStringLiteral("meta.attr.title.markup"))); metadata.remove(QStringLiteral("meta.attr.title.markup")); } item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); item = new QTreeWidgetItem(metadata_list, QStringList() << i18n("Author")); item->setData(0, Qt::UserRole, QStringLiteral("meta.attr.author.markup")); if (metadata.contains(QStringLiteral("meta.attr.author.markup"))) { item->setText(1, metadata.value(QStringLiteral("meta.attr.author.markup"))); metadata.remove(QStringLiteral("meta.attr.author.markup")); } else if (metadata.contains(QStringLiteral("meta.attr.artist.markup"))) { item->setText(0, i18n("Artist")); item->setData(0, Qt::UserRole, QStringLiteral("meta.attr.artist.markup")); item->setText(1, metadata.value(QStringLiteral("meta.attr.artist.markup"))); metadata.remove(QStringLiteral("meta.attr.artist.markup")); } item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); item = new QTreeWidgetItem(metadata_list, QStringList() << i18n("Copyright")); item->setData(0, Qt::UserRole, QStringLiteral("meta.attr.copyright.markup")); if (metadata.contains(QStringLiteral("meta.attr.copyright.markup"))) { item->setText(1, metadata.value(QStringLiteral("meta.attr.copyright.markup"))); metadata.remove(QStringLiteral("meta.attr.copyright.markup")); } item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); item = new QTreeWidgetItem(metadata_list, QStringList() << i18n("Year")); item->setData(0, Qt::UserRole, QStringLiteral("meta.attr.year.markup")); if (metadata.contains(QStringLiteral("meta.attr.year.markup"))) { item->setText(1, metadata.value(QStringLiteral("meta.attr.year.markup"))); metadata.remove(QStringLiteral("meta.attr.year.markup")); } else if (metadata.contains(QStringLiteral("meta.attr.date.markup"))) { item->setText(0, i18n("Date")); item->setData(0, Qt::UserRole, QStringLiteral("meta.attr.date.markup")); item->setText(1, metadata.value(QStringLiteral("meta.attr.date.markup"))); metadata.remove(QStringLiteral("meta.attr.date.markup")); } item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); QMap::const_iterator meta = metadata.constBegin(); while (meta != metadata.constEnd()) { item = new QTreeWidgetItem(metadata_list, QStringList() << meta.key().section('.', 2,2)); item->setData(0, Qt::UserRole, meta.key()); item->setText(1, meta.value()); item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); ++meta; } connect(add_metadata, SIGNAL(clicked()), this, SLOT(slotAddMetadataField())); connect(delete_metadata, SIGNAL(clicked()), this, SLOT(slotDeleteMetadataField())); add_metadata->setIcon(KoIconUtils::themedIcon(QStringLiteral("list-add"))); delete_metadata->setIcon(KoIconUtils::themedIcon(QStringLiteral("list-remove"))); slotUpdateDisplay(); if (doc != NULL) { slotUpdateFiles(); connect(clear_cache, SIGNAL(clicked()), this, SLOT(slotClearCache())); connect(delete_unused, SIGNAL(clicked()), this, SLOT(slotDeleteUnused())); connect(delete_proxies, SIGNAL(clicked()), this, SLOT(slotDeleteProxies())); } else tabWidget->widget(1)->setEnabled(false); connect(profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay())); connect(project_folder, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateButton(QString))); connect(button_export, SIGNAL(clicked()), this, SLOT(slotExportToText())); // Delete unused files is not implemented delete_unused->setVisible(false); } +void ProjectSettings::slotEditMetadata(QTreeWidgetItem *item, int ) +{ + metadata_list->editItem(item, 1); +} + void ProjectSettings::slotDeleteUnused() { QStringList toDelete; //TODO /* QList list = m_projectList->documentClipList(); for (int i = 0; i < list.count(); ++i) { DocClipBase *clip = list.at(i); if (clip->numReferences() == 0 && clip->clipType() != SlideShow) { QUrl url = clip->fileURL(); if (url.isValid() && !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) { QUrl url = clip->fileURL(); if (url.isValid() && 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); enable_proxy->setChecked(false); emit disableProxies(); // Delete proxy files QDir folder(project_folder->url().path()); folder.cd(QStringLiteral("thumbs")); foreach(const QString path, m_projectThumbs) { folder.remove(path); } buttonBox->setEnabled(true); slotUpdateFiles(true); } void ProjectSettings::slotDeleteProxies() { if (KMessageBox::warningContinueCancelList(this, i18n("Deleting these proxy clips will disable proxies for this project."), m_projectProxies) != KMessageBox::Continue) return; buttonBox->setEnabled(false); enable_proxy->setChecked(false); emit disableProxies(); // Delete proxy files QDir folder(project_folder->url().path()); folder.cd(QStringLiteral("proxy")); foreach(const QString path, m_projectProxies) { folder.remove(path); } buttonBox->setEnabled(true); slotUpdateFiles(true); } void ProjectSettings::slotUpdateFiles(bool cacheOnly) { // Get list of current project hashes QStringList hashes = pCore->binController()->getProjectHashes(); m_projectProxies.clear(); m_projectThumbs.clear(); // Check for matches in thumbs qint64 totalSize = 0; QDir folder(project_folder->url().path()); folder.cd(QStringLiteral("thumbs")); QStringList thumbs = folder.entryList(QDir::Files); foreach(const QString &thumb, thumbs) { QString px = thumb.section('.', 0, 0).section('#', 0, 0).section('_', 0, 0); if (hashes.contains(px)) { m_projectThumbs << thumb; QFileInfo f(folder.absoluteFilePath(thumb)); totalSize += f.size(); } } thumbs_count->setText(QString::number(m_projectThumbs.count())); thumbs_size->setText(KIO::convertSize(totalSize)); clear_cache->setEnabled(!m_projectThumbs.isEmpty()); // Check for matches in proxies totalSize = 0; folder.cd(QStringLiteral("../proxy")); QStringList proxies = folder.entryList(QDir::Files); foreach(const QString &proxy, proxies) { QString px = proxy.section('.', 0, 0); if (hashes.contains(px)) { m_projectProxies << proxy; QFileInfo f(folder.absoluteFilePath(proxy)); totalSize += f.size(); } } proxy_count->setText(QString::number(m_projectProxies.count())); proxy_size->setText(KIO::convertSize(totalSize)); delete_proxies->setEnabled(!m_projectProxies.isEmpty()); if (cacheOnly) return; QList list = pCore->binController()->getControllerList(); 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? // Setup categories QTreeWidgetItem *videos = new QTreeWidgetItem(files_list, QStringList() << i18n("Video clips")); videos->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("video-x-generic"))); videos->setExpanded(true); QTreeWidgetItem *sounds = new QTreeWidgetItem(files_list, QStringList() << i18n("Audio clips")); sounds->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("audio-x-generic"))); sounds->setExpanded(true); QTreeWidgetItem *images = new QTreeWidgetItem(files_list, QStringList() << i18n("Image clips")); images->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("image-x-generic"))); images->setExpanded(true); QTreeWidgetItem *slideshows = new QTreeWidgetItem(files_list, QStringList() << i18n("Slideshow clips")); slideshows->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("image-x-generic"))); slideshows->setExpanded(true); QTreeWidgetItem *texts = new QTreeWidgetItem(files_list, QStringList() << i18n("Text clips")); texts->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("text-plain"))); texts->setExpanded(true); QTreeWidgetItem *playlists = new QTreeWidgetItem(files_list, QStringList() << i18n("Playlist clips")); playlists->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("video-mlt-playlist"))); playlists->setExpanded(true); QTreeWidgetItem *others = new QTreeWidgetItem(files_list, QStringList() << i18n("Other clips")); others->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("unknown"))); others->setExpanded(true); int count = 0; QStringList allFonts; foreach(const QString & file, m_lumas) { count++; new QTreeWidgetItem(images, QStringList() << file); } for (int i = 0; i < list.count(); ++i) { ClipController *clip = list.at(i); if (clip->clipType() == Color) { // ignore color clips in list, there is no real file continue; } if (clip->clipType() == SlideShow) { QStringList subfiles = extractSlideshowUrls(clip->clipUrl()); foreach(const QString & file, subfiles) { count++; new QTreeWidgetItem(slideshows, QStringList() << file); } continue; } else if (!clip->clipUrl().isEmpty()) { //allFiles.append(clip->fileURL().path()); switch (clip->clipType()) { case Text: new QTreeWidgetItem(texts, QStringList() << clip->clipUrl().path()); break; case Audio: new QTreeWidgetItem(sounds, QStringList() << clip->clipUrl().path()); break; case Image: new QTreeWidgetItem(images, QStringList() << clip->clipUrl().path()); break; case Playlist: new QTreeWidgetItem(playlists, QStringList() << clip->clipUrl().path()); break; case Unknown: new QTreeWidgetItem(others, QStringList() << clip->clipUrl().path()); break; default: new QTreeWidgetItem(videos, QStringList() << clip->clipUrl().path()); break; } count++; } if (clip->clipType() == Text) { QStringList imagefiles = TitleWidget::extractImageList(clip->property(QStringLiteral("xmldata"))); QStringList fonts = TitleWidget::extractFontList(clip->property(QStringLiteral("xmldata"))); foreach(const QString & file, imagefiles) { count++; new QTreeWidgetItem(images, QStringList() << file); } allFonts << fonts; } else if (clip->clipType() == Playlist) { QStringList files = extractPlaylistUrls(clip->clipUrl().path()); foreach(const QString & file, files) { count++; new QTreeWidgetItem(others, QStringList() << file); } } } uint used = 0; uint unUsed = 0; qint64 usedSize = 0; qint64 unUsedSize = 0; pCore->bin()->getBinStats(&used, &unUsed, &usedSize, &unUsedSize); allFonts.removeDuplicates(); // Hide unused categories for (int i = 0; i < files_list->topLevelItemCount(); ++i) { if (files_list->topLevelItem(i)->childCount() == 0) { files_list->topLevelItem(i)->setHidden(true); } } files_count->setText(QString::number(count)); fonts_list->addItems(allFonts); if (allFonts.isEmpty()) { fonts_list->setHidden(true); label_fonts->setHidden(true); } 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(); } void ProjectSettings::slotUpdateDisplay() { QLocale locale; locale.setNumberOptions(QLocale::OmitGroupSeparator); QString currentProfile = profiles_list->itemData(profiles_list->currentIndex()).toString(); QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile); p_size->setText(values.value(QStringLiteral("width")) + 'x' + values.value(QStringLiteral("height"))); p_fps->setText(values.value(QStringLiteral("frame_rate_num")) + '/' + values.value(QStringLiteral("frame_rate_den"))); p_aspect->setText(values.value(QStringLiteral("sample_aspect_num")) + '/' + values.value(QStringLiteral("sample_aspect_den"))); p_display->setText(values.value(QStringLiteral("display_aspect_num")) + '/' + values.value(QStringLiteral("display_aspect_den"))); if (values.value(QStringLiteral("progressive")).toInt() == 0) { p_progressive->setText(i18n("Interlaced (%1 fields per second)", locale.toString((double)2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2))); } else { p_progressive->setText(i18n("Progressive")); } p_colorspace->setText(ProfilesDialog::getColorspaceDescription(values.value(QStringLiteral("colorspace")).toInt())); } void ProjectSettings::slotUpdateButton(const QString &path) { if (path.isEmpty()) m_buttonOk->setEnabled(false); else { m_buttonOk->setEnabled(true); slotUpdateFiles(true); } } QString ProjectSettings::selectedProfile() const { return profiles_list->itemData(profiles_list->currentIndex()).toString(); } QUrl ProjectSettings::selectedFolder() const { return project_folder->url(); } QPoint ProjectSettings::tracks() const { QPoint p; p.setX(video_tracks->value()); p.setY(audio_tracks->value()); return p; } bool ProjectSettings::enableVideoThumbs() const { return video_thumbs->isChecked(); } bool ProjectSettings::enableAudioThumbs() const { return audio_thumbs->isChecked(); } bool ProjectSettings::useProxy() const { return enable_proxy->isChecked(); } bool ProjectSettings::generateProxy() const { return generate_proxy->isChecked(); } bool ProjectSettings::generateImageProxy() const { return generate_imageproxy->isChecked(); } int ProjectSettings::proxyMinSize() const { return proxy_minsize->value(); } int ProjectSettings::proxyImageMinSize() const { return proxy_imageminsize->value(); } QString ProjectSettings::proxyParams() const { QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString(); return params.section(';', 0, 0); } QString ProjectSettings::proxyExtension() const { QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString(); return params.section(';', 1, 1); } //static QStringList ProjectSettings::extractPlaylistUrls(const QString &path) { QStringList urls; QDomDocument doc; QFile file(path); if (!file.open(QIODevice::ReadOnly)) return urls; if (!doc.setContent(&file)) { file.close(); return urls; } file.close(); QString root = doc.documentElement().attribute(QStringLiteral("root")); if (!root.isEmpty() && !root.endsWith('/')) root.append('/'); QDomNodeList files = doc.elementsByTagName(QStringLiteral("producer")); for (int i = 0; i < files.count(); ++i) { QDomElement e = files.at(i).toElement(); QString type = EffectsList::property(e, QStringLiteral("mlt_service")); if (type != QLatin1String("colour")) { QString url = EffectsList::property(e, QStringLiteral("resource")); if (type == QLatin1String("timewarp")) { url = EffectsList::property(e, QStringLiteral("warp_resource")); } else if (type == QLatin1String("framebuffer")) { url = url.section('?', 0, 0); } if (!url.isEmpty()) { if (!url.startsWith('/')) url.prepend(root); if (url.section('.', 0, -2).endsWith(QLatin1String("/.all"))) { // slideshow clip, extract image urls urls << extractSlideshowUrls(QUrl(url)); } else urls << url; if (url.endsWith(QLatin1String(".mlt")) || url.endsWith(QLatin1String(".kdenlive"))) { //TODO: Do something to avoid infinite loops if 2 files reference themselves... urls << extractPlaylistUrls(url); } } } } // luma files for transitions files = doc.elementsByTagName(QStringLiteral("transition")); for (int i = 0; i < files.count(); ++i) { QDomElement e = files.at(i).toElement(); QString url = EffectsList::property(e, QStringLiteral("resource")); if (!url.isEmpty()) { if (!url.startsWith('/')) url.prepend(root); urls << url; } } return urls; } //static QStringList ProjectSettings::extractSlideshowUrls(const QUrl &url) { QStringList urls; QString path = url.adjusted(QUrl::RemoveFilename).path(); QString ext = url.path().section('.', -1); QDir dir(path); if (url.path().contains(QStringLiteral(".all."))) { // this is a mime slideshow, like *.jpeg QStringList filters; filters << "*." + ext; dir.setNameFilters(filters); QStringList result = dir.entryList(QDir::Files); urls.append(path + filters.at(0) + " (" + i18np("1 image found", "%1 images found", result.count()) + ')'); } else { // this is a pattern slideshow, like sequence%4d.jpg QString filter = url.fileName(); QString ext = filter.section('.', -1); filter = filter.section('%', 0, -2); QString regexp = '^' + filter + "\\d+\\." + ext + '$'; QRegExp rx(regexp); int count = 0; QStringList result = dir.entryList(QDir::Files); foreach(const QString & path, result) { if (rx.exactMatch(path)) count++; } urls.append(url.path() + " (" + i18np("1 image found", "%1 images found", count) + ')'); } return urls; } void ProjectSettings::slotExportToText() { QString savePath = QFileDialog::getSaveFileName(this, QString(), project_folder->url().path(), QStringLiteral("text/plain")); if (savePath.isEmpty()) return; QString data; data.append(i18n("Project folder: %1", project_folder->url().path()) + '\n'); data.append(i18n("Project profile: %1", profiles_list->currentText()) + '\n'); data.append(i18n("Total clips: %1 (%2 used in timeline).", files_count->text(), used_count->text()) + "\n\n"); for (int i = 0; i < files_list->topLevelItemCount(); ++i) { if (files_list->topLevelItem(i)->childCount() > 0) { data.append('\n' + files_list->topLevelItem(i)->text(0) + ":\n\n"); for (int j = 0; j < files_list->topLevelItem(i)->childCount(); ++j) { data.append(files_list->topLevelItem(i)->child(j)->text(0) + '\n'); } } } QTemporaryFile tmpfile; if (!tmpfile.open()) { qWarning() << "///// CANNOT CREATE TMP FILE in: " << tmpfile.fileName(); return; } QFile xmlf(tmpfile.fileName()); if (!xmlf.open(QIODevice::WriteOnly)) return; xmlf.write(data.toUtf8()); if (xmlf.error() != QFile::NoError) { xmlf.close(); return; } xmlf.close(); KIO::FileCopyJob *copyjob = KIO::file_copy(QUrl::fromLocalFile(tmpfile.fileName()), QUrl::fromLocalFile(savePath)); copyjob->exec(); } void ProjectSettings::slotUpdateProxyParams() { QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString(); proxyparams->setPlainText(params.section(';', 0, 0)); } const QMap ProjectSettings::metadata() const { QMap metadata; for (int i = 0; i < metadata_list->topLevelItemCount(); ++i) { QTreeWidgetItem *item = metadata_list->topLevelItem(i); if (!item->text(1).simplified().isEmpty()) { // Insert metadata entry QString key = item->data(0, Qt::UserRole).toString(); if (key.isEmpty()) key = "meta.attr." + item->text(0).simplified() + ".markup"; QString value = item->text(1); metadata.insert(key, value); } } return metadata; } void ProjectSettings::slotAddMetadataField() { QString metaField = QInputDialog::getText(this, i18n("Metadata"), i18n("Metadata")); if (metaField.isEmpty()) return; QTreeWidgetItem *item = new QTreeWidgetItem(metadata_list, QStringList() << metaField); item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); } void ProjectSettings::slotDeleteMetadataField() { QTreeWidgetItem *item = metadata_list->currentItem(); if (item) delete item; } void ProjectSettings::loadProfiles() { profiles_list->clear(); QMap profilesInfo = ProfilesDialog::getProfilesInfo(); QMapIterator i(profilesInfo); while (i.hasNext()) { i.next(); profiles_list->addItem(i.value(), i.key()); } } void ProjectSettings::slotEditProfiles() { ProfilesDialog *w = new ProfilesDialog; w->exec(); QString currentProf = profiles_list->currentData().toString(); loadProfiles(); int ix = profiles_list->findData(currentProf); if (ix > -1) { profiles_list->setCurrentIndex(ix); } else { // Error, profile not found qWarning()<<"Project profile not found, disable editing"; } emit refreshProfiles(); delete w; } void ProjectSettings::slotManageEncodingProfile() { QPointer d = new EncodingProfilesDialog(0); d->exec(); delete d; loadProxyProfiles(); } void ProjectSettings::loadProxyProfiles() { // load proxy profiles KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::DataLocation); KConfigGroup group(&conf, "proxy"); QMap values = group.entryMap(); QMapIterator k(values); int ix = -1; proxy_profile->clear(); while (k.hasNext()) { k.next(); if (!k.key().isEmpty()) { QString params = k.value().section(';', 0, 0); QString extension = k.value().section(';', 1, 1); if (ix == -1 && ((params == m_proxyparameters && extension == m_proxyextension) || (m_proxyparameters.isEmpty() || m_proxyextension.isEmpty()))) { // this is the current profile ix = proxy_profile->count(); } proxy_profile->addItem(k.key(), k.value()); } } if (ix == -1) { // Current project proxy settings not found ix = proxy_profile->count(); proxy_profile->addItem(i18n("Current Settings"), QString(m_proxyparameters + ';' + m_proxyextension)); } proxy_profile->setCurrentIndex(ix); slotUpdateProxyParams(); } diff --git a/src/project/dialogs/projectsettings.h b/src/project/dialogs/projectsettings.h index 1471223e8..872213bcd 100644 --- a/src/project/dialogs/projectsettings.h +++ b/src/project/dialogs/projectsettings.h @@ -1,98 +1,100 @@ /*************************************************************************** * Copyright (C) 2008 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 PROJECTSETTINGS_H #define PROJECTSETTINGS_H #include #include #include "ui_projectsettings_ui.h" class KdenliveDoc; class ProjectSettings : public QDialog, public Ui::ProjectSettings_UI { Q_OBJECT public: ProjectSettings(KdenliveDoc *doc, QMap metadata, const QStringList &lumas, int videotracks, int audiotracks, const QString& projectPath, bool readOnlyTracks, bool unsavedProject, QWidget * parent = 0); QString selectedProfile() const; QUrl selectedFolder() const; QPoint tracks() const; bool enableVideoThumbs() const; bool enableAudioThumbs() const; bool useProxy() const; bool generateProxy() const; int proxyMinSize() const; bool generateImageProxy() const; int proxyImageMinSize() const; QString proxyParams() const; QString proxyExtension() const; const QMap metadata() const; static QStringList extractPlaylistUrls(const QString &path); static QStringList extractSlideshowUrls(const QUrl &url); public slots: virtual void accept(); private slots: void slotUpdateDisplay(); void slotUpdateButton(const QString &path); void slotUpdateFiles(bool cacheOnly = false); void slotClearCache(); void slotDeleteProxies(); void slotDeleteUnused(); /** @brief Export project data to text file. */ void slotExportToText(); /** @brief Update the displayed proxy parameters when user changes selection. */ void slotUpdateProxyParams(); /** @brief Insert a new metadata field. */ void slotAddMetadataField(); /** @brief Delete current metadata field. */ void slotDeleteMetadataField(); /** @brief Open project profile management dialog. */ void slotEditProfiles(); /** @brief Display proxy profiles management dialog. */ void slotManageEncodingProfile(); + /** @brief Open editor for metadata item. */ + void slotEditMetadata(QTreeWidgetItem *, int ); private: QPushButton *m_buttonOk; bool m_savedProject; QStringList m_lumas; void loadProfiles(); QString m_proxyparameters; QString m_proxyextension; /** @brief List of all proxies urls in this project. */ QStringList m_projectProxies; /** @brief List of all thumbnails used in this project. */ QStringList m_projectThumbs; /** @brief Fill the proxy profiles combobox. */ void loadProxyProfiles(); signals: /** @brief User deleted proxies, so disable them in project. */ void disableProxies(); void refreshProfiles(); }; #endif