+void MainWindow::startWaitingRenderJobs()
+{
+
+}
+
+void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QString &chapterFile)
+{
+ if (m_activeDocument == NULL || m_renderWidget == NULL) return;
+ QString scriptPath;
+ QString playlistPath;
+ if (scriptExport) {
+ bool ok;
+ QString scriptsFolder = m_activeDocument->projectFolder().path() + "/scripts/";
+ QString path = m_renderWidget->getFreeScriptName();
+ scriptPath = QInputDialog::getText(this, i18n("Create Render Script"), i18n("Script name (will be saved in: %1)", scriptsFolder), QLineEdit::Normal, KUrl(path).fileName(), &ok);
+ if (!ok || scriptPath.isEmpty()) return;
+ scriptPath.prepend(scriptsFolder);
+ QFile f(scriptPath);
+ if (f.exists()) {
+ if (KMessageBox::warningYesNo(this, i18n("Script file already exists. Do you want to overwrite it?")) != KMessageBox::Yes)
+ return;
+ }
+ playlistPath = scriptPath + ".mlt";
+ m_projectMonitor->saveSceneList(playlistPath);
+ } else {
+ KTemporaryFile temp;
+ temp.setAutoRemove(false);
+ temp.setSuffix(".mlt");
+ temp.open();
+ playlistPath = temp.fileName();
+ m_projectMonitor->saveSceneList(playlistPath);
+ }
+
+ if (!chapterFile.isEmpty()) {
+ int in = 0;
+ int out;
+ if (!zoneOnly) out = (int) GenTime(m_activeDocument->projectDuration()).frames(m_activeDocument->fps());
+ else {
+ in = m_activeTimeline->inPoint();
+ out = m_activeTimeline->outPoint();
+ }
+ QDomDocument doc;
+ QDomElement chapters = doc.createElement("chapters");
+ chapters.setAttribute("fps", m_activeDocument->fps());
+ doc.appendChild(chapters);
+
+ QDomElement guidesxml = m_activeDocument->guidesXml();
+ QDomNodeList nodes = guidesxml.elementsByTagName("guide");
+ for (int i = 0; i < nodes.count(); i++) {
+ QDomElement e = nodes.item(i).toElement();
+ if (!e.isNull()) {
+ QString comment = e.attribute("comment");
+ int time = (int) GenTime(e.attribute("time").toDouble()).frames(m_activeDocument->fps());
+ if (time >= in && time < out) {
+ if (zoneOnly) time = time - in;
+ QDomElement chapter = doc.createElement("chapter");
+ chapters.appendChild(chapter);
+ chapter.setAttribute("title", comment);
+ chapter.setAttribute("time", time);
+ }
+ }
+ }
+ if (chapters.childNodes().count() > 0) {
+ if (m_activeTimeline->projectView()->hasGuide(out, 0) == -1) {
+ // Always insert a guide in pos 0
+ QDomElement chapter = doc.createElement("chapter");
+ chapters.insertBefore(chapter, QDomNode());
+ chapter.setAttribute("title", i18n("Start"));
+ chapter.setAttribute("time", "0");
+ }
+ // save chapters file
+ QFile file(chapterFile);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
+ } else {
+ file.write(doc.toString().toUtf8());
+ if (file.error() != QFile::NoError)
+ kWarning() << "////// ERROR writing DVD CHAPTER file: " << chapterFile;
+ file.close();
+ }
+ }
+ }
+
+ m_renderWidget->slotExport(scriptExport, m_activeTimeline->inPoint(), m_activeTimeline->outPoint(), playlistPath, scriptPath);
+}
+