success = validator.validate(DOCUMENTVERSION);
if (success) { // Let the validator handle error messages
setModified(validator.isModified());
- QDomNode infoXmlNode = m_document.elementsByTagName("kdenlivedoc").at(0);
- QDomElement infoXml = infoXmlNode.toElement();
- QDomNode mlt = m_document.elementsByTagName("mlt").at(0);
+ QDomElement mlt = m_document.firstChildElement("mlt");
+ QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
profileName = infoXml.attribute("profile");
m_projectFolder = infoXml.attribute("projectfolder");
// Build tracks
QDomElement e;
- QDomNode tracksinfo = m_document.elementsByTagName("tracksinfo").at(0);
+ QDomElement tracksinfo = infoXml.firstChildElement("tracksinfo");
TrackInfo projectTrack;
if (!tracksinfo.isNull()) {
QDomNodeList trackslist = tracksinfo.childNodes();
setProfilePath(KdenliveSettings::default_profile());
m_clipManager->clear();
} else {
- QDomNode markers = m_document.elementsByTagName("markers").at(0);
+ QDomElement markers = infoXml.firstChildElement("markers");
if (!markers.isNull()) {
QDomNodeList markerslist = markers.childNodes();
int maxchild = markerslist.count();
m_clipManager->getClipById(e.attribute("id"))->addSnapMarker(GenTime(e.attribute("time").toDouble()), e.attribute("comment"));
}
}
- mlt.removeChild(markers);
+ infoXml.removeChild(markers);
}
- m_document.removeChild(infoXmlNode);
+ setProfilePath(profileName);
+ mlt.removeChild(infoXml);
kDebug() << "Reading file: " << url.path() << ", found clips: " << producers.count();
}
}
}
}
}
- }
+ } else setProfilePath(profileName);
// Something went wrong, or a new file was requested: create a new project
if (!success) {
}
// Set the video profile (empty == default)
- setProfilePath(profileName);
// Make sure the project folder is usable
if (m_projectFolder.isEmpty() || !KIO::NetAccess::exists(m_projectFolder.path(), KIO::NetAccess::DestinationSide, parent)) {
{
QDomDocument sceneList;
sceneList.setContent(scene, true);
- QDomNode mlt = sceneList.elementsByTagName("mlt").at(0);
+ QDomElement mlt = sceneList.firstChildElement("mlt");
QDomElement addedXml = sceneList.createElement("kdenlivedoc");
mlt.appendChild(addedXml);
addedXml.setAttribute("projectfolder", m_projectFolder.path());
addedXml.setAttribute("zoom", m_zoom);
+ // Add profile info
+ QDomElement profileinfo = sceneList.createElement("profileinfo");
+ profileinfo.setAttribute("description", m_profile.description);
+ profileinfo.setAttribute("frame_rate_num", m_profile.frame_rate_num);
+ profileinfo.setAttribute("frame_rate_den", m_profile.frame_rate_den);
+ profileinfo.setAttribute("width", m_profile.width);
+ profileinfo.setAttribute("height", m_profile.height);
+ profileinfo.setAttribute("progressive", m_profile.progressive);
+ profileinfo.setAttribute("sample_aspect_num", m_profile.sample_aspect_num);
+ profileinfo.setAttribute("sample_aspect_den", m_profile.sample_aspect_den);
+ profileinfo.setAttribute("display_aspect_num", m_profile.display_aspect_num);
+ profileinfo.setAttribute("display_aspect_den", m_profile.display_aspect_den);
+ addedXml.appendChild(profileinfo);
+
// tracks info
QDomElement tracksinfo = sceneList.createElement("tracksinfo");
foreach(const TrackInfo &info, m_tracksList) {
if (path.isEmpty()) path = KdenliveSettings::default_profile();
if (path.isEmpty()) path = "dv_pal";
m_profile = ProfilesDialog::getVideoProfile(path);
+ if (m_profile.path.isEmpty()) {
+ // Profile not found, use embedded profile
+ QDomElement profileInfo = m_document.elementsByTagName("profileinfo").at(0).toElement();
+ if (profileInfo.isNull()) {
+ KMessageBox::information(kapp->activeWindow(), i18n("Project profile was not found, using default profile."), i18n("Missing Profile"));
+ m_profile = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
+ } else {
+ KMessageBox::information(kapp->activeWindow(), i18n("Project profile was not found, it will be added to your system now."), i18n("Missing Profile"));
+ m_profile.description = profileInfo.attribute("description");
+ m_profile.frame_rate_num = profileInfo.attribute("frame_rate_num").toInt();
+ m_profile.frame_rate_den = profileInfo.attribute("frame_rate_den").toInt();
+ m_profile.width = profileInfo.attribute("width").toInt();
+ m_profile.height = profileInfo.attribute("height").toInt();
+ m_profile.progressive = profileInfo.attribute("progressive").toInt();
+ m_profile.sample_aspect_num = profileInfo.attribute("sample_aspect_num").toInt();
+ m_profile.sample_aspect_den = profileInfo.attribute("sample_aspect_den").toInt();
+ m_profile.display_aspect_num = profileInfo.attribute("display_aspect_num").toInt();
+ m_profile.display_aspect_den = profileInfo.attribute("display_aspect_den").toInt();
+ ProfilesDialog::saveProfile(m_profile);
+ setModified(true);
+ }
+ }
+
KdenliveSettings::setProject_display_ratio((double) m_profile.display_aspect_num / m_profile.display_aspect_den);
m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
KdenliveSettings::setProject_fps(m_fps);
profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
if (profilesFiles.contains(name)) path = KdenliveSettings::mltpath() + '/' + name;
}
- if (isCustom || path.isEmpty()) {
+ if (isCustom || path.isEmpty()) {
path = name;
}
return result;
}
if (name == KdenliveSettings::default_profile()) KdenliveSettings::setDefault_profile("dv_pal");
- kDebug() << "// WARNING, COULD NOT FIND PROFILE " << name;
- return getVideoProfile("dv_pal");
+ kDebug() << "// WARNING, COULD NOT FIND PROFILE " << name;
+ return result;
}
KConfig confFile(path, KConfig::SimpleConfig);
result.path = name;
return QString();
}
+// static
+void ProfilesDialog::saveProfile(MltVideoProfile &profile)
+{
+ int i = 0;
+ QString customName = "profiles/customprofile";
+ QString profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
+ kDebug() << " TYING PROFILE FILE: " << profilePath;
+ while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, 0)) {
+ i++;
+ profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
+ }
+ QFile file(profilePath);
+ if (!file.open(QIODevice::WriteOnly)) {
+ KMessageBox::sorry(0, i18n("Cannot write to file %1", profilePath));
+ return;
+ }
+ QTextStream out(&file);
+ out << "description=" << profile.description << "\n" << "frame_rate_num=" << profile.frame_rate_num << "\n" << "frame_rate_den=" << profile.frame_rate_den << "\n" << "width=" << profile.width << "\n" << "height=" << profile.height << "\n" << "progressive=" << profile.progressive << "\n" << "sample_aspect_num=" << profile.sample_aspect_num << "\n" << "sample_aspect_den=" << profile.sample_aspect_den << "\n" << "display_aspect_num=" << profile.display_aspect_num << "\n" << "display_aspect_den=" << profile.display_aspect_den << "\n";
+ if (file.error() != QFile::NoError) {
+ KMessageBox::error(0, i18n("Cannot write to file %1", profilePath));
+ }
+ file.close();
+ profile.path = profilePath;
+}
+
void ProfilesDialog::slotUpdateDisplay()
{