void ProfilesDialog::fillList(const QString selectedProfile)
{
- // List the Mlt profiles
+ // List the Mlt profiles
m_view.profiles_list->clear();
QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
QMapIterator<QString, QString> i(profilesInfo);
if (name.contains('/')) isCustom = true;
if (!isCustom) {
- // List the Mlt profiles
+ // List the Mlt profiles
profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
- if (profilesFiles.contains(name)) path = KdenliveSettings::mltpath() + '/' + name;
+ if (profilesFiles.contains(name)) path = KdenliveSettings::mltpath() + name;
}
if (isCustom || path.isEmpty()) {
path = name;
if (path.isEmpty() || !QFile::exists(path)) {
if (name == "dv_pal") {
- kDebug() << "!!! WARNING, COULD NOT FIND DEFAULT MLT PROFILE";
+ kDebug() << "!!! WARNING, COULD NOT FIND DEFAULT MLT PROFILE";
return result;
}
if (name == KdenliveSettings::default_profile()) KdenliveSettings::setDefault_profile("dv_pal");
}
// static
-QString ProfilesDialog::getProfileDescription(QString name)
+double ProfilesDialog::getStringEval(const MltVideoProfile &profile, QString eval)
+{
+ double result;
+ eval.replace("%width", QString::number(profile.width));
+ eval.replace("%height", QString::number(profile.height));
+ if (eval.contains('/')) result = (double) eval.section('/', 0, 0).toInt() / eval.section('/', 1, 1).toInt();
+ else if (eval.contains('*')) result = (double) eval.section('*', 0, 0).toInt() * eval.section('*', 1, 1).toInt();
+ else if (eval.contains('+')) result = (double) eval.section('+', 0, 0).toInt() + eval.section('+', 1, 1).toInt();
+ else if (eval.contains('-')) result = (double) eval.section('-', 0, 0).toInt() - eval.section('-', 1, 1).toInt();
+ else result = eval.toDouble();
+ return result;
+}
+
+
+// static
+bool ProfilesDialog::existingProfileDescription(const QString &desc)
{
- QStringList profilesNames;
- QStringList profilesFiles;
QStringList profilesFilter;
profilesFilter << "*";
- // List the Mlt profiles
- profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
- if (profilesFiles.contains(name)) {
- KConfig confFile(KdenliveSettings::mltpath() + '/' + name, KConfig::SimpleConfig);
- return confFile.entryMap().value("description");
+ // List the Mlt profiles
+ QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
+ for (int i = 0; i < profilesFiles.size(); ++i) {
+ KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
+ if (desc == confFile.entryMap().value("description")) return true;
}
// List custom profiles
QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
for (int i = 0; i < customProfiles.size(); ++i) {
profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
- if (profilesFiles.contains(name)) {
- KConfig confFile(customProfiles.at(i) + '/' + name, KConfig::SimpleConfig);
- return confFile.entryMap().value("description");
+ for (int j = 0; j < profilesFiles.size(); ++j) {
+ KConfig confFile(customProfiles.at(i) + profilesFiles.at(j), KConfig::SimpleConfig);
+ if (desc == confFile.entryMap().value("description")) return true;
}
}
+ return false;
+}
+// static
+QString ProfilesDialog::existingProfile(MltVideoProfile profile)
+{
+ // Check if the profile has a matching entry in existing ones
+ QStringList profilesFilter;
+ profilesFilter << "*";
+
+ // Check the Mlt profiles
+ QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
+ for (int i = 0; i < profilesFiles.size(); ++i) {
+ KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
+ if (profile.display_aspect_den != confFile.entryMap().value("display_aspect_den").toInt()) continue;
+ if (profile.display_aspect_num != confFile.entryMap().value("display_aspect_num").toInt()) continue;
+ if (profile.sample_aspect_den != confFile.entryMap().value("sample_aspect_den").toInt()) continue;
+ if (profile.sample_aspect_num != confFile.entryMap().value("sample_aspect_num").toInt()) continue;
+ if (profile.width != confFile.entryMap().value("width").toInt()) continue;
+ if (profile.height != confFile.entryMap().value("height").toInt()) continue;
+ if (profile.frame_rate_den != confFile.entryMap().value("frame_rate_den").toInt()) continue;
+ if (profile.frame_rate_num != confFile.entryMap().value("frame_rate_num").toInt()) continue;
+ if (profile.progressive != confFile.entryMap().value("progressive").toInt()) continue;
+ return profilesFiles.at(i);
+ }
+
+ // Check custom profiles
+ QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
+ for (int i = 0; i < customProfiles.size(); ++i) {
+ profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
+ for (int j = 0; j < profilesFiles.size(); ++j) {
+ KConfig confFile(customProfiles.at(i) + profilesFiles.at(j), KConfig::SimpleConfig);
+ if (profile.display_aspect_den != confFile.entryMap().value("display_aspect_den").toInt()) continue;
+ if (profile.display_aspect_num != confFile.entryMap().value("display_aspect_num").toInt()) continue;
+ if (profile.sample_aspect_den != confFile.entryMap().value("sample_aspect_den").toInt()) continue;
+ if (profile.sample_aspect_num != confFile.entryMap().value("sample_aspect_num").toInt()) continue;
+ if (profile.width != confFile.entryMap().value("width").toInt()) continue;
+ if (profile.height != confFile.entryMap().value("height").toInt()) continue;
+ if (profile.frame_rate_den != confFile.entryMap().value("frame_rate_den").toInt()) continue;
+ if (profile.frame_rate_num != confFile.entryMap().value("frame_rate_num").toInt()) continue;
+ if (profile.progressive != confFile.entryMap().value("progressive").toInt()) continue;
+ return customProfiles.at(i) + profilesFiles.at(j);
+ }
+ }
return QString();
}
QStringList profilesFilter;
profilesFilter << "*";
- // List the Mlt profiles
+ // List the Mlt profiles
QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
for (int i = 0; i < profilesFiles.size(); ++i) {
- KConfig confFile(KdenliveSettings::mltpath() + '/' + profilesFiles.at(i), KConfig::SimpleConfig);
+ KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
QString desc = confFile.entryMap().value("description");
if (!desc.isEmpty()) result.insert(desc, profilesFiles.at(i));
}
for (int i = 0; i < customProfiles.size(); ++i) {
profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
for (int j = 0; j < profilesFiles.size(); ++j) {
- KConfig confFile(customProfiles.at(i) + '/' + profilesFiles.at(j), KConfig::SimpleConfig);
+ KConfig confFile(customProfiles.at(i) + profilesFiles.at(j), KConfig::SimpleConfig);
QString desc = confFile.entryMap().value("description");
- if (!desc.isEmpty()) result.insert(desc, customProfiles.at(i) + '/' + profilesFiles.at(j));
+ if (!desc.isEmpty()) result.insert(desc, customProfiles.at(i) + profilesFiles.at(j));
}
}
return result;
if (!path.contains('/')) {
// This is an MLT profile
- KConfig confFile(KdenliveSettings::mltpath() + '/' + path, KConfig::SimpleConfig);
+ KConfig confFile(KdenliveSettings::mltpath() + path, KConfig::SimpleConfig);
return confFile.entryMap();
} else {
// This is a custom profile
QStringList profilesFilter;
profilesFilter << "*";
- // List the Mlt profiles
+ // List the Mlt profiles
profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
for (int i = 0; i < profilesFiles.size(); ++i) {
- KConfig confFile(KdenliveSettings::mltpath() + '/' + profilesFiles.at(i), KConfig::SimpleConfig);
+ KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
QMap< QString, QString > values = confFile.entryMap();
if (values.value("description") == profileName) {
values.insert("path", profilesFiles.at(i));
for (int i = 0; i < customProfiles.size(); ++i) {
QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
for (int i = 0; i < profiles.size(); ++i) {
- KConfig confFile(customProfiles.at(i) + '/' + profiles.at(i), KConfig::SimpleConfig);
+ KConfig confFile(customProfiles.at(i) + profiles.at(i), KConfig::SimpleConfig);
QMap< QString, QString > values = confFile.entryMap();
if (values.value("description") == profileName) {
- values.insert("path", customProfiles.at(i) + '/' + profiles.at(i));
+ values.insert("path", customProfiles.at(i) + profiles.at(i));
return values;
}
}
QStringList profilesFilter;
profilesFilter << "*";
- // List the Mlt profiles
+ // List the Mlt profiles
profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
for (int i = 0; i < profilesFiles.size(); ++i) {
- KConfig confFile(KdenliveSettings::mltpath() + '/' + profilesFiles.at(i), KConfig::SimpleConfig);
+ KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
QMap< QString, QString > values = confFile.entryMap();
if (values.value("description") == profileDesc) return profilesFiles.at(i);
}
for (int i = 0; i < customProfiles.size(); ++i) {
QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
for (int i = 0; i < profiles.size(); ++i) {
- KConfig confFile(customProfiles.at(i) + '/' + profiles.at(i), KConfig::SimpleConfig);
+ KConfig confFile(customProfiles.at(i) + profiles.at(i), KConfig::SimpleConfig);
QMap< QString, QString > values = confFile.entryMap();
- if (values.value("description") == profileDesc) return customProfiles.at(i) + '/' + profiles.at(i);
+ if (values.value("description") == profileDesc) return customProfiles.at(i) + profiles.at(i);
}
}
return QString();
m_selectedProfileIndex = m_view.profiles_list->currentIndex();
QString currentProfile = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
m_isCustomProfile = currentProfile.contains('/');
+ m_view.button_create->setEnabled(true);
m_view.button_delete->setEnabled(m_isCustomProfile);
m_view.properties->setEnabled(m_isCustomProfile);
m_view.button_save->setEnabled(m_isCustomProfile);
m_view.frame_num->setValue(values.value("frame_rate_num").toInt());
m_view.frame_den->setValue(values.value("frame_rate_den").toInt());
m_view.progressive->setChecked(values.value("progressive").toInt());
+ if (values.value("progressive").toInt()) {
+ m_view.fields->setText(QString::number((double)values.value("frame_rate_num").toInt()/values.value("frame_rate_den").toInt(), 'f', 2));
+ } else {
+ m_view.fields->setText(QString::number((double)2*values.value("frame_rate_num").toInt()/values.value("frame_rate_den").toInt(), 'f', 2));
+ }
m_profileIsModified = false;
}