[PictureLoader] Periodically refresh the local images index (#5997)

This commit is contained in:
RickyRister 2025-06-22 15:25:04 -07:00 committed by GitHub
parent b69091a51a
commit c1f12f52ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View file

@ -7,6 +7,8 @@
#include <QDirIterator>
#include <QMovie>
static constexpr int REFRESH_INTERVAL_MS = 10 * 1000;
PictureLoaderLocal::PictureLoaderLocal(QObject *parent)
: QObject(parent), picsPath(SettingsCache::instance().getPicsPath()),
customPicsPath(SettingsCache::instance().getCustomPicsPath()),
@ -17,11 +19,17 @@ PictureLoaderLocal::PictureLoaderLocal(QObject *parent)
connect(&SettingsCache::instance(), &SettingsCache::overrideAllCardArtWithPersonalPreferenceChanged, this,
&PictureLoaderLocal::setOverrideAllCardArtWithPersonalPreference);
createIndex();
refreshIndex();
refreshTimer = new QTimer(this);
connect(refreshTimer, &QTimer::timeout, this, &PictureLoaderLocal::refreshIndex);
refreshTimer->start(REFRESH_INTERVAL_MS);
}
void PictureLoaderLocal::createIndex()
void PictureLoaderLocal::refreshIndex()
{
customFolderIndex.clear();
QDirIterator it(customPicsPath, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
// Recursively check all subdirectories of the CUSTOM folder
@ -37,8 +45,8 @@ void PictureLoaderLocal::createIndex()
}
}
qCInfo(PictureLoaderLocalLog) << "Finished indexing local image folder CUSTOM; map now has"
<< customFolderIndex.size() << "entries.";
qCDebug(PictureLoaderLocalLog) << "Finished indexing local image folder CUSTOM; map now has"
<< customFolderIndex.size() << "entries.";
}
/**