1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include <KStandardDirs>
22 #include <KMessageBox>
24 #include <KFileDialog>
25 #include <KIO/NetAccess>
26 #include <KApplication>
28 #include "kdenlivedoc.h"
29 #include "docclipbase.h"
30 #include "profilesdialog.h"
31 #include "kdenlivesettings.h"
33 #include "clipmanager.h"
34 #include "addfoldercommand.h"
35 #include "editfoldercommand.h"
36 #include "titlewidget.h"
37 #include "mainwindow.h"
40 KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_commandStack(new QUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(7) {
41 m_clipManager = new ClipManager(this);
44 if (KIO::NetAccess::download(url.path(), tmpFile, parent)) {
46 m_document.setContent(&file, false);
48 QDomNode infoXmlNode = m_document.elementsByTagName("kdenlivedoc").at(0);
49 QDomNode westley = m_document.elementsByTagName("westley").at(0);
50 if (!infoXmlNode.isNull()) {
51 QDomElement infoXml = infoXmlNode.toElement();
52 QString profilePath = infoXml.attribute("profile");
53 m_startPos = infoXml.attribute("position").toInt();
54 m_zoom = infoXml.attribute("zoom", "7").toInt();
55 setProfilePath(profilePath);
56 double version = infoXml.attribute("version").toDouble();
57 if (version < 0.7) convertDocument(version);
59 //delete all mlt producers and instead, use Kdenlive saved producers
60 QDomNodeList prods = m_document.elementsByTagName("producer");
61 int maxprod = prods.count();
63 for (int i = 0; i < maxprod; i++) {
64 QDomNode m = prods.at(pos);
65 QString prodId = m.toElement().attribute("id");
66 if (prodId == "black" || prodId.startsWith("slowmotion"))
68 else westley.removeChild(m);
70 prods = m_document.elementsByTagName("kdenlive_producer");
71 maxprod = prods.count();
72 for (int i = 0; i < maxprod; i++) {
73 prods.at(0).toElement().setTagName("producer");
74 westley.insertBefore(prods.at(0), QDomNode());
78 QDomNodeList producers = m_document.elementsByTagName("producer");
79 const int max = producers.count();
81 m_documentLoadingStep = 100.0 / (max + m_document.elementsByTagName("entry").count());
82 parent->slotGotProgressInfo(i18n("Loading project clips"), (int) m_documentLoadingProgress);
85 for (int i = 0; i < max; i++) {
86 e = producers.item(i).cloneNode().toElement();
87 if (m_documentLoadingStep > 0) {
88 m_documentLoadingProgress += m_documentLoadingStep;
89 parent->slotGotProgressInfo(QString(), (int) m_documentLoadingProgress);
90 qApp->processEvents();
92 QString prodId = e.attribute("id");
93 if (!e.isNull() && prodId != "black" && !prodId.startsWith("slowmotion")/*&& prodId.toInt() > 0*/) {
98 QDomNode markers = m_document.elementsByTagName("markers").at(0);
99 if (!markers.isNull()) {
100 QDomNodeList markerslist = markers.childNodes();
101 int maxchild = markerslist.count();
102 for (int k = 0; k < maxchild; k++) {
103 e = markerslist.at(k).toElement();
104 if (e.tagName() == "marker") {
105 m_clipManager->getClipById(e.attribute("id"))->addSnapMarker(GenTime(e.attribute("time").toDouble()), e.attribute("comment"));
108 westley.removeChild(markers);
110 m_document.removeChild(infoXmlNode);
112 kDebug() << "Reading file: " << url.path() << ", found clips: " << producers.count();
113 } else kWarning() << " NO KDENLIVE INFO FOUND IN FILE: " << url.path();
114 KIO::NetAccess::removeTempFile(tmpFile);
116 KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
119 // Creating new document
120 QDomElement westley = m_document.createElement("westley");
121 m_document.appendChild(westley);
123 QDomElement tractor = m_document.createElement("tractor");
124 tractor.setAttribute("id", "maintractor");
125 QDomElement multitrack = m_document.createElement("multitrack");
126 QDomElement playlist = m_document.createElement("playlist");
127 playlist.setAttribute("id", "black_track");
128 westley.appendChild(playlist);
134 int total = audiotracks + videotracks + 1;
136 for (int i = 1; i < total; i++) {
137 QDomElement playlist = m_document.createElement("playlist");
138 playlist.setAttribute("id", "playlist" + QString::number(i));
139 westley.appendChild(playlist);
142 QDomElement track0 = m_document.createElement("track");
143 track0.setAttribute("producer", "black_track");
144 tractor.appendChild(track0);
146 // create audio tracks
147 for (int i = 1; i < audiotracks + 1; i++) {
148 QDomElement track = m_document.createElement("track");
149 track.setAttribute("producer", "playlist" + QString::number(i));
150 track.setAttribute("hide", "video");
151 tractor.appendChild(track);
154 // create video tracks
155 for (int i = audiotracks + 1; i < total; i++) {
156 QDomElement track = m_document.createElement("track");
157 track.setAttribute("producer", "playlist" + QString::number(i));
158 tractor.appendChild(track);
161 for (uint i = 2; i < total ; i++) {
162 QDomElement transition = m_document.createElement("transition");
163 transition.setAttribute("always_active", "1");
165 QDomElement property = m_document.createElement("property");
166 property.setAttribute("name", "a_track");
167 QDomText value = m_document.createTextNode(QString::number(1));
168 property.appendChild(value);
169 transition.appendChild(property);
171 property = m_document.createElement("property");
172 property.setAttribute("name", "b_track");
173 value = m_document.createTextNode(QString::number(i));
174 property.appendChild(value);
175 transition.appendChild(property);
177 property = m_document.createElement("property");
178 property.setAttribute("name", "mlt_service");
179 value = m_document.createTextNode("mix");
180 property.appendChild(value);
181 transition.appendChild(property);
183 property = m_document.createElement("property");
184 property.setAttribute("name", "combine");
185 value = m_document.createTextNode("1");
186 property.appendChild(value);
187 transition.appendChild(property);
189 property = m_document.createElement("property");
190 property.setAttribute("name", "internal_added");
191 value = m_document.createTextNode("237");
192 property.appendChild(value);
193 transition.appendChild(property);
194 tractor.appendChild(transition);
196 westley.appendChild(tractor);
198 m_scenelist = m_document.toString();
199 kDebug() << "KDEnnlive document, init timecode: " << m_fps;
200 if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
201 else m_timecode.setFormat((int) m_fps);
203 m_autoSaveTimer = new QTimer(this);
204 m_autoSaveTimer->setSingleShot(true);
205 QString directory = m_url.directory();
206 QString fileName = m_url.fileName();
207 m_recoveryUrl.setDirectory(directory);
208 m_recoveryUrl.setFileName("~" + fileName);
209 connect(m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(slotAutoSave()));
212 KdenliveDoc::~KdenliveDoc() {
213 delete m_commandStack;
214 delete m_clipManager;
215 delete m_autoSaveTimer;
216 if (!m_url.isEmpty()) {
217 // remove backup file
218 if (KIO::NetAccess::exists(m_recoveryUrl, KIO::NetAccess::SourceSide, NULL))
219 KIO::NetAccess::del(m_recoveryUrl, NULL);
223 void KdenliveDoc::syncGuides(QList <Guide *> guides) {
227 m_guidesXml = doc.createElement("guides");
228 for (int i = 0; i < guides.count(); i++) {
229 e = doc.createElement("guide");
230 e.setAttribute("time", guides.at(i)->position().ms() / 1000);
231 e.setAttribute("comment", guides.at(i)->label());
232 m_guidesXml.appendChild(e);
236 void KdenliveDoc::slotAutoSave() {
238 m_render->saveSceneList(m_recoveryUrl.path(), documentInfoXml());
242 void KdenliveDoc::setZoom(int factor) {
246 int KdenliveDoc::zoom() const {
250 void KdenliveDoc::convertDocument(double version) {
251 // Opening a old Kdenlive document
252 QDomNode westley = m_document.elementsByTagName("westley").at(1);
253 QDomNode tractor = m_document.elementsByTagName("tractor").at(0);
254 QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
255 QDomNode multitrack = m_document.elementsByTagName("multitrack").at(0);
256 QDomNodeList playlists = m_document.elementsByTagName("playlist");
258 m_startPos = kdenlivedoc.toElement().attribute("timeline_position").toInt();
260 QDomNode props = m_document.elementsByTagName("properties").at(0).toElement();
261 QString profile = props.toElement().attribute("videoprofile");
262 if (profile == "dv_wide") profile = "dv_pal_wide";
263 setProfilePath(profile);
265 // move playlists outside of tractor and add the tracks instead
266 int max = playlists.count();
267 for (int i = 0; i < max; i++) {
268 QDomNode n = playlists.at(i);
269 westley.insertBefore(n, QDomNode());
270 QDomElement pl = n.toElement();
271 QDomElement track = m_document.createElement("track");
272 QString trackType = pl.attribute("hide");
273 if (!trackType.isEmpty()) track.setAttribute("hide", trackType);
274 QString playlist_id = pl.attribute("id");
275 if (playlist_id.isEmpty()) {
276 playlist_id = "black_track";
277 pl.setAttribute("id", playlist_id);
279 track.setAttribute("producer", playlist_id);
280 //tractor.appendChild(track);
281 tractor.insertAfter(track, QDomNode());
283 tractor.removeChild(multitrack);
285 // audio track mixing transitions should not be added to track view, so add required attribute
286 QDomNodeList transitions = m_document.elementsByTagName("transition");
287 max = transitions.count();
288 for (int i = 0; i < max; i++) {
289 QDomElement tr = transitions.at(i).toElement();
290 if (tr.attribute("combine") == "1" && tr.attribute("mlt_service") == "mix") {
291 QDomElement property = m_document.createElement("property");
292 property.setAttribute("name", "internal_added");
293 QDomText value = m_document.createTextNode("237");
294 property.appendChild(value);
295 tr.appendChild(property);
297 // convert transition
298 QDomNamedNodeMap attrs = tr.attributes();
299 for (unsigned int j = 0; j < attrs.count(); j++) {
300 QString attrName = attrs.item(j).nodeName();
301 if (attrName != "in" && attrName != "out" && attrName != "id") {
302 QDomElement property = m_document.createElement("property");
303 property.setAttribute("name", attrName);
304 QDomText value = m_document.createTextNode(attrs.item(j).nodeValue());
305 property.appendChild(value);
306 tr.appendChild(property);
312 // move transitions after tracks
313 for (int i = 0; i < max; i++) {
314 tractor.insertAfter(transitions.at(0), QDomNode());
317 // Fix filters format
318 QDomNodeList entries = m_document.elementsByTagName("entry");
319 max = entries.count();
320 for (int i = 0; i < max; i++) {
323 QDomNode m = entries.at(i).firstChild();
324 while (!m.isNull()) {
325 if (m.toElement().tagName() == "filter") {
326 QDomElement filt = m.toElement();
327 QDomNamedNodeMap attrs = filt.attributes();
328 QString current_id = filt.attribute("kdenlive_id");
329 if (current_id != last_id) {
331 last_id = current_id;
333 QDomElement e = m_document.createElement("property");
334 e.setAttribute("name", "kdenlive_ix");
335 QDomText value = m_document.createTextNode(QString::number(effectix));
336 e.appendChild(value);
338 for (int j = 0; j < attrs.count(); j++) {
339 QDomAttr a = attrs.item(j).toAttr();
341 kDebug() << " FILTER; adding :" << a.name() << ":" << a.value();
342 QDomElement e = m_document.createElement("property");
343 e.setAttribute("name", a.name());
344 QDomText value = m_document.createTextNode(a.value());
345 e.appendChild(value);
356 QDomNodeList filters = m_document.elementsByTagName("filter");
357 max = filters.count();
360 for (int i = 0; i < max; i++) {
361 QDomElement filt = filters.at(i).toElement();
362 QDomNamedNodeMap attrs = filt.attributes();
363 QString current_id = filt.attribute("kdenlive_id");
364 if (current_id != last_id) {
366 last_id = current_id;
368 QDomElement e = m_document.createElement("property");
369 e.setAttribute("name", "kdenlive_ix");
370 QDomText value = m_document.createTextNode(QString::number(1));
371 e.appendChild(value);
373 for (int j = 0; j < attrs.count(); j++) {
374 QDomAttr a = attrs.item(j).toAttr();
376 kDebug() << " FILTER; adding :" << a.name() << ":" << a.value();
377 QDomElement e = m_document.createElement("property");
378 e.setAttribute("name", a.name());
379 QDomText value = m_document.createTextNode(a.value());
380 e.appendChild(value);
387 QDomNodeList producers = westley.toElement().elementsByTagName("producer");
388 max = producers.count();
389 for (int i = 0; i < max; i++) {
390 QDomElement prod = producers.at(i).toElement();
391 if (prod.attribute("mlt_service") == "framebuffer") {
392 QString slowmotionprod = prod.attribute("resource");
393 slowmotionprod.replace(':', '?');
394 kDebug() << "// FOUND WRONG SLOWMO, new: " << slowmotionprod;
395 prod.setAttribute("resource", slowmotionprod);
399 // move producers to correct place, markers to a global list, fix clip descriptions
400 QDomElement markers = m_document.createElement("markers");
401 producers = m_document.elementsByTagName("producer");
402 max = producers.count();
403 for (int i = 0; i < max; i++) {
404 QDomElement prod = producers.at(0).toElement();
405 QDomNode m = prod.firstChild();
406 if (!m.isNull() && m.toElement().tagName() == "markers") {
407 QDomNodeList prodchilds = m.childNodes();
408 int maxchild = prodchilds.count();
409 for (int k = 0; k < maxchild; k++) {
410 QDomElement mark = prodchilds.at(0).toElement();
411 mark.setAttribute("id", prod.attribute("id"));
412 markers.insertAfter(mark, QDomNode());
415 } else if (m.isText()) {
416 QString comment = m.nodeValue();
417 if (!comment.isEmpty()) {
418 prod.setAttribute("description", comment);
422 int duration = prod.attribute("duration").toInt();
423 if (duration > 0) prod.setAttribute("out", QString::number(duration));
424 westley.insertBefore(prod, QDomNode());
427 QDomNode westley0 = m_document.elementsByTagName("westley").at(0);
428 if (!markers.firstChild().isNull()) westley0.appendChild(markers);
429 westley0.removeChild(kdenlivedoc);
431 QDomNodeList elements = westley.childNodes();
432 max = elements.count();
433 for (int i = 0; i < max; i++) {
434 QDomElement prod = elements.at(0).toElement();
435 westley0.insertAfter(prod, QDomNode());
438 westley0.removeChild(westley);
440 //kDebug() << "///////////////// CONVERTED DOC:";
441 //kDebug() << m_document.toString();
442 //kDebug() << "///////////////// END CONVERTED DOC:";
445 QDomElement KdenliveDoc::documentInfoXml() {
448 QDomElement addedXml = doc.createElement("kdenlivedoc");
449 QDomElement markers = doc.createElement("markers");
450 addedXml.setAttribute("version", "0.7");
451 addedXml.setAttribute("profile", profilePath());
452 addedXml.setAttribute("position", m_render->seekPosition().frames(m_fps));
453 addedXml.setAttribute("zoom", m_zoom);
454 QList <DocClipBase*> list = m_clipManager->documentClipList();
455 for (int i = 0; i < list.count(); i++) {
456 e = list.at(i)->toXML();
457 e.setTagName("kdenlive_producer");
458 addedXml.appendChild(doc.importNode(e, true));
459 QList < CommentedTime > marks = list.at(i)->commentedSnapMarkers();
460 for (int j = 0; j < marks.count(); j++) {
461 QDomElement marker = doc.createElement("marker");
462 marker.setAttribute("time", marks.at(j).time().ms() / 1000);
463 marker.setAttribute("comment", marks.at(j).comment());
464 marker.setAttribute("id", e.attribute("id"));
465 markers.appendChild(marker);
468 addedXml.appendChild(markers);
469 if (!m_guidesXml.isNull()) addedXml.appendChild(doc.importNode(m_guidesXml, true));
470 //kDebug() << m_document.toString();
475 ClipManager *KdenliveDoc::clipManager() {
476 return m_clipManager;
479 KUrl KdenliveDoc::projectFolder() const {
480 if (m_projectFolder.isEmpty()) return KUrl(KStandardDirs::locateLocal("appdata", "/projects/"));
481 return m_projectFolder;
484 QString KdenliveDoc::getDocumentStandard() {
485 //WARNING: this way to tell the video standard is a bit hackish...
486 if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) return "PAL";
490 QString KdenliveDoc::profilePath() const {
491 return m_profile.path;
494 void KdenliveDoc::setProfilePath(QString path) {
495 if (path.isEmpty()) path = KdenliveSettings::default_profile();
496 if (path.isEmpty()) path = "dv_pal";
497 m_profile = ProfilesDialog::getVideoProfile(path);
498 KdenliveSettings::setProject_display_ratio((double) m_profile.display_aspect_num / m_profile.display_aspect_den);
499 m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
500 m_width = m_profile.width;
501 m_height = m_profile.height;
502 kDebug() << "KDEnnlive document, init timecode from path: " << path << ", " << m_fps;
503 if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
504 else m_timecode.setFormat((int) m_fps);
507 const double KdenliveDoc::dar() {
508 return (double) m_profile.display_aspect_num / m_profile.display_aspect_den;
511 void KdenliveDoc::setThumbsProgress(const QString &message, int progress) {
512 emit progressInfo(message, progress);
515 void KdenliveDoc::loadingProgressed() {
516 m_documentLoadingProgress += m_documentLoadingStep;
517 emit progressInfo(QString(), (int) m_documentLoadingProgress);
520 QUndoStack *KdenliveDoc::commandStack() {
521 return m_commandStack;
524 void KdenliveDoc::setRenderer(Render *render) {
526 emit progressInfo(i18n("Loading playlist..."), 0);
527 qApp->processEvents();
528 if (m_render) m_render->setSceneList(m_document.toString(), m_startPos);
529 emit progressInfo(QString(), -1);
532 Render *KdenliveDoc::renderer() {
536 void KdenliveDoc::updateClip(const QString &id) {
537 emit updateClipDisplay(id);
540 void KdenliveDoc::updateAllProjectClips() {
541 QList <DocClipBase*> list = m_clipManager->documentClipList();
542 for (int i = 0; i < list.count(); i++)
543 emit updateClipDisplay(list.at(i)->getId());
546 int KdenliveDoc::getFramePos(QString duration) {
547 return m_timecode.getFrameCount(duration, m_fps);
550 QString KdenliveDoc::producerName(const QString &id) {
551 QString result = "unnamed";
552 QDomNodeList prods = producersList();
553 int ct = prods.count();
554 for (int i = 0; i < ct ; i++) {
555 QDomElement e = prods.item(i).toElement();
556 if (e.attribute("id") != "black" && e.attribute("id") == id) {
557 result = e.attribute("name");
558 if (result.isEmpty()) result = KUrl(e.attribute("resource")).fileName();
565 void KdenliveDoc::setProducerDuration(const QString &id, int duration) {
566 QDomNodeList prods = producersList();
567 int ct = prods.count();
568 for (int i = 0; i < ct ; i++) {
569 QDomElement e = prods.item(i).toElement();
570 if (e.attribute("id") != "black" && e.attribute("id") == id) {
571 e.setAttribute("duration", QString::number(duration));
577 int KdenliveDoc::getProducerDuration(const QString &id) {
579 QDomNodeList prods = producersList();
580 int ct = prods.count();
581 for (int i = 0; i < ct ; i++) {
582 QDomElement e = prods.item(i).toElement();
583 if (e.attribute("id") != "black" && e.attribute("id") == id) {
584 result = e.attribute("duration").toInt();
592 QDomDocument KdenliveDoc::generateSceneList() {
594 QDomElement westley = doc.createElement("westley");
595 doc.appendChild(westley);
596 QDomElement prod = doc.createElement("producer");
599 QDomDocument KdenliveDoc::toXml() const {
603 Timecode KdenliveDoc::timecode() const {
607 QDomNodeList KdenliveDoc::producersList() {
608 return m_document.elementsByTagName("producer");
611 void KdenliveDoc::backupMltPlaylist() {
612 if (m_render) m_scenelist = m_render->sceneList();
615 double KdenliveDoc::fps() const {
619 int KdenliveDoc::width() const {
623 int KdenliveDoc::height() const {
627 KUrl KdenliveDoc::url() const {
631 void KdenliveDoc::setUrl(KUrl url) {
633 QString directory = m_url.directory();
634 QString fileName = m_url.fileName();
635 m_recoveryUrl.setDirectory(directory);
636 m_recoveryUrl.setFileName("~" + fileName);
639 void KdenliveDoc::setModified(bool mod) {
640 if (!m_url.isEmpty() && mod && KdenliveSettings::crashrecovery()) {
641 m_autoSaveTimer->start(3000);
643 if (mod == m_modified) return;
645 emit docModified(m_modified);
648 bool KdenliveDoc::isModified() const {
652 QString KdenliveDoc::description() const {
654 return i18n("Untitled") + " / " + m_profile.description;
656 return m_url.fileName() + " / " + m_profile.description;
659 void KdenliveDoc::addClip(const QDomElement &elem, const QString &clipId) {
660 DocClipBase *clip = new DocClipBase(m_clipManager, elem, clipId);
661 kDebug() << "///////// DOCUM, CREATING NEW CLIP, ID:" << clipId << ", PAR ID:" << elem.attribute("groupid");
662 m_clipManager->addClip(clip);
663 emit addProjectClip(clip);
666 void KdenliveDoc::addFolder(const QString foldername, const QString &clipId, bool edit) {
667 emit addProjectFolder(foldername, clipId, false, edit);
670 void KdenliveDoc::deleteFolder(const QString foldername, const QString &clipId) {
671 emit addProjectFolder(foldername, clipId, true);
674 void KdenliveDoc::deleteProjectClip(QList <QString> ids) {
675 for (int i = 0; i < ids.size(); ++i) {
676 emit deleteTimelineClip(ids.at(i));
677 m_clipManager->slotDeleteClip(ids.at(i));
682 void KdenliveDoc::deleteProjectFolder(QMap <QString, QString> map) {
683 QMapIterator<QString, QString> i(map);
684 while (i.hasNext()) {
686 slotDeleteFolder(i.key(), i.value());
691 void KdenliveDoc::deleteClip(const QString &clipId) {
692 emit signalDeleteProjectClip(clipId);
693 m_clipManager->deleteClip(clipId);
696 void KdenliveDoc::slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId) {
697 m_clipManager->slotAddClipList(urls, group, groupId);
698 emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
703 void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const QString &groupId) {
704 kDebug() << "///////// DOCUM, ADD CLP: " << url;
705 m_clipManager->slotAddClipFile(url, group, groupId);
706 emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
710 void KdenliveDoc::slotAddTextClipFile(const QString path, const QString xml, const QString group, const QString &groupId) {
711 kDebug() << "///////// DOCUM, ADD TXT CLP: " << path;
712 m_clipManager->slotAddTextClipFile(path, xml, group, groupId);
716 void KdenliveDoc::slotAddFolder(const QString folderName) {
717 AddFolderCommand *command = new AddFolderCommand(this, folderName, QString::number(m_clipManager->getFreeClipId()), true);
718 commandStack()->push(command);
722 void KdenliveDoc::slotDeleteFolder(const QString folderName, const QString &id) {
723 AddFolderCommand *command = new AddFolderCommand(this, folderName, id, false);
724 commandStack()->push(command);
728 void KdenliveDoc::slotEditFolder(const QString newfolderName, const QString oldfolderName, const QString &clipId) {
729 EditFolderCommand *command = new EditFolderCommand(this, newfolderName, oldfolderName, clipId, false);
730 commandStack()->push(command);
734 const QString&KdenliveDoc::getFreeClipId() {
735 return QString::number(m_clipManager->getFreeClipId());
738 DocClipBase *KdenliveDoc::getBaseClip(const QString &clipId) {
739 return m_clipManager->getClipById(clipId);
742 void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const QString &groupId) {
743 m_clipManager->slotAddColorClipFile(name, color, duration, group, groupId);
747 void KdenliveDoc::slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, const bool loop, const bool fade, const QString &luma_duration, const QString &luma_file, const int softness, const QString group, const QString &groupId) {
748 m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, fade, luma_duration, luma_file, softness, group, groupId);
752 void KdenliveDoc::slotCreateTextClip(QString group, const QString &groupId) {
753 QString titlesFolder = projectFolder().path() + "/titles/";
754 KStandardDirs::makeDir(titlesFolder);
755 TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, kapp->activeWindow());
756 if (dia_ui->exec() == QDialog::Accepted) {
757 QString titleName = "title";
759 QString path = titlesFolder + titleName + QString::number(counter).rightJustified(3, '0', false);
760 while (QFile::exists(path + ".kdenlivetitle")) {
762 path = titlesFolder + titleName + QString::number(counter).rightJustified(3, '0', false);
764 QPixmap pix = dia_ui->renderedPixmap();
765 pix.save(path + ".png");
766 //dia_ui->saveTitle(path + ".kdenlivetitle");
767 slotAddTextClipFile(path, dia_ui->xml().toString(), QString(), QString());
772 void KdenliveDoc::editTextClip(QString path, const QString &id) {
773 DocClipBase *clip = m_clipManager->getClipById(id);
775 TitleWidget *dia_ui = new TitleWidget(KUrl()/*path + ".kdenlivetitle")*/, path, m_render, kapp->activeWindow());
777 doc.setContent(clip->getProperty("xmldata"));
779 if (dia_ui->exec() == QDialog::Accepted) {
780 QPixmap pix = dia_ui->renderedPixmap();
781 pix.save(path + ".png");
782 //dia_ui->saveTitle(path + ".kdenlivetitle");
783 //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
784 emit refreshClipThumbnail(id);
790 #include "kdenlivedoc.moc"