-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimagecontroller.h
More file actions
45 lines (37 loc) · 1.17 KB
/
imagecontroller.h
File metadata and controls
45 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef IMAGECONTROLLER_H
#define IMAGECONTROLLER_H
#include <string>
#include <vector>
#include <QFileInfo>
#include <QPixMap>
#include <QMutex>
#include <QThread>
#include <atomic>
#include "cachemanager.h"
class ImageController : public QObject {
Q_OBJECT
public:
ImageController();
~ImageController();
void initialize(const std::string &path);
QPixmap getPixMap();
QFileInfo getFileInfo();
std::string getCurrentFile() const;
void nextImage();
void previousImage();
// Start preloading images around the current index
void startPreloading();
int getCacheSize();
int getMaxCacheSize();
signals:
void cacheSizeChanged(int newSize); // Signal to notify when cache size changes (for displaying on frontend)
private:
std::atomic<bool> cancelPreloading; // cancellation flag for preloading tasks
void scanDirectory(const std::string &directory);
bool isSupportedFile(const std::string &file) const;
std::vector<std::string> fileList;
int currentIndex;
CacheManager cacheManager; // Use CacheManager for caching images
QMutex cacheMutex; // Mutex for thread safety
};
#endif // IMAGECONTROLLER_H