forked from easymodo/qimgv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.h
122 lines (105 loc) · 3.04 KB
/
core.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef CORE_H
#define CORE_H
#include <QObject>
#include <QDebug>
#include <QTimer>
#include <QMutex>
#include <malloc.h>
#include "appversion.h"
#include "settings.h"
#include "components/directorymanager/directorymanager.h"
#include "components/loader/loader.h"
#include "components/scaler/scaler.h"
#include "components/thumbnailer/thumbnailer.h"
#include "components/scriptmanager/scriptmanager.h"
#include "gui/mainwindow.h"
struct State {
State() : currentIndex(0), hasActiveImage(false), isWaitingForLoader(false) {}
int currentIndex;
// TODO: come up with something better?
QString displayingFileName;
bool hasActiveImage, isWaitingForLoader;
};
class Core : public QObject {
Q_OBJECT
public:
Core();
void showGui();
public slots:
void updateInfoString();
void loadByPath(QString filePath, bool blocking);
// loads image in second thread
void loadByPath(QString);
// loads image in main thread
void loadByPathBlocking(QString);
// invalid position will be ignored
bool loadByIndex(int index);
bool loadByIndexBlocking(int index);
signals:
void imageIndexChanged(int);
private:
void initGui();
void initComponents();
void connectComponents();
void initActions();
void onUpdate();
void onFirstRun();
// ui stuff
MainWindow *mw;
State state;
QTimer *loadingTimer; // this is for loading message delay. TODO: replace with something better
bool infiniteScrolling;
// components
Loader *loader;
DirectoryManager *dirManager;
Cache *cache;
Scaler *scaler;
Thumbnailer *thumbnailer;
void rotateByDegrees(int degrees);
void reset();
bool setDirectory(QString newPath);
void displayImage(Image *img);
void loadDirectory(QString);
void loadImage(QString path, bool blocking);
void trimCache();
void preload(int index);
private slots:
void readSettings();
void nextImage();
void prevImage();
void jumpToFirst();
void jumpToLast();
void onLoadFinished(std::shared_ptr<Image> img);
void onLoadFailed(QString path);
void onLoadStarted();
void onLoadingTimeout();
void clearCache();
void rotateLeft();
void rotateRight();
void closeBackgroundTasks();
void close();
void scalingRequest(QSize);
void onScalingFinished(QPixmap* scaled, ScalerRequest req);
void forwardThumbnail(std::shared_ptr<Thumbnail> thumbnail);
void moveFile(QString destDirectory);
void copyFile(QString destDirectory);
void removeFile(int index, bool trash);
void onFileRemoved(int index);
void onFileAdded(int index);
void showResizeDialog();
void resize(QSize size);
void flipH();
void flipV();
void crop(QRect rect);
void discardEdits();
void toggleCropPanel();
void requestSavePath();
void saveImageToDisk();
void saveImageToDisk(QString);
void runScript(const QString&);
void removeFilePermanent();
void removeFilePermanent(int index);
void moveToTrash();
void moveToTrash(int index);
};
#endif // CORE_H