]> git.sesse.net Git - kdenlive/commitdiff
Title clips now really usable (only transparency & duration change still missing)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 6 Apr 2008 14:37:28 +0000 (14:37 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 6 Apr 2008 14:37:28 +0000 (14:37 +0000)
svn path=/branches/KDE4/; revision=2159

16 files changed:
src/clipitem.cpp
src/clipmanager.cpp
src/clipmanager.h
src/clipproperties.cpp
src/docclipbase.cpp
src/docclipbase.h
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h
src/projectsettings.cpp
src/projectsettings.h
src/renderer.cpp
src/titlewidget.cpp
src/titlewidget.h

index c1ffe8bc2d95e4b084e6c27c1c7f133c0a576bda..21d24e3d80922a87c59105301d094949796380f6 100644 (file)
@@ -87,9 +87,10 @@ ClipItem::ClipItem(DocClipBase *clip, ItemInfo info, double scale, double fps)
         QString colour = m_xml.attribute("colour");
         colour = colour.replace(0, 2, "#");
         setBrush(QColor(colour.left(7)));
-    } else if (m_clipType == IMAGE) {
+    } else if (m_clipType == IMAGE || m_clipType == TEXT) {
         m_maxDuration = GenTime(10000, m_fps);
         m_startPix = KThumb::getImage(KUrl(m_xml.attribute("resource")), (int)(50 * KdenliveSettings::project_display_ratio()), 50);
+        m_endPix = m_startPix;
     } else if (m_clipType == AUDIO) {
         connect(clip, SIGNAL(gotAudioData()), this, SLOT(slotGotAudioData()));
     }
index b8853b47ac3af855d9d86620ce739209a6c97120..9b43fed2b237ff56b6f88fba188e05f954314417 100644 (file)
@@ -128,6 +128,27 @@ void ClipManager::slotAddColorClipFile(const QString name, const QString color,
     m_doc->commandStack()->push(command);
 }
 
+
+
+void ClipManager::slotAddTextClipFile(const QString path, const QString group, const int groupId) {
+    kDebug() << "/////  CLIP MANAGER, ADDING CLIP: " << path;
+    QDomDocument doc;
+    QDomElement prod = doc.createElement("producer");
+    prod.setAttribute("resource", path + ".png");
+    prod.setAttribute("xml", path);
+    uint id = m_clipIdCounter++;
+    prod.setAttribute("id", QString::number(id));
+    if (!group.isEmpty()) {
+        prod.setAttribute("groupname", group);
+        prod.setAttribute("groupid", groupId);
+    }
+    prod.setAttribute("type", (int) TEXT);
+    prod.setAttribute("in", "0");
+    prod.setAttribute("out", m_doc->getFramePos(KdenliveSettings::image_duration()));
+    AddClipCommand *command = new AddClipCommand(m_doc, prod, id, true);
+    m_doc->commandStack()->push(command);
+}
+
 int ClipManager::getFreeClipId() {
     return m_clipIdCounter++;
 }
index 1521fb243f781ead6482628a615aa751ec6c4f1d..d4062aefe901f1ecd44142f7aacc44318b4b7d52 100644 (file)
@@ -49,6 +49,7 @@ Q_OBJECT public:
     DocClipBase *getClipAt(int pos);
     void deleteClip(uint clipId);
     void slotAddClipFile(const KUrl url, const QString group, const int groupId);
+    void slotAddTextClipFile(const QString path, const QString group, const int groupId);
     void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId);
     DocClipBase *getClipById(int clipId);
     void slotDeleteClip(uint clipId);
index 9118efc54a0fc99b91f78ee084d6ee79267bb267..81e4c88a817b7e13b869475fd4ad179ca95840f4 100644 (file)
@@ -55,12 +55,12 @@ ClipProperties::ClipProperties(DocClipBase *clip, Timecode tc, double fps, QWidg
 
         QPixmap pix = m_clip->thumbProducer()->getImage(url, 240, 180);
         m_view.clip_thumb->setPixmap(pix);
-        if (t == IMAGE || t == VIDEO) m_view.tabWidget->removeTab(1);
+        if (t == IMAGE || t == VIDEO || t == COLOR) m_view.tabWidget->removeTab(1);
     } else {
         m_view.tabWidget->removeTab(0);
         m_view.clip_thumb->setHidden(true);
     }
-    if (t != IMAGE && t != COLOR) m_view.clip_duration->setReadOnly(true);
+    if (t != IMAGE && t != COLOR && t != TEXT) m_view.clip_duration->setReadOnly(true);
 
     KFileItem f(KFileItem::Unknown, KFileItem::Unknown, url, true);
     m_view.clip_filesize->setText(KIO::convertSize(f.size()));
index b96cdf58359c510063226a96398b15a9cb8df76d..5b85e6cc22c9d7ed88057c398c3a61e48dd6fdae 100644 (file)
@@ -144,6 +144,10 @@ const QString DocClipBase::description() const {
     return m_properties.value("description");
 }
 
+const QString DocClipBase::getProperty(const QString prop) const {
+    return m_properties.value(prop);
+}
+
 void DocClipBase::setDuration(GenTime dur) {
     m_duration = dur;
 }
index 230b3d4baa398b52e0ed46b3e005f3b974fbbc2f..e7ec0ae33c1b45e9dacce0d9775a43e0e7d535e2 100644 (file)
@@ -85,6 +85,9 @@ Q_OBJECT public:
     /** Returns the description of this clip. */
     const QString description() const;
 
+    /** Returns any property of this clip. */
+    const QString getProperty(const QString prop) const;
+
     /** Returns the internal unique id of the clip. */
     uint getId() const;
     void setId(const uint &newId);
index 0d7fd96c12314001950de8a9c0d7448614c0f57a..df36874662a57e102744439c7d1244b3b1e6627d 100644 (file)
@@ -35,7 +35,7 @@
 #include "editfoldercommand.h"
 #include "titlewidget.h"
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), 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) {
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *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_clipManager = new ClipManager(this);
     if (!url.isEmpty()) {
         QString tmpFile;
@@ -147,6 +147,11 @@ ClipManager *KdenliveDoc::clipManager() {
     return m_clipManager;
 }
 
+KUrl KdenliveDoc::projectFolder() const {
+    if (m_projectFolder.isEmpty()) return KUrl(KStandardDirs::locateLocal("appdata", "/projects/"));
+    return m_projectFolder;
+}
+
 QString KdenliveDoc::getDocumentStandard() {
     //WARNING: this way to tell the video standard is a bit hackish...
     if (m_profile.description.contains("pal", Qt::CaseInsensitive) || m_profile.description.contains("25", Qt::CaseInsensitive) || m_profile.description.contains("50", Qt::CaseInsensitive)) return "PAL";
@@ -283,7 +288,7 @@ void KdenliveDoc::setModified(bool mod) {
     emit docModified(m_modified);
 }
 
-bool KdenliveDoc::isModified() {
+bool KdenliveDoc::isModified() const {
     return m_modified;
 }
 
@@ -337,6 +342,12 @@ void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const int
     setModified(true);
 }
 
+void KdenliveDoc::slotAddTextClipFile(const QString path, const QString group, const int groupId) {
+    kDebug() << "/////////  DOCUM, ADD TXT CLP: " << path;
+    m_clipManager->slotAddTextClipFile(path, group, groupId);
+    setModified(true);
+}
+
 void KdenliveDoc::slotAddFolder(const QString folderName) {
     AddFolderCommand *command = new AddFolderCommand(this, folderName, m_clipManager->getFreeClipId(), true);
     commandStack()->push(command);
@@ -369,11 +380,33 @@ void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color,
 }
 
 void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
-    TitleWidget *dia_ui = new TitleWidget(m_render, 0);
+    QString titlesFolder = projectFolder().path() + "/titles/";
+    KStandardDirs::makeDir(titlesFolder);
+    TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, 0);
+    if (dia_ui->exec() == QDialog::Accepted) {
+        QString titleName = "title";
+        int counter = 0;
+        QString path = titlesFolder + titleName + QString::number(counter).rightJustified(3, '0', false);
+        while (QFile::exists(path + ".kdenlivetitle")) {
+            counter++;
+            path = titlesFolder + titleName + QString::number(counter).rightJustified(3, '0', false);
+        }
+        QPixmap pix = dia_ui->renderedPixmap();
+        pix.save(path + ".png");
+        dia_ui->saveTitle(path + ".kdenlivetitle");
+        slotAddTextClipFile(path, QString(), -1);
+    }
+    delete dia_ui;
+}
+
+void KdenliveDoc::editTextClip(QString path, int id) {
+    TitleWidget *dia_ui = new TitleWidget(KUrl(path + ".kdenlivetitle"), path, m_render, 0);
     if (dia_ui->exec() == QDialog::Accepted) {
-        QPixmap p = dia_ui->renderedPixmap();
-        p.save("/tmp/kdenlivetitle.png");
-        slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
+        QPixmap pix = dia_ui->renderedPixmap();
+        pix.save(path + ".png");
+        dia_ui->saveTitle(path + ".kdenlivetitle");
+        //slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
+        emit refreshClipThumbnail(id);
     }
     delete dia_ui;
 }
index 8576101840c483419575bed04f2d999ab8e257c2..cfb922f9c1d7525da8ef806770a3c6eb035d2f07 100644 (file)
@@ -42,7 +42,7 @@ class DocClipBase;
 class KdenliveDoc: public QObject {
 Q_OBJECT public:
 
-    KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent = 0);
+    KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent = 0);
     ~KdenliveDoc();
     QDomNodeList producersList();
     double fps() const;
@@ -63,6 +63,8 @@ Q_OBJECT public:
     void addFolder(const QString foldername, int clipId, bool edit);
     void deleteFolder(const QString foldername, int clipId);
     void slotAddClipFile(const KUrl url, const QString group, const int groupId = -1);
+    void slotAddTextClipFile(const QString path, const QString group, const int groupId = -1);
+    void editTextClip(QString path, int id);
     void slotAddFolder(const QString folderName);
     void slotDeleteFolder(const QString folderName, const int id);
     void slotEditFolder(const QString folderName, const QString oldfolderName, int clipId);
@@ -86,7 +88,9 @@ Q_OBJECT public:
     void setModified(bool mod);
     int getFreeClipId();
     /** does the document need saving */
-    bool isModified();
+    bool isModified() const;
+    /** Returns project folder, used to store project files (titles, effects,...) */
+    KUrl projectFolder() const;
 
 private:
     KUrl m_url;
@@ -104,6 +108,8 @@ private:
     QString m_scenelist;
     /** tells whether current doc has been changed since last save event */
     bool m_modified;
+    /** Project folder, used to store project files (titles, effects,...) */
+    KUrl m_projectFolder;
 
 public slots:
     void slotCreateTextClip(QString group, int groupId);
@@ -117,6 +123,7 @@ signals:
     void thumbsProgress(KUrl, int);
     /** emited when the document state has been modified (= needs saving or not) */
     void docModified(bool);
+    void refreshClipThumbnail(int);
 };
 
 #endif
index 0bec81b73c8bddf90323ec7f4a392eef03e5307a..5176dec8d09fa56bbd2aaddf8430f8b1fbfa3a3b 100644 (file)
@@ -504,16 +504,18 @@ void MainWindow::readOptions() {
 
 void MainWindow::newFile() {
     QString profileName;
+    KUrl projectFolder;
     if (m_timelineArea->count() == 0) profileName = KdenliveSettings::default_profile();
     else {
         ProjectSettings *w = new ProjectSettings;
-        w->exec();
+        if (w->exec() != QDialog::Accepted) return;
         profileName = w->selectedProfile();
+        projectFolder = w->selectedFolder();
         delete w;
     }
     MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName);
     if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
-    KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof, m_commandStack);
+    KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, prof, m_commandStack);
     TrackView *trackView = new TrackView(doc, this);
     m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description);
     if (m_timelineArea->count() == 1)
@@ -578,7 +580,7 @@ void MainWindow::openFile(const KUrl &url) { //new
     //TODO: get video profile from url before opening it
     MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile());
     if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal");
-    KdenliveDoc *doc = new KdenliveDoc(url, prof, m_commandStack);
+    KdenliveDoc *doc = new KdenliveDoc(url, KUrl(), prof, m_commandStack);
     TrackView *trackView = new TrackView(doc, this);
     m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description()));
     m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path());
@@ -589,6 +591,8 @@ void MainWindow::openFile(const KUrl &url) { //new
 
 void MainWindow::parseProfiles() {
     //kdDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <<endl;
+
+    //KdenliveSettings::setDefaulttmpfolder();
     if (KdenliveSettings::mltpath().isEmpty()) {
         KdenliveSettings::setMltpath(QString(MLT_PREFIX) + QString("/share/mlt/profiles/"));
     }
@@ -732,6 +736,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
             disconnect(m_activeDocument, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
             disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
             disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
+            disconnect(m_activeDocument, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
             disconnect(m_activeDocument, SIGNAL(deletTimelineClip(int)), m_activeTimeline, SLOT(slotDeleteClip(int)));
             disconnect(m_activeDocument, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
             disconnect(m_activeTimeline, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
@@ -762,10 +767,14 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     connect(doc, SIGNAL(addProjectFolder(const QString, int, bool, bool)), m_projectList, SLOT(slotAddFolder(const QString, int, bool, bool)));
     connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int)));
     connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int)));
+    connect(doc, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
+
     connect(doc, SIGNAL(deletTimelineClip(int)), trackView, SLOT(slotDeleteClip(int)));
     connect(doc, SIGNAL(thumbsProgress(KUrl, int)), this, SLOT(slotGotProgressInfo(KUrl, int)));
     connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
 
+
+
     connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), effectStack, SLOT(slotClipItemSelected(ClipItem*)));
     connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
     connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
@@ -904,6 +913,10 @@ void MainWindow::slotGotProgressInfo(KUrl url, int progress) {
 }
 
 void MainWindow::slotShowClipProperties(DocClipBase *clip) {
+    if (clip->clipType() == TEXT) {
+        m_activeDocument->editTextClip(clip->getProperty("xml"), clip->getId());
+        return;
+    }
     ClipProperties dia(clip, m_activeDocument->timecode(), m_activeDocument->fps(), this);
     if (dia.exec() == QDialog::Accepted) {
         m_projectList->slotUpdateClipProperties(dia.clipId(), dia.properties());
index cee7dbd01f773532314cb3a421936e536929c623..33678dc94db2a50f3eeffd942d6b7b21483bd665 100644 (file)
@@ -23,6 +23,7 @@
 #include <QPixmap>
 #include <QIcon>
 #include <QDialog>
+#include <QtGui>
 
 #include <KDebug>
 #include <KAction>
@@ -46,8 +47,8 @@
 #include "docclipbase.h"
 #include "kdenlivedoc.h"
 #include "renderer.h"
+#include "kthumb.h"
 #include "projectlistview.h"
-#include <QtGui>
 
 ProjectList::ProjectList(QWidget *parent)
         : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL) {
@@ -465,6 +466,15 @@ QDomElement ProjectList::producersList() {
     return prods;
 }
 
+void ProjectList::slotRefreshClipThumbnail(int clipId) {
+    ProjectItem *item = getItemById(clipId);
+    if (item) {
+        int height = 40;
+        int width = (int)(height  * (double) m_render->renderWidth() / m_render->renderHeight());
+        QPixmap pix = KThumb::getImage(item->clipUrl(), item->referencedClip()->getProjectThumbFrame(), width, height);
+        item->setIcon(0, pix);
+    }
+}
 
 void ProjectList::slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata) {
     ProjectItem *item = getItemById(clipId);
@@ -475,8 +485,6 @@ void ProjectList::slotReplyGetFileProperties(int clipId, const QMap < QString, Q
     }
 }
 
-
-
 void ProjectList::slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h) {
     ProjectItem *item = getItemById(clipId);
     if (item) item->setIcon(0, pix);
index 80498cb6bf436e23561c06d0a68dffc8ec345f79..4bc08c82064224ce87a6e4f2e6f43dbe22bec3be 100644 (file)
@@ -116,6 +116,7 @@ public slots:
     void slotAddClip(DocClipBase *clip);
     void slotDeleteClip(int clipId);
     void slotUpdateClip(int id);
+    void slotRefreshClipThumbnail(int clipId);
 
 
 private:
index 1aaa15e23b405ec6370715aa5690ccde25efb995..c1c726d421f4adf2dd84a9175ebbce67943bff5e 100644 (file)
@@ -60,10 +60,14 @@ void ProjectSettings::slotUpdateButton(const QString &path) {
     else buttonOk->setEnabled(true);
 }
 
-QString ProjectSettings::selectedProfile() {
+QString ProjectSettings::selectedProfile() const {
     return ProfilesDialog::getPathFromDescription(m_view.profiles_list->currentText());
 }
 
+KUrl ProjectSettings::selectedFolder() const {
+    return m_view.project_folder->url();
+}
+
 #include "projectsettings.moc"
 
 
index a36f50c542c2f73305f6ebb54243c232763ddc62..e36fe8dfa1f18fcef1e89bac9bcd3b7ce9403def 100644 (file)
@@ -31,7 +31,8 @@ class ProjectSettings : public QDialog {
 
 public:
     ProjectSettings(QWidget * parent = 0);
-    QString selectedProfile();
+    QString selectedProfile() const;
+    KUrl selectedFolder() const;
 
 private slots:
     void slotUpdateDisplay();
index 8ecfc69d229a5d957e9aafeead92a9b7b3d082be..0e53393aa79c147f04381791b0a10e677a147356 100644 (file)
@@ -373,7 +373,7 @@ bool Render::isValid(KUrl url) {
 
 void Render::getFileProperties(const QDomElement &xml, int clipId) {
     int height = 40;
-    int width = (int)(height * 16 / 9.0);   //KdenliveSettings::displayratio();
+    int width = (int)(height  * m_mltProfile->dar());
     QDomDocument doc;
     QDomElement westley = doc.createElement("westley");
     doc.appendChild(westley);
index 01719d8ce39c82eac01daa2c9c5f6f3646945b72..83a03d1ff32be7a63f26b4f84525ee5db5202b59 100644 (file)
@@ -35,7 +35,7 @@
 
 int settingUp = false;
 
-TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent), m_render(render), m_count(0) {
+TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent): QDialog(parent), m_render(render), m_count(0), m_projectPath(projectPath) {
     setupUi(this);
     //frame_properties->
     setFont(KGlobalSettings::toolBarFont());
@@ -155,7 +155,6 @@ TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent), m_re
 
     QPen framepen(Qt::DotLine);
     framepen.setColor(Qt::red);
-    slotRectTool();
 
     m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_frameWidth, m_frameHeight));
     m_frameBorder->setPen(framepen);
@@ -174,6 +173,10 @@ TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent), m_re
     kDebug() << "// TITLE WIDGWT: " << graphicsView->viewport()->width() << "x" << graphicsView->viewport()->height();
     toolBox->setItemEnabled(2, false);
     toolBox->setItemEnabled(3, false);
+    if (!url.isEmpty()) {
+        m_count = m_titledocument.loadDocument(url, startViewport, endViewport) + 1;
+        slotSelectTool();
+    } else slotRectTool();
 }
 
 
@@ -549,7 +552,7 @@ void TitleWidget::setupViewports() {
 }
 
 void TitleWidget::loadTitle() {
-    KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlivetitle", this, tr("Save Title"));
+    KUrl url = KFileDialog::getOpenUrl(KUrl(m_projectPath), "*.kdenlivetitle", this, tr("Save Title"));
     if (!url.isEmpty()) {
         QList<QGraphicsItem *> items = m_scene->items();
         for (int i = 0; i < items.size(); i++) {
@@ -560,9 +563,9 @@ void TitleWidget::loadTitle() {
     }
 }
 
-void TitleWidget::saveTitle() {
-    KUrl url = KFileDialog::getSaveUrl(KUrl(), "*.kdenlivetitle", this, tr("Save Title"));
-    m_titledocument.saveDocument(url, startViewport, endViewport);
+void TitleWidget::saveTitle(KUrl url) {
+    if (url.isEmpty()) KUrl url = KFileDialog::getSaveUrl(KUrl(m_projectPath), "*.kdenlivetitle", this, tr("Save Title"));
+    if (!url.isEmpty()) m_titledocument.saveDocument(url, startViewport, endViewport);
 }
 
 QPixmap TitleWidget::renderedPixmap() {
index 55392513c2d563b17a3166ad9fef77490d1d9531..e213b7790567ad1118957348cc325ff0558f8cc3 100644 (file)
@@ -44,7 +44,7 @@ public:
 class TitleWidget : public QDialog , public Ui::TitleWidget_UI {
     Q_OBJECT
 public:
-    TitleWidget(Render *render, QWidget *parent = 0);
+    TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent = 0);
 
 protected:
     virtual void resizeEvent(QResizeEvent * event);
@@ -67,6 +67,8 @@ private:
     QAction *m_buttonCursor;
     QAction *m_buttonSave;
     QAction *m_buttonLoad;
+    /** project path for storing title clips */
+    QString m_projectPath;
 
 public slots:
     void slotNewText(QGraphicsTextItem *tt);
@@ -81,7 +83,7 @@ public slots:
     void svgSelected(const KUrl&);
     void itemScaled(int);
     void itemRotate(int);
-    void saveTitle();
+    void saveTitle(KUrl url = KUrl());
     void loadTitle();
     QPixmap renderedPixmap();