]> git.sesse.net Git - kdenlive/commitdiff
Add project folder places entry to Kdenlive file dialogs:
authorTill Theato <root@ttill.de>
Sat, 11 Dec 2010 21:00:38 +0000 (21:00 +0000)
committerTill Theato <root@ttill.de>
Sat, 11 Dec 2010 21:00:38 +0000 (21:00 +0000)
http://kdenlive.org/mantis/view.php?id=1828

svn path=/trunk/kdenlive/; revision=5158

src/kdenlivedoc.cpp
src/kdenlivedoc.h

index 0275c2dc16ff66242c1669d2fb3b3c976f037dc5..f57e9efc34bc47ef37e6aa80e969a6f207925158 100644 (file)
 #include <KIO/NetAccess>
 #include <KIO/CopyJob>
 #include <KApplication>
+#include <KGlobal>
+#include <KBookmarkManager>
+#include <KBookmark>
+#include <KStandardDirs>
 
 #include <QCryptographicHash>
 #include <QFile>
@@ -260,6 +264,8 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
     KStandardDirs::makeDir(m_projectFolder.path(KUrl::AddTrailingSlash) + "thumbs/");
     KStandardDirs::makeDir(m_projectFolder.path(KUrl::AddTrailingSlash) + "ladspa/");
 
+    updateProjectFolderPlacesEntry();
+
     //kDebug() << "// SETTING SCENE LIST:\n\n" << m_document.toString();
     connect(m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(slotAutoSave()));
 }
@@ -670,6 +676,8 @@ void KdenliveDoc::setProjectFolder(KUrl url)
     KStandardDirs::makeDir(url.path(KUrl::AddTrailingSlash) + "thumbs/");
     if (KMessageBox::questionYesNo(kapp->activeWindow(), i18n("You have changed the project folder. Do you want to copy the cached data from %1 to the new folder %2?").arg(m_projectFolder.path(), url.path())) == KMessageBox::Yes) moveProjectData(url);
     m_projectFolder = url;
+
+    updateProjectFolderPlacesEntry();
 }
 
 void KdenliveDoc::moveProjectData(KUrl url)
@@ -1449,5 +1457,43 @@ bool KdenliveDoc::saveCustomEffects(QDomNodeList customeffects)
     return (!importedEffects.isEmpty());
 }
 
+void KdenliveDoc::updateProjectFolderPlacesEntry()
+{
+    const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml");
+    KBookmarkManager *bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");
+    KBookmarkGroup root = bookmarkManager->root();
+    KBookmark bookmark = root.first();
+
+    QString kdenliveName = KGlobal::mainComponent().componentName();
+    KUrl documentLocation = m_projectFolder;
+
+    bool exists = false;
+
+    while (!bookmark.isNull()) {
+        // UDI not empty indicates a device
+        QString udi = bookmark.metaDataItem("UDI");
+        QString appName = bookmark.metaDataItem("OnlyInApp");
+
+        if (udi.isEmpty() && appName == kdenliveName && bookmark.text() == i18n("Project Folder")) {
+            if (bookmark.url() != documentLocation) {
+                bookmark.setUrl(documentLocation);
+                bookmarkManager->emitChanged(root);
+            }
+            exists = true;
+            break;
+        }
+
+        bookmark = root.next(bookmark);
+    }
+
+    // if entry does not exist yet (was not found), well, create it then
+    if (!exists) {
+        KBookmark newBookmark = root.addBookmark(i18n("Project Folder"), documentLocation, "folder-favorites");
+        // Make this user selectable ?
+        newBookmark.setMetaDataItem("OnlyInApp", kdenliveName);
+        bookmarkManager->emitChanged(root);
+    }
+}
+
 #include "kdenlivedoc.moc"
 
index 5ae8045ab5b49716a3e159415d96948f5f329175..7139dd9951e93a911fcd837c0cff53d1dd65c800 100644 (file)
@@ -176,6 +176,9 @@ private:
     *   @return True if effects were imported.  */
     bool saveCustomEffects(QDomNodeList customeffects);
 
+    /** @brief Updates the project folder location entry in the kdenlive file dialogs to point to the current project folder. */
+    void updateProjectFolderPlacesEntry();
+
 public slots:
     void slotCreateXmlClip(const QString &name, const QDomElement xml, QString group, const QString &groupId);
     void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId);