From: Till Theato Date: Sat, 11 Dec 2010 21:00:38 +0000 (+0000) Subject: Add project folder places entry to Kdenlive file dialogs: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c59b232df628b84271a99765f32e03d606cc2733;p=kdenlive Add project folder places entry to Kdenlive file dialogs: http://kdenlive.org/mantis/view.php?id=1828 svn path=/trunk/kdenlive/; revision=5158 --- diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 0275c2dc..f57e9efc 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -40,6 +40,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -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" diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 5ae8045a..7139dd99 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -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);