return hash;
}
+void DocClipBase::refreshThumbUrl() {
+ if (m_thumbProd) m_thumbProd->updateThumbUrl(m_properties.value("file_hash"));
+}
+
void DocClipBase::setProperty(const QString &key, const QString &value) {
m_properties.insert(key, value);
if (key == "resource") {
- m_thumbProd->updateClipUrl(KUrl(value));
getFileHash(value);
+ if (m_thumbProd) m_thumbProd->updateClipUrl(KUrl(value), m_properties.value("file_hash"));
} else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
//else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
else if (key == "colour") {
void slotClearAudioCache();
void askForAudioThumbs();
QString getClipHash() const;
+ void refreshThumbUrl();
private: // Private attributes
/** The name of this clip */
#include <KLocale>
#include <KFileDialog>
#include <KIO/NetAccess>
+#include <KIO/CopyJob>
#include <KApplication>
return m_projectFolder;
}
+void KdenliveDoc::setProjectFolder(KUrl url) {
+ if (url == m_projectFolder) return;
+ setModified(true);
+ KStandardDirs::makeDir(url.path());
+ KStandardDirs::makeDir(url.path() + "/titles/");
+ KStandardDirs::makeDir(url.path() + "/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;
+}
+
+void KdenliveDoc::moveProjectData(KUrl url) {
+ QList <DocClipBase*> list = m_clipManager->documentClipList();
+ for (int i = 0; i < list.count(); i++) {
+ DocClipBase *clip = list.at(i);
+ if (clip->clipType() == TEXT) {
+ // the image for title clip must be moved
+ KUrl oldUrl = clip->fileURL();
+ KUrl newUrl = KUrl(url.path() + "/titles/" + oldUrl.fileName());
+ KIO::Job *job = KIO::copy(oldUrl, newUrl);
+ if (KIO::NetAccess::synchronousRun(job, 0)) clip->setProperty("resource", newUrl.path());
+ }
+ QString hash = clip->getClipHash();
+ KUrl oldVideoThumbUrl = KUrl(m_projectFolder.path() + "/thumbs/" + hash + ".png");
+ KUrl oldAudioThumbUrl = KUrl(m_projectFolder.path() + "/thumbs/" + hash + ".thumb");
+ if (KIO::NetAccess::exists(oldVideoThumbUrl, KIO::NetAccess::SourceSide, 0)) {
+ KUrl newUrl = KUrl(url.path() + "/thumbs/" + hash + ".png");
+ KIO::Job *job = KIO::copy(oldVideoThumbUrl, newUrl);
+ KIO::NetAccess::synchronousRun(job, 0);
+ }
+ if (KIO::NetAccess::exists(oldAudioThumbUrl, KIO::NetAccess::SourceSide, 0)) {
+ KUrl newUrl = KUrl(url.path() + "/thumbs/" + hash + ".thumb");
+ KIO::Job *job = KIO::copy(oldAudioThumbUrl, newUrl);
+ if (KIO::NetAccess::synchronousRun(job, 0)) clip->refreshThumbUrl();
+ }
+ }
+}
+
QString KdenliveDoc::profilePath() const {
return m_profile.path;
}
id = prods.at(i)->get("id");
prodId = id.section('_', 0, 0);
prodTrack = id.section('_', 1, 1);
- kDebug() << "CHECK PRO CLIP, ID: " << id;
DocClipBase *clip = m_clipManager->getClipById(prodId);
if (clip) clip->setProducer(prods.at(i));
- kDebug() << "CHECK PRO CLIP, ID: " << id << " DONE";
if (clip && clip->clipType() == TEXT && !QFile::exists(clip->fileURL().path())) {
// regenerate text clip image if required
kDebug() << "// TITLE: " << clip->getProperty("titlename") << " Preview file: " << clip->getProperty("resource") << " DOES NOT EXIST";
QString description() const;
void setUrl(KUrl url);
void setProfilePath(QString path);
- const QString&getFreeClipId();
+ const QString &getFreeClipId();
/** does the document need saving */
bool isModified() const;
/** Returns project folder, used to store project files (titles, effects,...) */
void switchTrackVideo(int ix, bool hide);
void switchTrackAudio(int ix, bool hide);
void cachePixmap(const QString &fileId, const QPixmap &pix) const;
+ void setProjectFolder(KUrl url);
private:
KUrl m_url;
void checkProjectClips();
void setNewClipResource(const QString &id, const QString &path);
QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
+ void moveProjectData(KUrl url);
public slots:
void slotCreateTextClip(QString group, const QString &groupId);
return m_producer != NULL;
}
-void KThumb::updateClipUrl(KUrl url) {
+void KThumb::updateThumbUrl(const QString &hash) {
+ m_thumbFile = m_clipManager->projectFolder() + "/thumbs/" + hash + ".thumb";
+}
+
+void KThumb::updateClipUrl(KUrl url, const QString &hash) {
m_url = url;
if (m_producer) {
char *tmp = Render::decodedString(url.path());
m_producer->set("resource", tmp);
delete[] tmp;
}
+ m_thumbFile = m_clipManager->projectFolder() + "/thumbs/" + hash + ".thumb";
}
//static
void setProducer(Mlt::Producer *producer);
void askForAudioThumbs(const QString &id);
bool hasProducer() const;
+ void updateThumbUrl(const QString &hash);
public slots:
void extractImage(int frame, int frame2);
QPixmap extractImage(int frame, int width, int height);
- void updateClipUrl(KUrl url);
+ void updateClipUrl(KUrl url, const QString &hash);
static QPixmap getImage(KUrl url, int width, int height);
// static QPixmap getImage(QDomElement xml, int frame, int width, int height);
/* void getImage(KUrl url, int frame, int width, int height);
m_activeDocument->setProfilePath(profile);
KdenliveSettings::setCurrent_profile(profile);
KdenliveSettings::setProject_fps(m_activeDocument->fps());
+ m_activeDocument->setProjectFolder(w->selectedFolder());
setCaption(m_activeDocument->description(), m_activeDocument->isModified());
m_monitorManager->resetProfiles(m_activeDocument->timecode());
if (m_renderWidget) m_renderWidget->setProfile(m_activeDocument->mltProfile());