+void MainWindow::loadTranscoders()
+{
+ QMenu *transMenu = static_cast<QMenu*>(factory()->container("transcoders", this));
+ transMenu->clear();
+
+ KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
+ KConfigGroup transConfig(config, "Transcoding");
+ // read the entries
+ QMap< QString, QString > profiles = transConfig.entryMap();
+ QMapIterator<QString, QString> i(profiles);
+ while (i.hasNext()) {
+ i.next();
+ QAction *a = transMenu->addAction(i.key());
+ a->setData(i.value());
+ connect(a, SIGNAL(triggered()), this, SLOT(slotTranscode()));
+ }
+}
+
+void MainWindow::slotTranscode(KUrl::List urls)
+{
+ QString params;
+ if (urls.isEmpty()) {
+ urls.append(m_projectList->currentClipUrl());
+ QAction *action = qobject_cast<QAction *>(sender());
+ params = action->data().toString();
+ }
+ if (urls.isEmpty()) return;
+ ClipTranscode *d = new ClipTranscode(urls, params);
+ connect(d, SIGNAL(addClip(KUrl)), this, SLOT(slotAddProjectClip(KUrl)));
+ d->show();
+ //QProcess::startDetached("ffmpeg", parameters);
+}
+
+void MainWindow::slotTranscodeClip()
+{
+ KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///projectfolder"));
+ if (urls.isEmpty()) return;
+ slotTranscode(urls);
+}
+
+void MainWindow::slotSetDocumentRenderProfile(const QString &dest, const QString &name, const QString &file)
+{
+ if (m_activeDocument == NULL) return;
+ m_activeDocument->setDocumentProperty("renderdestination", dest);
+ m_activeDocument->setDocumentProperty("renderprofile", name);
+ m_activeDocument->setDocumentProperty("renderurl", file);
+ m_activeDocument->setModified(true);
+}
+
+
+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);
+}
+
+void MainWindow::slotUpdateTimecodeFormat(int ix)
+{
+ KdenliveSettings::setFrametimecode(ix == 1);
+ m_clipMonitor->updateTimecodeFormat();
+ m_projectMonitor->updateTimecodeFormat();
+}
+
+void MainWindow::slotRemoveFocus()
+{
+ statusBar()->setFocus();
+ statusBar()->clearFocus();
+}
+
+
+
+