+void ProjectSettings::slotUpdateDisplay()
+{
+ QString currentProfile = profiles_list->itemData(profiles_list->currentIndex()).toString();
+ QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
+ p_size->setText(values.value("width") + 'x' + values.value("height"));
+ p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
+ p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
+ p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
+ if (values.value("progressive").toInt() == 0) {
+ p_progressive->setText(i18n("Interlaced (%1 fields per second)",
+ QString::number((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("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();
+}
+
+KUrl ProjectSettings::selectedFolder() const
+{
+ return project_folder->url();
+}
+
+QPoint ProjectSettings::tracks()
+{
+ 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();
+}
+
+
+//static
+QStringList ProjectSettings::extractPlaylistUrls(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("root");
+ if (!root.isEmpty() && !root.endsWith('/')) root.append('/');
+ QDomNodeList files = doc.elementsByTagName("producer");
+ for (int i = 0; i < files.count(); i++) {
+ QDomElement e = files.at(i).toElement();
+ QString type = EffectsList::property(e, "mlt_service");
+ if (type != "colour") {
+ QString url = EffectsList::property(e, "resource");
+ if (!url.isEmpty()) {
+ if (!url.startsWith('/')) url.prepend(root);
+ if (url.section('.', 0, -2).endsWith("/.all")) {
+ // slideshow clip, extract image urls
+ urls << extractSlideshowUrls(KUrl(url));
+ } else urls << url;
+ if (url.endsWith(".mlt") || url.endsWith(".kdenlive")) {
+ //TODO: Do something to avoid infinite loops if 2 files reference themselves...
+ urls << extractPlaylistUrls(url);
+ }
+ }
+ }
+ }
+
+ // luma files for transitions
+ files = doc.elementsByTagName("transition");
+ for (int i = 0; i < files.count(); i++) {
+ QDomElement e = files.at(i).toElement();
+ QString url = EffectsList::property(e, "luma");
+ if (!url.isEmpty()) {
+ if (!url.startsWith('/')) url.prepend(root);
+ urls << url;
+ }
+ }
+
+ return urls;
+}
+
+
+//static
+QStringList ProjectSettings::extractSlideshowUrls(KUrl url)
+{
+ QStringList urls;
+ QString path = url.directory(KUrl::AppendTrailingSlash);
+ QString ext = url.path().section('.', -1);
+ QDir dir(path);
+ if (url.path().contains(".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 = KFileDialog::getSaveFileName(project_folder->url(), "text/plain", this);
+ 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");
+ }
+ }
+ }
+ KTemporaryFile tmpfile;
+ if (!tmpfile.open()) {
+ kWarning() << "///// CANNOT CREATE TMP FILE in: " << tmpfile.fileName();
+ return;
+ }
+ QFile xmlf(tmpfile.fileName());
+ xmlf.open(QIODevice::WriteOnly);
+ xmlf.write(data.toUtf8());
+ if (xmlf.error() != QFile::NoError) {
+ xmlf.close();
+ return;
+ }
+ xmlf.close();
+ KIO::NetAccess::upload(tmpfile.fileName(), savePath, 0);
+}
+
+
+