]> git.sesse.net Git - kdenlive/blob - src/kdenlivedoc.cpp
NEW: Kdenlive can now create screencasts.
[kdenlive] / src / kdenlivedoc.cpp
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20 #include <KDebug>
21 #include <KStandardDirs>
22 #include <KMessageBox>
23 #include <KLocale>
24 #include <KFileDialog>
25 #include <KIO/NetAccess>
26 #include <KApplication>
27
28 #include "kdenlivedoc.h"
29 #include "docclipbase.h"
30 #include "profilesdialog.h"
31 #include "kdenlivesettings.h"
32 #include "renderer.h"
33 #include "clipmanager.h"
34 #include "addfoldercommand.h"
35 #include "editfoldercommand.h"
36 #include "titlewidget.h"
37 #include "mainwindow.h"
38
39 KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0) {
40         kDebug()<<"// init profile, ratnum: "<<profile.frame_rate_num<<", "<<profile.frame_rate_num<<", width: "<<profile.width;
41     m_clipManager = new ClipManager(this);
42     if (!url.isEmpty()) {
43         QString tmpFile;
44         if (KIO::NetAccess::download(url.path(), tmpFile, parent)) {
45             QFile file(tmpFile);
46             m_document.setContent(&file, false);
47             file.close();
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                 if (!profilePath.isEmpty()) setProfilePath(profilePath);
55                 double version = infoXml.attribute("version").toDouble();
56                 if (version < 0.7) convertDocument(version);
57                 else {
58                     //delete all mlt producers and instead, use Kdenlive saved producers
59                     QDomNodeList prods = m_document.elementsByTagName("producer");
60                     int maxprod = prods.count();
61                     int pos = 0;
62                     for (int i = 0; i < maxprod; i++) {
63                         QDomNode m = prods.at(pos);
64                         if (m.toElement().attribute("id") == "black")
65                             pos = 1;
66                         else westley.removeChild(m);
67                     }
68                     prods = m_document.elementsByTagName("kdenlive_producer");
69                     maxprod = prods.count();
70                     for (int i = 0; i < maxprod; i++) {
71                         prods.at(0).toElement().setTagName("producer");
72                         westley.insertBefore(prods.at(0), QDomNode());
73                     }
74                 }
75                 QDomElement e;
76                 QDomNodeList producers = m_document.elementsByTagName("producer");
77                 const int max = producers.count();
78                 if (max > 0) {
79                     m_documentLoadingStep = 100.0 / (max + m_document.elementsByTagName("entry").count());
80                     parent->slotGotProgressInfo(i18n("Loading project clips"), (int) m_documentLoadingProgress);
81                 }
82
83                 for (int i = 0; i < max; i++) {
84                     e = producers.item(i).cloneNode().toElement();
85                     if (m_documentLoadingStep > 0) {
86                         m_documentLoadingProgress += m_documentLoadingStep;
87                         parent->slotGotProgressInfo(QString(), (int) m_documentLoadingProgress);
88                         qApp->processEvents();
89                     }
90                     if (!e.isNull() && e.attribute("id") != "black") {
91                         addClip(e, e.attribute("id").toInt());
92                     }
93                 }
94
95                 QDomNode markers = m_document.elementsByTagName("markers").at(0);
96                 if (!markers.isNull()) {
97                     QDomNodeList markerslist = markers.childNodes();
98                     int maxchild = markerslist.count();
99                     for (int k = 0; k < maxchild; k++) {
100                         e = markerslist.at(k).toElement();
101                         if (e.tagName() == "marker") {
102                             int id = e.attribute("id").toInt();
103                             m_clipManager->getClipById(id)->addSnapMarker(GenTime(e.attribute("time").toDouble()), e.attribute("comment"));
104                         }
105                     }
106                     m_document.removeChild(markers);
107                 }
108                 m_document.removeChild(infoXmlNode);
109
110                 kDebug() << "Reading file: " << url.path() << ", found clips: " << producers.count();
111             } else kWarning() << "  NO KDENLIVE INFO FOUND IN FILE: " << url.path();
112             KIO::NetAccess::removeTempFile(tmpFile);
113         } else {
114             KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
115         }
116     } else {
117         // Creating new document
118         QDomElement westley = m_document.createElement("westley");
119         m_document.appendChild(westley);
120
121         QDomElement tractor = m_document.createElement("tractor");
122         tractor.setAttribute("id", "maintractor");
123         QDomElement multitrack = m_document.createElement("multitrack");
124         QDomElement playlist = m_document.createElement("playlist");
125         playlist.setAttribute("id", "black_track");
126         westley.appendChild(playlist);
127
128
129         // create playlists
130         int audiotracks = 2;
131         int videotracks = 3;
132         int total = audiotracks + videotracks + 1;
133
134         for (int i = 1; i < total; i++) {
135             QDomElement playlist = m_document.createElement("playlist");
136             playlist.setAttribute("id", "playlist" + QString::number(i));
137             westley.appendChild(playlist);
138         }
139
140         QDomElement track0 = m_document.createElement("track");
141         track0.setAttribute("producer", "black_track");
142         tractor.appendChild(track0);
143
144         // create audio tracks
145         for (int i = 1; i < audiotracks + 1; i++) {
146             QDomElement track = m_document.createElement("track");
147             track.setAttribute("producer", "playlist" + QString::number(i));
148             track.setAttribute("hide", "video");
149             tractor.appendChild(track);
150         }
151
152         // create video tracks
153         for (int i = audiotracks + 1; i < total; i++) {
154             QDomElement track = m_document.createElement("track");
155             track.setAttribute("producer", "playlist" + QString::number(i));
156             tractor.appendChild(track);
157         }
158
159         for (uint i = 2; i < total ; i++) {
160             QDomElement transition = m_document.createElement("transition");
161             transition.setAttribute("in", "0");
162             //TODO: Make audio mix last for all project duration
163             transition.setAttribute("out", "15000");
164
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);
170
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);
176
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);
182
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);
188
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);
195         }
196         westley.appendChild(tractor);
197     }
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);
202 }
203
204 KdenliveDoc::~KdenliveDoc() {
205     delete m_commandStack;
206     delete m_clipManager;
207 }
208
209 void KdenliveDoc::convertDocument(double version) {
210     // Opening a old Kdenlive document
211     QDomNode westley = m_document.elementsByTagName("westley").at(1);
212     QDomNode tractor = m_document.elementsByTagName("tractor").at(0);
213     QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
214     QDomNode multitrack = m_document.elementsByTagName("multitrack").at(0);
215     QDomNodeList playlists = m_document.elementsByTagName("playlist");
216
217     QDomNode props = m_document.elementsByTagName("properties").at(0).toElement();
218     QString profile = props.toElement().attribute("videoprofile");
219     if (profile == "dv_wide") profile = "dv_pal_wide";
220     if (!profile.isEmpty()) {
221         setProfilePath(profile);
222     } else setProfilePath("dv_pal");
223
224     // move playlists outside of tractor and add the tracks instead
225     int max = playlists.count();
226     for (int i = 0; i < max; i++) {
227         QDomNode n = playlists.at(i);
228         westley.insertBefore(n, QDomNode());
229         QDomElement pl = n.toElement();
230         QDomElement track = m_document.createElement("track");
231         QString trackType = pl.attribute("hide");
232         if (!trackType.isEmpty()) track.setAttribute("hide", trackType);
233         QString playlist_id =  pl.attribute("id");
234         if (playlist_id.isEmpty()) {
235             playlist_id = "black_track";
236             pl.setAttribute("id", playlist_id);
237         }
238         track.setAttribute("producer", playlist_id);
239         tractor.appendChild(track);
240     }
241     tractor.removeChild(multitrack);
242
243     // audio track mixing transitions should not be added to track view, so add required attribute
244     QDomNodeList transitions = m_document.elementsByTagName("transition");
245     max = transitions.count();
246     for (int i = 0; i < max; i++) {
247         QDomElement tr = transitions.at(i).toElement();
248         if (tr.attribute("combine") == "1" && tr.attribute("mlt_service") == "mix") {
249             QDomElement property = m_document.createElement("property");
250             property.setAttribute("name", "internal_added");
251             QDomText value = m_document.createTextNode("237");
252             property.appendChild(value);
253             tr.appendChild(property);
254         } else {
255             // convert transition
256             QDomNamedNodeMap attrs = tr.attributes();
257             for (unsigned int j = 0; j < attrs.count(); j++) {
258                 QString attrName = attrs.item(j).nodeName();
259                 if (attrName != "in" && attrName != "out" && attrName != "id") {
260                     QDomElement property = m_document.createElement("property");
261                     property.setAttribute("name", attrName);
262                     QDomText value = m_document.createTextNode(attrs.item(j).nodeValue());
263                     property.appendChild(value);
264                     tr.appendChild(property);
265                 }
266             }
267         }
268     }
269
270     // move transitions after tracks
271     for (int i = 0; i < max; i++) {
272         tractor.insertAfter(transitions.at(0), QDomNode());
273     }
274
275     QDomElement markers = m_document.createElement("markers");
276
277     // change producer names
278     QDomNodeList producers = m_document.elementsByTagName("producer");
279     max = producers.count();
280     for (int i = 0; i < max; i++) {
281         QDomElement prod = producers.at(0).toElement();
282         QDomNode m = prod.firstChild();
283         if (!m.isNull() && m.toElement().tagName() == "markers") {
284             QDomNodeList prodchilds = m.childNodes();
285             int maxchild = prodchilds.count();
286             for (int k = 0; k < maxchild; k++) {
287                 QDomElement mark = prodchilds.at(0).toElement();
288                 mark.setAttribute("id", prod.attribute("id"));
289                 markers.insertAfter(mark, QDomNode());
290             }
291             prod.removeChild(m);
292         }
293         int duration = prod.attribute("duration").toInt();
294         if (duration > 0) prod.setAttribute("out", QString::number(duration));
295         westley.insertBefore(prod, QDomNode());
296     }
297
298     QDomNode westley0 = m_document.elementsByTagName("westley").at(0);
299     if (!markers.firstChild().isNull()) westley0.appendChild(markers);
300     westley0.removeChild(kdenlivedoc);
301
302     QDomNodeList elements = westley.childNodes();
303     max = elements.count();
304     for (int i = 0; i < max; i++) {
305         QDomElement prod = elements.at(0).toElement();
306         westley0.insertAfter(prod, QDomNode());
307     }
308
309     westley0.removeChild(westley);
310
311     //kDebug() << "/////////////////  CONVERTED DOC:";
312     //kDebug() << m_document.toString();
313     //kDebug() << "/////////////////  END CONVERTED DOC:";
314 }
315
316 QDomElement KdenliveDoc::documentInfoXml(QDomElement timelineInfo) {
317     QDomDocument doc;
318     QDomElement e;
319     QDomElement addedXml = doc.createElement("kdenlivedoc");
320     QDomElement markers = doc.createElement("markers");
321     addedXml.setAttribute("version", "0.7");
322     addedXml.setAttribute("profile", profilePath());
323     addedXml.setAttribute("position", m_render->seekPosition().frames(m_fps));
324     QList <DocClipBase*> list = m_clipManager->documentClipList();
325     for (int i = 0; i < list.count(); i++) {
326         e = list.at(i)->toXML();
327         e.setTagName("kdenlive_producer");
328         addedXml.appendChild(doc.importNode(e, true));
329         QList < CommentedTime > marks = list.at(i)->commentedSnapMarkers();
330         for (int j = 0; j < marks.count(); j++) {
331             QDomElement marker = doc.createElement("marker");
332             marker.setAttribute("time", marks.at(j).time().ms() / 1000);
333             marker.setAttribute("comment", marks.at(j).comment());
334             marker.setAttribute("id", e.attribute("id"));
335             markers.appendChild(marker);
336         }
337     }
338     addedXml.appendChild(markers);
339     addedXml.appendChild(doc.importNode(timelineInfo, true));
340     //kDebug() << m_document.toString();
341     return addedXml;
342 }
343
344
345 ClipManager *KdenliveDoc::clipManager() {
346     return m_clipManager;
347 }
348
349 KUrl KdenliveDoc::projectFolder() const {
350     if (m_projectFolder.isEmpty()) return KUrl(KStandardDirs::locateLocal("appdata", "/projects/"));
351     return m_projectFolder;
352 }
353
354 QString KdenliveDoc::getDocumentStandard() {
355     //WARNING: this way to tell the video standard is a bit hackish...
356     if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) return "PAL";
357     return "NTSC";
358 }
359
360 QString KdenliveDoc::profilePath() const {
361     return m_profile.path;
362 }
363
364 void KdenliveDoc::setProfilePath(QString path) {
365     KdenliveSettings::setCurrent_profile(path);
366     m_profile = ProfilesDialog::getVideoProfile(path);
367     m_fps = (double) m_profile.frame_rate_num / m_profile.frame_rate_den;
368     m_width = m_profile.width;
369     m_height = m_profile.height;
370     kDebug() << "KDEnnlive document, init timecode from path: "<<path<<",  "<<m_fps;
371     if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
372     else m_timecode.setFormat((int) m_fps);
373 }
374
375 void KdenliveDoc::setThumbsProgress(const QString &message, int progress) {
376     emit progressInfo(message, progress);
377 }
378
379 void KdenliveDoc::loadingProgressed() {
380     m_documentLoadingProgress += m_documentLoadingStep;
381     emit progressInfo(QString(), (int) m_documentLoadingProgress);
382 }
383
384 KUndoStack *KdenliveDoc::commandStack() {
385     return m_commandStack;
386 }
387
388 void KdenliveDoc::setRenderer(Render *render) {
389     m_render = render;
390     emit progressInfo(i18n("Loading playlist..."), 0);
391     qApp->processEvents();
392     if (m_render) m_render->setSceneList(m_scenelist, m_startPos);
393     emit progressInfo(QString(), -1);
394 }
395
396 Render *KdenliveDoc::renderer() {
397     return m_render;
398 }
399
400 void KdenliveDoc::updateClip(int id) {
401     emit updateClipDisplay(id);
402 }
403
404 int KdenliveDoc::getFramePos(QString duration) {
405     return m_timecode.getFrameCount(duration, m_fps);
406 }
407
408 QString KdenliveDoc::producerName(int id) {
409     QString result = "unnamed";
410     QDomNodeList prods = producersList();
411     int ct = prods.count();
412     for (int i = 0; i <  ct ; i++) {
413         QDomElement e = prods.item(i).toElement();
414         if (e.attribute("id") != "black" && e.attribute("id").toInt() == id) {
415             result = e.attribute("name");
416             if (result.isEmpty()) result = KUrl(e.attribute("resource")).fileName();
417             break;
418         }
419     }
420     return result;
421 }
422
423 void KdenliveDoc::setProducerDuration(int id, int duration) {
424     QDomNodeList prods = producersList();
425     int ct = prods.count();
426     for (int i = 0; i <  ct ; i++) {
427         QDomElement e = prods.item(i).toElement();
428         if (e.attribute("id") != "black" && e.attribute("id").toInt() == id) {
429             e.setAttribute("duration", QString::number(duration));
430             break;
431         }
432     }
433 }
434
435 int KdenliveDoc::getProducerDuration(int id) {
436     int result = 0;
437     QDomNodeList prods = producersList();
438     int ct = prods.count();
439     for (int i = 0; i <  ct ; i++) {
440         QDomElement e = prods.item(i).toElement();
441         if (e.attribute("id") != "black" && e.attribute("id").toInt() == id) {
442             result = e.attribute("duration").toInt();
443             break;
444         }
445     }
446     return result;
447 }
448
449
450 QDomDocument KdenliveDoc::generateSceneList() {
451     QDomDocument doc;
452     QDomElement westley = doc.createElement("westley");
453     doc.appendChild(westley);
454     QDomElement prod = doc.createElement("producer");
455 }
456
457 QDomDocument KdenliveDoc::toXml() const {
458     return m_document;
459 }
460
461 Timecode KdenliveDoc::timecode() const {
462     return m_timecode;
463 }
464
465 QDomNodeList KdenliveDoc::producersList() {
466     return m_document.elementsByTagName("producer");
467 }
468
469 void KdenliveDoc::backupMltPlaylist() {
470     if (m_render) m_scenelist = m_render->sceneList();
471 }
472
473 double KdenliveDoc::fps() const {
474     return m_fps;
475 }
476
477 int KdenliveDoc::width() const {
478     return m_width;
479 }
480
481 int KdenliveDoc::height() const {
482     return m_height;
483 }
484
485 KUrl KdenliveDoc::url() const {
486     return m_url;
487 }
488
489 void KdenliveDoc::setUrl(KUrl url) {
490     m_url = url;
491 }
492
493 void KdenliveDoc::setModified(bool mod) {
494     if (mod == m_modified) return;
495     m_modified = mod;
496     emit docModified(m_modified);
497 }
498
499 bool KdenliveDoc::isModified() const {
500     return m_modified;
501 }
502
503 QString KdenliveDoc::description() const {
504     if (m_url.isEmpty())
505         return i18n("Untitled") + " / " + m_profile.description;
506     else
507         return m_url.fileName() + " / " + m_profile.description;
508 }
509
510 void KdenliveDoc::addClip(const QDomElement &elem, const int clipId) {
511     DocClipBase *clip = new DocClipBase(m_clipManager, elem, clipId);
512     kDebug() << "/////////  DOCUM, CREATING NEW CLIP, ID:" << clipId << ", PAR ID:" << elem.attribute("groupid");
513     m_clipManager->addClip(clip);
514     emit addProjectClip(clip);
515 }
516
517 void KdenliveDoc::addFolder(const QString foldername, int clipId, bool edit) {
518     emit addProjectFolder(foldername, clipId, false, edit);
519 }
520
521 void KdenliveDoc::deleteFolder(const QString foldername, int clipId) {
522     emit addProjectFolder(foldername, clipId, true);
523 }
524
525 void KdenliveDoc::deleteProjectClip(QList <int> ids) {
526     for (int i = 0; i < ids.size(); ++i) {
527         emit deletTimelineClip(ids.at(i));
528         m_clipManager->slotDeleteClip(ids.at(i));
529     }
530     setModified(true);
531 }
532
533 void KdenliveDoc::deleteProjectFolder(QMap <QString, int> map) {
534     QMapIterator<QString, int> i(map);
535     while (i.hasNext()) {
536         i.next();
537         slotDeleteFolder(i.key(), i.value());
538     }
539     setModified(true);
540 }
541
542 void KdenliveDoc::deleteClip(const uint clipId) {
543     emit signalDeleteProjectClip(clipId);
544     m_clipManager->deleteClip(clipId);
545 }
546
547 void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const int groupId) {
548     kDebug() << "/////////  DOCUM, ADD CLP: " << url;
549     m_clipManager->slotAddClipFile(url, group, groupId);
550     setModified(true);
551 }
552
553 void KdenliveDoc::slotAddTextClipFile(const QString path, const QString group, const int groupId) {
554     kDebug() << "/////////  DOCUM, ADD TXT CLP: " << path;
555     m_clipManager->slotAddTextClipFile(path, group, groupId);
556     setModified(true);
557 }
558
559 void KdenliveDoc::slotAddFolder(const QString folderName) {
560     AddFolderCommand *command = new AddFolderCommand(this, folderName, m_clipManager->getFreeClipId(), true);
561     commandStack()->push(command);
562     setModified(true);
563 }
564
565 void KdenliveDoc::slotDeleteFolder(const QString folderName, const int id) {
566     AddFolderCommand *command = new AddFolderCommand(this, folderName, id, false);
567     commandStack()->push(command);
568     setModified(true);
569 }
570
571 void KdenliveDoc::slotEditFolder(const QString newfolderName, const QString oldfolderName, int clipId) {
572     EditFolderCommand *command = new EditFolderCommand(this, newfolderName, oldfolderName, clipId, false);
573     commandStack()->push(command);
574     setModified(true);
575 }
576
577 int KdenliveDoc::getFreeClipId() {
578     return m_clipManager->getFreeClipId();
579 }
580
581 DocClipBase *KdenliveDoc::getBaseClip(int clipId) {
582     return m_clipManager->getClipById(clipId);
583 }
584
585 void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId) {
586     m_clipManager->slotAddColorClipFile(name, color, duration, group, groupId);
587     setModified(true);
588 }
589
590 void KdenliveDoc::slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, bool loop, const QString group, const int groupId) {
591     m_clipManager->slotAddSlideshowClipFile(name, path, count, duration, loop, group, groupId);
592     setModified(true);
593 }
594
595 void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
596     QString titlesFolder = projectFolder().path() + "/titles/";
597     KStandardDirs::makeDir(titlesFolder);
598     TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, kapp->activeWindow());
599     if (dia_ui->exec() == QDialog::Accepted) {
600         QString titleName = "title";
601         int counter = 0;
602         QString path = titlesFolder + titleName + QString::number(counter).rightJustified(3, '0', false);
603         while (QFile::exists(path + ".kdenlivetitle")) {
604             counter++;
605             path = titlesFolder + titleName + QString::number(counter).rightJustified(3, '0', false);
606         }
607         QPixmap pix = dia_ui->renderedPixmap();
608         pix.save(path + ".png");
609         dia_ui->saveTitle(path + ".kdenlivetitle");
610         slotAddTextClipFile(path, QString(), -1);
611     }
612     delete dia_ui;
613 }
614
615 void KdenliveDoc::editTextClip(QString path, int id) {
616     TitleWidget *dia_ui = new TitleWidget(KUrl(path + ".kdenlivetitle"), path, m_render, kapp->activeWindow());
617     if (dia_ui->exec() == QDialog::Accepted) {
618         QPixmap pix = dia_ui->renderedPixmap();
619         pix.save(path + ".png");
620         dia_ui->saveTitle(path + ".kdenlivetitle");
621         //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
622         emit refreshClipThumbnail(id);
623     }
624     delete dia_ui;
625 }
626
627
628 #include "kdenlivedoc.moc"
629