+ProjectSettings::ProjectSettings(ProjectList *projectlist, QMap <QString, QString> metadata, QStringList lumas, int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool savedProject, QWidget * parent) :
+ QDialog(parent), m_savedProject(savedProject), m_projectList(projectlist), m_lumas(lumas)
+{
+ setupUi(this);
+
+ list_search->setTreeWidget(files_list);
+
+ QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
+ QMapIterator<QString, QString> i(profilesInfo);
+ while (i.hasNext()) {
+ i.next();
+ profiles_list->addItem(i.key(), i.value());
+ }
+ project_folder->setMode(KFile::Directory);
+ project_folder->setUrl(KUrl(projectPath));
+ QString currentProf = KdenliveSettings::current_profile();
+
+ for (int i = 0; i < profiles_list->count(); i++) {
+ if (profiles_list->itemData(i).toString() == currentProf) {
+ profiles_list->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ 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 proxyparameters;
+ QString proxyextension;
+ if (projectlist) {
+ enable_proxy->setChecked(projectlist->getDocumentProperty("enableproxy").toInt());
+ generate_proxy->setChecked(projectlist->getDocumentProperty("generateproxy").toInt());
+ proxy_minsize->setValue(projectlist->getDocumentProperty("proxyminsize").toInt());
+ proxyparameters = projectlist->getDocumentProperty("proxyparams");
+ generate_imageproxy->setChecked(projectlist->getDocumentProperty("generateimageproxy").toInt());
+ proxy_imageminsize->setValue(projectlist->getDocumentProperty("proxyimageminsize").toInt());
+ proxyextension = projectlist->getDocumentProperty("proxyextension");
+ }
+ else {
+ enable_proxy->setChecked(KdenliveSettings::enableproxy());
+ generate_proxy->setChecked(KdenliveSettings::generateproxy());
+ proxy_minsize->setValue(KdenliveSettings::proxyminsize());
+ proxyparameters = KdenliveSettings::proxyparams();
+ generate_imageproxy->setChecked(KdenliveSettings::generateimageproxy());
+ proxy_imageminsize->setValue(KdenliveSettings::proxyimageminsize());
+ proxyextension = KdenliveSettings::proxyextension();
+
+ }
+
+ proxy_minsize->setEnabled(generate_proxy->isChecked());
+ proxy_imageminsize->setEnabled(generate_imageproxy->isChecked());
+
+
+ // load proxy profiles
+ KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
+ KConfigGroup group(&conf, "proxy");
+ QMap <QString, QString> values = group.entryMap();
+ QMapIterator<QString, QString> k(values);
+ int ix = -1;
+ 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 == proxyparameters && extension == proxyextension) || (proxyparameters.isEmpty() || 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(proxyparameters + ';' + proxyextension));
+ }
+ proxy_profile->setCurrentIndex(ix);
+ slotUpdateProxyParams();
+
+ // Proxy GUI stuff
+ proxy_showprofileinfo->setIcon(KIcon("help-about"));
+ 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
+ QTreeWidgetItem *item = new QTreeWidgetItem(metadata_list, QStringList() << i18n("Title"));
+ item->setData(0, Qt::UserRole, QString("meta.attr.title.markup"));
+ if (metadata.contains("meta.attr.title.markup")) item->setText(1, metadata.value("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, QString("meta.attr.author.markup"));
+ if (metadata.contains("meta.attr.author.markup")) item->setText(1, metadata.value("meta.attr.author.markup"));
+ item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ item = new QTreeWidgetItem(metadata_list, QStringList() << i18n("Copyright"));
+ item->setData(0, Qt::UserRole, QString("meta.attr.copyright.markup"));
+ if (metadata.contains("meta.attr.copyright.markup")) item->setText(1, metadata.value("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, QString("meta.attr.year.markup"));
+ if (metadata.contains("meta.attr.year.markup")) item->setText(1, metadata.value("meta.attr.year.markup"));
+ item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+
+ slotUpdateDisplay();
+ if (m_projectList != 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(const QString &)), this, SLOT(slotUpdateButton(const QString &)));
+ connect(button_export, SIGNAL(clicked()), this, SLOT(slotExportToText()));
+}
+
+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::slotDeleteProxies()
+{
+ if (KMessageBox::warningContinueCancel(this, i18n("Deleting proxy clips will disable proxies for this project.")) != KMessageBox::Continue) return;
+ buttonBox->setEnabled(false);
+ enable_proxy->setChecked(false);
+ emit disableProxies();
+ KIO::NetAccess::del(KUrl(project_folder->url().path(KUrl::AddTrailingSlash) + "proxy/"), this);
+ KStandardDirs::makeDir(project_folder->url().path(KUrl::AddTrailingSlash) + "proxy/");
+ buttonBox->setEnabled(true);
+ slotUpdateFiles(true);
+}