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

View file

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

View file

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

View file

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