Commit ea2fc56d authored by Julius Künzel's avatar Julius Künzel
Browse files

Refactor cache manager

parent 2a810d0c
Pipeline #56514 passed with stage
in 10 minutes and 23 seconds
......@@ -4100,17 +4100,9 @@ void MainWindow::setTimelineToolbarIconSize(QAction *a)
void MainWindow::slotManageCache()
{
QDialog d(this);
d.setWindowTitle(i18n("Manage Cache Data"));
auto *lay = new QVBoxLayout;
TemporaryData tmp(pCore->currentDoc(), false, this);
connect(&tmp, &TemporaryData::disableProxies, this, &MainWindow::slotDisableProxies);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
connect(buttonBox, &QDialogButtonBox::rejected, &d, &QDialog::reject);
lay->addWidget(&tmp);
lay->addWidget(buttonBox);
d.setLayout(lay);
d.exec();
QPointer<TemporaryData> d(new TemporaryData(pCore->currentDoc(), false, this));
connect(d, &TemporaryData::disableProxies, this, &MainWindow::slotDisableProxies);
d->exec();
}
void MainWindow::slotUpdateCompositing(QAction *compose)
......
......@@ -128,6 +128,7 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap<QString, QString> metada
}
project_folder->setUrl(QUrl::fromLocalFile(doc->projectTempFolder()));
auto *cacheWidget = new TemporaryData(doc, true, this);
cacheWidget->buttonBox->hide();
connect(cacheWidget, &TemporaryData::disableProxies, this, &ProjectSettings::disableProxies);
connect(cacheWidget, &TemporaryData::disablePreview, this, &ProjectSettings::disablePreview);
tabWidget->addTab(cacheWidget, i18n("Cache Data"));
......
This diff is collapsed.
......@@ -22,11 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef TEMPORARYDATA_H
#define TEMPORARYDATA_H
#include "ui_managecache_ui.h"
#include "definitions.h"
#include <KIO/DirectorySizeJob>
#include <QDir>
#include <QTreeWidgetItem>
#include <QWidget>
#include <QDialog>
class KdenliveDoc;
class QPaintEvent;
......@@ -88,11 +89,11 @@ private:
/**
* @class TemporaryData
* @brief Dialog allowing management of project's temporary data.
* @brief Dialog allowing management of cache data.
*
*/
class TemporaryData : public QWidget
class TemporaryData : public QDialog, public Ui::ManageCache_UI
{
Q_OBJECT
......@@ -103,19 +104,7 @@ private:
KdenliveDoc *m_doc;
ChartWidget *m_currentPie;
ChartWidget *m_globalPie;
QLabel *m_previewSize;
QLabel *m_proxySize;
QLabel *m_totalProxySize;
QLabel *m_audioSize;
QLabel *m_thumbSize;
QLabel *m_currentSize;
QLabel *m_globalSize;
QLabel *m_selectedSize;
QLabel *m_backupSize;
QWidget *m_currentPage;
QWidget *m_globalPage;
QTreeWidget *m_listWidget;
QGridLayout *m_grid;
bool m_currentProjectOnly;
KIO::filesize_t m_totalCurrent;
KIO::filesize_t m_totalGlobal;
QList<KIO::filesize_t> m_currentSizes;
......@@ -123,14 +112,13 @@ private:
QString m_processingDirectory;
QDir m_globalDir;
QStringList m_proxies;
QToolButton *m_globalDelete;
void updateDataInfo();
void updateGlobalInfo();
void updateTotal();
void buildGlobalCacheDialog(int minHeight);
void processglobalDirectories();
void processBackupDirectories();
void processProxyDirectory();
void deleteCache(QStringList &folders);
private slots:
void gotPreviewSize(KJob *job);
......@@ -153,7 +141,6 @@ private slots:
void deleteSelected();
void cleanCache();
void cleanProxy();
void deleteCache(QStringList &folders);
signals:
void disableProxies();
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ManageCache_UI</class>
<widget class="QDialog" name="ManageCache_UI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Manage Cache Data</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<property name="tabBarAutoHide">
<bool>true</bool>
</property>
<widget class="QWidget" name="projectPage">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="accessibleName">
<string>Current Project</string>
</property>
<attribute name="title">
<string>Current Project</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,10,0,0,0">
<item row="3" column="3">
<widget class="QLabel" name="thumbSize">
<property name="text">
<string>0 B</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="proxySize">
<property name="text">
<string>0 B</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QToolButton" name="delAudio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="proxyColor">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="proxyLabel">
<property name="text">
<string>Proxy Clips</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="audioColor">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="thumbColor">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QToolButton" name="delThumb">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="5" column="0" colspan="5">
<widget class="QFrame" name="seperator1">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="previewSize">
<property name="text">
<string>0 B</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QToolButton" name="delProxy">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="audioLabel">
<property name="text">
<string>Audio Thumbnails</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="previewColor">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="audioSize">
<property name="text">
<string>0 B</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="previewLabel">
<property name="text">
<string>Timeline Preview</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="5">
<layout class="QHBoxLayout" name="currentChartBox"/>
</item>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="currentLabel">
<property name="text">
<string>Project total cache data</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="delPreview">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="thumbLabel">
<property name="text">
<string>Video Thumbnails</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="5">
<widget class="QLabel" name="currentPath">
<property name="toolTip">
<string>Click to open cache folder</string>
</property>
<property name="text">
<string>&lt;a href='#'&gt;/home/user/.cache/kdenlive/1617522274308&lt;/a&gt;</string>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QToolButton" name="delCurrent">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLabel" name="currentSize">
<property name="text">
<string>0 B</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="globalPage">
<property name="accessibleName">
<string>Current Project</string>
</property>
<property name="accessibleDescription">
<string>Current Project</string>
</property>
<attribute name="title">
<string>All Projects</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,10,0,0">
<item row="4" column="3">
<widget class="QToolButton" name="gProxyClean">
<property name="toolTip">
<string>Cleanup old proxy file</string>
</property>
<property name="icon">
<iconset theme="edit-clear-history">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<layout class="QHBoxLayout" name="gChartLayout">
<item>
<widget class="QTreeWidget" name="listWidget">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Folder</string>
</property>
</column>
<column>
<property name="text">
<string extracomment="Filesize">Size</string>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="gTotalColor">
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="5">
<widget class="QFrame" name="seperator3">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="gTotalLabel">
<property name="text">
<string>Total Cached Data</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="5">
<widget class="QFrame" name="seperator4">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="gBackupLabel">
<property name="text">
<string>Total Backup Data</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="gProxySize">
<property name="text">
<string>Calculating...</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QToolButton" name="gDelete">
<property name="toolTip">
<string>Delete selected cache</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QToolButton" name="gBackupDelete">
<property name="toolTip">
<string>Delete all backup data</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="10" column="0" colspan="5">
<layout class="QHBoxLayout" name="cleanupLayout" stretch="0,0">
<item>
<widget class="QLabel" name="gCleanupLabel">
<property name="text">
<string>Cleanup will delete data older than</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="gCleanupSpin">
<property name="suffix">
<string> months</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>48</number>
</property>
<property name="value">
<number>6</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="4">
<widget class="QToolButton" name="gProxyDelete">
<property name="toolTip">
<string>Delete all proxy clips</string>
</property>
<property name="icon">
<iconset theme="trash-empty">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QToolButton" name="gClean">
<property name="toolTip">
<string>Cleanup unused cache</string>
</property>
<property name="icon">
<iconset theme="edit-clear-history">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QToolButton" name="gBackupClean">
<property name="toolTip">
<string>Cleanup old backups</string>
</property>
<property name="icon">
<iconset theme="edit-clear-history">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="gSelectedColor">
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="5">
<widget class="QFrame" name="seperator2">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="gBackupSize">
<property name="text">
<string>Calculating...</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="5">
<widget class="QLabel" name="gProxyPath">
<property name="toolTip">
<string>Click to open proxy folder</string>
</property>
<property name="text">
<string>&lt;a href='#'&gt;/home/user/.cache/kdenlive/proxy&lt;/a&gt;</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="gProxyLabel">
<property name="text">
<string>Total Proxy Data</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="5">
<widget class="QLabel" name="gBackupPath">
<property name="toolTip">
<string>Click to open backup folder</string>
</property>
<property name="text">
<string>&lt;a href='#'&gt;/home/user/.local/share/kdenlive/.backup&lt;/a&gt;</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="gTotalSize">
<property name="text">
<string>Calculating...</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="qSelectedLabel">
<property name="text">
<string>Selected Cached Data</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="gSelectedSize">
<property name="text">
<string>Calculating...</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">