Add generating thumbnails from cmd line

This commit is contained in:
2025-03-17 11:08:18 +01:00
parent 21675d9479
commit f30dd2a520
8 changed files with 124 additions and 27 deletions
+17 -5
View File
@@ -113,6 +113,7 @@ ImageRingList::ImageRingList(Database *database, const QStringList &nameFilter,
, m_analyzeLevel(None)
, m_database(database)
, m_nameFilter(nameFilter)
, m_fileSuffix(nameFilter)
{
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
m_nameFilter.replaceInStrings(QRegularExpression("^"), "*.");
@@ -170,8 +171,8 @@ bool ImageRingList::setDir(const QString path, const QString &currentFile, bool
};
scanDir(path);
qDebug() << absolutePaths.size();
setFiles(absolutePaths, m_liveMode ? absolutePaths.first() : currentFile);
//qDebug() << absolutePaths.size();
setFilesPrivate(absolutePaths, m_liveMode ? absolutePaths.first() : currentFile);
m_fileSystemWatcher.removePaths(m_fileSystemWatcher.directories());
m_fileSystemWatcher.addPath(path);
@@ -192,6 +193,17 @@ void ImageRingList::setFile(const QString &file)
}
}
void ImageRingList::setFiles(QStringList files)
{
QRegularExpression reg("(" + m_fileSuffix.join("|") + ")");
files.removeIf([&reg](const QString &file){
QFileInfo info(file);
auto match = reg.match(info.suffix());
return !match.hasMatch() || !info.exists() || !info.isReadable() || !info.isFile();
});
setFilesPrivate(files);
}
ImagePtr ImageRingList::currentImage()
{
if(m_images.size())
@@ -237,11 +249,11 @@ void ImageRingList::decrement()
void ImageRingList::setMarked()
{
QStringList files = m_database->getMarkedFiles();
std::remove_if(files.begin(), files.end(), [](const QString &file){
files.removeIf([](const QString &file){
QFileInfo info(file);
return !info.exists() || !info.isReadable();
});
setFiles(files);
setFilesPrivate(files);
}
void ImageRingList::setLiveMode(bool live)
@@ -474,7 +486,7 @@ void ImageRingList::toggleSlideshow(bool start)
}
}
void ImageRingList::setFiles(const QStringList files, const QString &currentFile)
void ImageRingList::setFilesPrivate(const QStringList files, const QString &currentFile)
{
m_loadPool->clear();
m_thumbPool->clear();