+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();
+}
+
+void MainWindow::slotRevert()
+{
+ if (KMessageBox::warningContinueCancel(this, i18n("This will delete all changes made since you last saved your project. Are you sure you want to continue?"), i18n("Revert to last saved version")) == KMessageBox::Cancel) return;
+ KUrl url = m_activeDocument->url();
+ closeCurrentDocument(false);
+ doOpenFile(url, NULL);
+}
+
+
+void MainWindow::slotShutdown()
+{
+ if (m_activeDocument) m_activeDocument->setModified(false);
+ // Call shutdown
+ QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
+ if (interface && interface->isServiceRegistered("org.kde.ksmserver")) {
+ QDBusInterface smserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface");
+ smserver.call("logout", 1, 2, 2);
+ }
+}
+
+void MainWindow::slotUpdateTrackInfo()
+{
+ if (m_activeDocument)
+ m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList());
+}
+
+void MainWindow::slotChangePalette(QAction *action, const QString &themename)
+{
+ // Load the theme file
+ QString theme;
+ if (action == NULL) theme = themename;
+ else theme = action->data().toString();
+ KdenliveSettings::setColortheme(theme);
+ // Make palette for all widgets.
+ QPalette plt;
+ if (theme.isEmpty())
+ plt = QApplication::desktop()->palette();
+ else {
+ KSharedConfigPtr config = KSharedConfig::openConfig(theme);
+ plt = KGlobalSettings::createApplicationPalette(config);
+ }
+
+ kapp->setPalette(plt);
+ const QObjectList children = statusBar()->children();
+
+ foreach(QObject *child, children) {
+ if (child->isWidgetType())
+ ((QWidget*)child)->setPalette(plt);
+ const QObjectList subchildren = child->children();
+ foreach(QObject *subchild, subchildren) {
+ if (subchild->isWidgetType())
+ ((QWidget*)subchild)->setPalette(plt);
+ }
+ }
+}
+
+
+QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
+{
+ // code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
+ const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
+ const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
+ const QSize bitsSize(24, 2);
+ const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
+ const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
+
+ QPixmap pixmap(23, 16);
+ pixmap.fill(Qt::black); // ### use some color other than black for borders?
+
+ KConfigGroup group(config, "WM");
+ QPainter p(&pixmap);
+ KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
+ p.fillRect(1, 1, 7, 7, windowScheme.background());
+ p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
+
+ KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
+ p.fillRect(8, 1, 7, 7, buttonScheme.background());
+ p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
+
+ p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
+ p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
+
+ KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
+ p.fillRect(1, 8, 7, 7, viewScheme.background());
+ p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
+
+ KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
+ p.fillRect(8, 8, 7, 7, selectionScheme.background());
+ p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
+
+ p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
+ p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
+
+ p.end();
+ return pixmap;
+}
+
+void MainWindow::slotSwitchMonitors()
+{
+ m_monitorManager->slotSwitchMonitors();
+ if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus();
+ else m_projectList->focusTree();
+}
+