refactor(wayland): seperate cmake files for modularity

This commit is contained in:
outfoxxed 2024-02-19 00:52:03 -08:00
parent 5bbd0333ef
commit c6dde9ca9d
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
28 changed files with 32 additions and 33 deletions

38
src/core/watcher.cpp Normal file
View file

@ -0,0 +1,38 @@
#include "watcher.hpp"
#include <qdir.h>
#include <qfileinfo.h>
#include <qfilesystemwatcher.h>
#include <qobject.h>
#include <qtmetamacros.h>
FiletreeWatcher::FiletreeWatcher(QObject* parent): QObject(parent) {
QObject::connect(
&this->watcher,
&QFileSystemWatcher::fileChanged,
this,
&FiletreeWatcher::onFileChanged
);
QObject::connect(
&this->watcher,
&QFileSystemWatcher::directoryChanged,
this,
&FiletreeWatcher::onDirectoryChanged
);
}
void FiletreeWatcher::addPath(const QString& path) {
this->watcher.addPath(path);
if (QFileInfo(path).isDir()) {
auto dir = QDir(path);
for (auto& entry: dir.entryList(QDir::AllEntries | QDir::NoDotAndDotDot)) {
this->addPath(dir.filePath(entry));
}
}
}
void FiletreeWatcher::onDirectoryChanged(const QString& path) { this->addPath(path); }
void FiletreeWatcher::onFileChanged(const QString& path) { emit this->fileChanged(path); }