-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileWatcher.h
More file actions
38 lines (30 loc) · 817 Bytes
/
FileWatcher.h
File metadata and controls
38 lines (30 loc) · 817 Bytes
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
#ifndef FILEWATCHER_H
#define FILEWATCHER_H
#include <QObject>
#include <QFileSystemWatcher>
#include <QTimer>
#include <QQmlApplicationEngine>
class FileWatcher : public QObject
{
Q_OBJECT
public:
explicit FileWatcher(QObject *parent = nullptr);
void setPath(const QString &path);
void setNameFilters(const QStringList &filters){m_nameFilters = filters;}
void setEngine(QQmlApplicationEngine &e){
engine = &e;
}
Q_INVOKABLE void clearCache();
signals:
void fileChanged();
private slots:
void onFileChanged(const QString &filePath);
private:
QFileSystemWatcher *watcher{nullptr};
QStringList m_nameFilters;
QStringList filesToWatch;
bool fileIsChaned{false};
QTimer *timer{nullptr};
QQmlApplicationEngine *engine;
};
#endif // FILEWATCHER_H