Files
tenmon/imageringlist.h
T
2019-09-19 17:07:47 +02:00

69 lines
1.7 KiB
C++

#ifndef IMAGERINGLIST_H
#define IMAGERINGLIST_H
#include <QObject>
#include <QFileSystemWatcher>
#include <QList>
#include <QPixmap>
#include <memory>
#include "imageinfo.h"
class Image : public QObject
{
Q_OBJECT
bool m_loading;
bool m_released;
bool m_current;
QPixmap m_pixmap;
QString m_name;
ImageInfoData m_info;
public:
explicit Image(const QString name);
void load();
void release();
QString name() const;
QPixmap pixmap() const;
ImageInfoData info() const;
bool isCurrent() const;
signals:
void pixmapLoaded(Image *ptr);
protected slots:
void imageLoaded(QImage img, ImageInfoData info);
};
typedef std::shared_ptr<Image> ImagePtr;
class ImageRingList : public QObject
{
Q_OBJECT
int m_width;
QList<ImagePtr> m_images;
QList<ImagePtr>::iterator m_firstImage;
QList<ImagePtr>::iterator m_currImage;
QList<ImagePtr>::iterator m_lastImage;
QFileSystemWatcher m_fileSystemWatcher;
bool m_liveMode;
public:
explicit ImageRingList(QObject *parent = 0);
~ImageRingList();
bool setDir(const QString path, const QString &currentFile = QString());
void setFile(const QString &file);
ImagePtr currentImage();
void increment();
void decrement();
void setLiveMode(bool live);
protected:
void setFiles(const QStringList files, const QString &currentFile = QString());
QList<ImagePtr>::iterator increment(QList<ImagePtr>::iterator iter);
QList<ImagePtr>::iterator decrement(QList<ImagePtr>::iterator iter);
signals:
void pixmapLoaded(QPixmap pix);
void infoLoaded(ImageInfoData info);
void currentImageChanged();
protected slots:
void imageLoaded(Image *image);
void dirChanged(QString dir);
};
#endif // IMAGERINGLIST_H