Add simple live mode that show last image added to directory
This commit is contained in:
+8
-2
@@ -94,6 +94,7 @@ void Image::imageLoaded(QImage img)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImageRingList::ImageRingList(QObject *parent) : QObject(parent)
|
ImageRingList::ImageRingList(QObject *parent) : QObject(parent)
|
||||||
|
, m_liveMode(false)
|
||||||
{
|
{
|
||||||
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
|
connect(&m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
|
||||||
}
|
}
|
||||||
@@ -107,13 +108,13 @@ bool ImageRingList::setDir(const QString path, const QString ¤tFile)
|
|||||||
QStringList nameFilter;
|
QStringList nameFilter;
|
||||||
nameFilter << "*.jpg" << "*.png" << "*.cr2";
|
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;
|
QStringList absolutePaths;
|
||||||
foreach(const QString &file, list)
|
foreach(const QString &file, list)
|
||||||
{
|
{
|
||||||
absolutePaths.append(dir.absoluteFilePath(file));
|
absolutePaths.append(dir.absoluteFilePath(file));
|
||||||
}
|
}
|
||||||
setFiles(absolutePaths, currentFile);
|
setFiles(absolutePaths, m_liveMode ? list.first() : currentFile);
|
||||||
|
|
||||||
m_fileSystemWatcher.removePaths(m_fileSystemWatcher.directories());
|
m_fileSystemWatcher.removePaths(m_fileSystemWatcher.directories());
|
||||||
m_fileSystemWatcher.addPath(path);
|
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 ¤tFile)
|
void ImageRingList::setFiles(const QStringList files, const QString ¤tFile)
|
||||||
{
|
{
|
||||||
m_images.clear();
|
m_images.clear();
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class ImageRingList : public QObject
|
|||||||
QList<ImagePtr>::iterator m_currImage;
|
QList<ImagePtr>::iterator m_currImage;
|
||||||
QList<ImagePtr>::iterator m_lastImage;
|
QList<ImagePtr>::iterator m_lastImage;
|
||||||
QFileSystemWatcher m_fileSystemWatcher;
|
QFileSystemWatcher m_fileSystemWatcher;
|
||||||
|
bool m_liveMode;
|
||||||
public:
|
public:
|
||||||
explicit ImageRingList(QObject *parent = 0);
|
explicit ImageRingList(QObject *parent = 0);
|
||||||
bool setDir(const QString path, const QString ¤tFile = QString());
|
bool setDir(const QString path, const QString ¤tFile = QString());
|
||||||
@@ -44,6 +45,7 @@ public:
|
|||||||
ImagePtr currentImage();
|
ImagePtr currentImage();
|
||||||
void increment();
|
void increment();
|
||||||
void decrement();
|
void decrement();
|
||||||
|
void setLiveMode(bool live);
|
||||||
protected:
|
protected:
|
||||||
void setFiles(const QStringList files, const QString ¤tFile = QString());
|
void setFiles(const QStringList files, const QString ¤tFile = QString());
|
||||||
QList<ImagePtr>::iterator increment(QList<ImagePtr>::iterator iter);
|
QList<ImagePtr>::iterator increment(QList<ImagePtr>::iterator iter);
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
|
|||||||
QMenu *fileMenu = new QMenu(tr("File"), this);
|
QMenu *fileMenu = new QMenu(tr("File"), this);
|
||||||
fileMenu->addAction(tr("Open"), this, SLOT(openFile()), QKeySequence("Ctrl+O"));
|
fileMenu->addAction(tr("Open"), this, SLOT(openFile()), QKeySequence("Ctrl+O"));
|
||||||
fileMenu->addAction(tr("Copy marked files"), this, SLOT(copyMarked()));
|
fileMenu->addAction(tr("Copy marked files"), this, SLOT(copyMarked()));
|
||||||
|
QAction *liveModeAction = fileMenu->addAction(tr("Live mode"), this, SLOT(liveMode(bool)));
|
||||||
|
liveModeAction->setCheckable(true);
|
||||||
fileMenu->addAction(tr("Exit"), this, SLOT(close()));
|
fileMenu->addAction(tr("Exit"), this, SLOT(close()));
|
||||||
menuBar()->addMenu(fileMenu);
|
menuBar()->addMenu(fileMenu);
|
||||||
|
|
||||||
@@ -225,6 +227,11 @@ void MainWindow::copyMarked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::liveMode(bool active)
|
||||||
|
{
|
||||||
|
m_ringList->setLiveMode(active);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::updateWindowTitle()
|
void MainWindow::updateWindowTitle()
|
||||||
{
|
{
|
||||||
ImagePtr ptr = m_ringList->currentImage();
|
ImagePtr ptr = m_ringList->currentImage();
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ protected slots:
|
|||||||
void markAndNext();
|
void markAndNext();
|
||||||
void unmarkAndNext();
|
void unmarkAndNext();
|
||||||
void copyMarked();
|
void copyMarked();
|
||||||
|
void liveMode(bool active);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user