Store proxy profile info in proxy clip name, no more separate folders, fix...

Store proxy profile info in proxy clip name, no more separate folders, fix info & deletion of proxies in cached data widget
CCBUG: 364655
parent b7972249
......@@ -3239,6 +3239,17 @@ void Bin::refreshProxySettings()
} else delete masterCommand;
}
QStringList Bin::getProxyHashList()
{
QStringList list;
QList <ProjectClip*> clipList = m_rootFolder->childClips();
foreach (ProjectClip *clp, clipList) {
if (clp->clipType() == AV || clp->clipType() == Video || clp->clipType() == Playlist)
list << clp->hash();
}
return list;
}
void Bin::slotSendAudioThumb(QString id)
{
ProjectClip *clip = m_rootFolder->clip(id);
......
......@@ -526,6 +526,8 @@ public:
/** @brief Command adding a bin clip */
bool addClip(QDomElement elem, const QString &clipId);
void rebuildProxies();
/** @brief Return a list of all clips hashes used in this project */
QStringList getProxyHashList();
private slots:
void slotAddClip();
......
......@@ -330,7 +330,7 @@ int KdenliveDoc::setSceneList()
return -1;
}
pCore->bin()->isLoading = false;
bool ok = false;
QDir thumbsFolder = getCacheDir(CacheThumbs, &ok);
if (ok)
......@@ -1276,16 +1276,12 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<ProjectClip *> clipLi
if (!ok) {
// Error
}
QString extension = getDocumentProperty(QStringLiteral("proxyextension"));
QString proxyFolder;
QString extension = QStringLiteral(".") + getDocumentProperty(QStringLiteral("proxyextension"));
QString params = getDocumentProperty(QStringLiteral("proxyparams"));
if (params.contains(QStringLiteral("-s "))) {
proxyFolder = params.section(QStringLiteral("-s "), 1).section(QStringLiteral("x"), 0, 0);
QString proxySize = params.section(QStringLiteral("-s "), 1).section(QStringLiteral("x"), 0, 0);
extension.prepend(QStringLiteral("-") + proxySize);
}
proxyFolder.append(QStringLiteral("-") + extension);
qDebug()<<" PXY FOLDER: "<<proxyFolder;
dir.mkdir(proxyFolder);
dir.cd(proxyFolder);
// Prepare updated properties
QMap <QString, QString> newProps;
......@@ -1305,9 +1301,8 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<ProjectClip *> clipLi
if (doProxy) {
newProps.clear();
QString path = dir.absoluteFilePath(item->hash() + '.' + (t == Image ? QStringLiteral("png") : extension));
QString path = dir.absoluteFilePath(item->hash() + (t == Image ? QStringLiteral(".png") : extension));
// insert required duration for proxy
qDebug()<<" PXY PATH: "<<path;
newProps.insert(QStringLiteral("proxy_out"), item->getProducerProperty(QStringLiteral("out")));
newProps.insert(QStringLiteral("kdenlive:proxy"), path);
}
......@@ -1661,3 +1656,8 @@ QDir KdenliveDoc::getCacheDir(CacheType type, bool *ok) const
}
return dir;
}
QStringList KdenliveDoc::getProxyHashList()
{
return pCore->bin()->getProxyHashList();
}
......@@ -169,6 +169,8 @@ public:
QDir getCacheDir(CacheType type, bool *ok) const;
/** @brief Create standard cache dirs for the project */
void initCacheDirs();
/** @brief Get a list of all proxy hash used in this project */
QStringList getProxyHashList();
private:
QUrl m_url;
......
......@@ -186,6 +186,10 @@ TemporaryData::TemporaryData(KdenliveDoc *doc, bool currentProjectOnly, QWidget
m_grid->addWidget(del, 5, 4);
m_currentPage->setLayout(m_grid);
m_proxies = m_doc->getProxyHashList();
for (int i = 0; i < m_proxies.count(); i++) {
m_proxies[i].append(QStringLiteral("*"));
}
if (currentProjectOnly) {
lay->addWidget(m_currentPage);
......@@ -220,8 +224,13 @@ void TemporaryData::updateDataInfo()
preview = m_doc->getCacheDir(CacheProxy, &ok);
if (ok) {
KIO::DirectorySizeJob *job = KIO::directorySize(QUrl::fromLocalFile(preview.absolutePath()));
connect(job, &KIO::DirectorySizeJob::result, this, &TemporaryData::gotProxySize);
preview.setNameFilters(m_proxies);
QFileInfoList fList = preview.entryInfoList();
qint64 size = 0;
foreach(const QFileInfo &info, fList) {
size += info.size();
}
gotProxySize(size);
}
preview = m_doc->getCacheDir(CacheAudio, &ok);
......@@ -234,6 +243,8 @@ void TemporaryData::updateDataInfo()
KIO::DirectorySizeJob *job = KIO::directorySize(QUrl::fromLocalFile(preview.absolutePath()));
connect(job, &KIO::DirectorySizeJob::result, this, &TemporaryData::gotThumbSize);
}
if (m_globalPage)
updateGlobalInfo();
}
void TemporaryData::gotPreviewSize(KJob *job)
......@@ -253,13 +264,8 @@ void TemporaryData::gotPreviewSize(KJob *job)
updateTotal();
}
void TemporaryData::gotProxySize(KJob *job)
void TemporaryData::gotProxySize(qint64 total)
{
KIO::DirectorySizeJob *sourceJob = static_cast<KIO::DirectorySizeJob *> (job);
qulonglong total = sourceJob->totalSize();
if (sourceJob->totalFiles() == 0) {
total = 0;
}
QLayoutItem *button = m_grid->itemAtPosition(1, 4);
if (button && button->widget()) {
button->widget()->setEnabled(total > 0);
......@@ -344,18 +350,19 @@ void TemporaryData::deleteProxy()
{
bool ok = false;
QDir dir = m_doc->getCacheDir(CacheProxy, &ok);
if (!ok) {
if (!ok || dir.dirName() != QLatin1String("proxy")) {
return;
}
if (KMessageBox::warningContinueCancel(this, i18n("Delete all data in the cache proxy folder:\n%1", dir.absolutePath())) != KMessageBox::Continue) {
dir.setNameFilters(m_proxies);
QStringList files = dir.entryList(QDir::Files);
if (KMessageBox::warningContinueCancelList(this, i18n("Delete all project data in the cache proxy folder:\n%1", dir.absolutePath()), files) != KMessageBox::Continue) {
return;
}
if (dir.dirName() == QLatin1String("proxy")) {
dir.removeRecursively();
dir.mkpath(".");
emit disableProxies();
updateDataInfo();
foreach(const QString &file, files) {
dir.remove(file);
}
emit disableProxies();
updateDataInfo();
}
void TemporaryData::deleteAudio()
......@@ -467,7 +474,6 @@ void TemporaryData::buildGlobalCacheDialog(int minHeight)
lay->setColumnStretch(4, 10);
lay->setRowStretch(0, 10);
connect(m_listWidget, &QTreeWidget::itemSelectionChanged, this, &TemporaryData::refreshGlobalPie);
updateGlobalInfo();
}
void TemporaryData::updateGlobalInfo()
......
......@@ -112,6 +112,7 @@ private:
QStringList m_globalDirectories;
QString m_processingDirectory;
QDir m_globalDir;
QStringList m_proxies;
QPushButton *m_globalDelete;
void updateDataInfo();
void updateGlobalInfo();
......@@ -121,7 +122,7 @@ private:
private slots:
void gotPreviewSize(KJob *job);
void gotProxySize(KJob *job);
void gotProxySize(qint64 total);
void gotAudioSize(KJob *job);
void gotThumbSize(KJob *job);
void gotFolderSize(KJob *job);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment