Add simple live mode that show last image added to directory

This commit is contained in:
2019-08-21 06:39:18 +02:00
parent 9a5027e498
commit 50dcd4b902
4 changed files with 18 additions and 2 deletions
+8 -2
View File
@@ -94,6 +94,7 @@ void Image::imageLoaded(QImage img)
}
ImageRingList::ImageRingList(QObject *parent) : QObject(parent)
, m_liveMode(false)
{
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
}
@@ -107,13 +108,13 @@ bool ImageRingList::setDir(const QString path, const QString &currentFile)
QStringList nameFilter;
nameFilter << "*.jpg" << "*.png" << "*.cr2";
QStringList list = dir.entryList(nameFilter, QDir::Files | QDir::Readable, QDir::Name);
QStringList list = dir.entryList(nameFilter, QDir::Files | QDir::Readable, m_liveMode ? QDir::Time : QDir::Name);
QStringList absolutePaths;
foreach(const QString &file, list)
{
absolutePaths.append(dir.absoluteFilePath(file));
}
setFiles(absolutePaths, currentFile);
setFiles(absolutePaths, m_liveMode ? list.first() : currentFile);
m_fileSystemWatcher.removePaths(m_fileSystemWatcher.directories());
m_fileSystemWatcher.addPath(path);
@@ -162,6 +163,11 @@ void ImageRingList::decrement()
}
}
void ImageRingList::setLiveMode(bool live)
{
m_liveMode = live;
}
void ImageRingList::setFiles(const QStringList files, const QString &currentFile)
{
m_images.clear();