Reduce memory usage

This commit is contained in:
reionwong 2021-10-15 18:57:18 +08:00
parent 8ede4f8f41
commit bbcbe40747
4 changed files with 13 additions and 0 deletions

View file

@ -53,6 +53,7 @@
#include <QProcess>
#include <QSettings>
#include <QDesktopServices>
#include <QPixmapCache>
// Qt Quick
#include <QQuickItem>
@ -1199,6 +1200,11 @@ void FolderModel::keyboardSearch(const QString &text)
}
}
void FolderModel::clearPixmapCache()
{
QPixmapCache::clear();
}
void FolderModel::restoreFromTrash()
{
if (!m_selectionModel->hasSelection())

View file

@ -209,6 +209,8 @@ public:
Q_INVOKABLE void updateSelectedItemsSize();
Q_INVOKABLE void keyboardSearch(const QString &text);
Q_INVOKABLE void clearPixmapCache();
void restoreFromTrash();
bool isDesktop() const;

View file

@ -41,6 +41,9 @@ Item {
clip: true
cache: false
// Clear cache
onSourceChanged: dirModel.clearPixmapCache()
ColorOverlay {
id: dimsWallpaper
anchors.fill: parent

View file

@ -21,6 +21,7 @@
#include <QEvent>
#include <QDebug>
#include <QQuickWindow>
#include <QPixmapCache>
Window::Window(QObject *parent)
: QQmlApplicationEngine(parent)
@ -40,6 +41,7 @@ void Window::load(const QUrl &url)
bool Window::eventFilter(QObject *obj, QEvent *e)
{
if (e->type() == QEvent::Close) {
QPixmapCache::clear();
clearComponentCache();
deleteLater();
e->accept();