diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-02 17:41:45 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-02 17:41:45 +1000 |
| commit | 74a99d2ac4dab391db7574d6c09f219591d2afcc (patch) | |
| tree | 1fab3f1834553668d12ea98da1728c44ff407017 /plugin/src/Caelestia/filesystemmodel.cpp | |
| parent | plugin/fsm: async add watcher paths (diff) | |
| download | caelestia-shell-74a99d2ac4dab391db7574d6c09f219591d2afcc.tar.gz caelestia-shell-74a99d2ac4dab391db7574d6c09f219591d2afcc.tar.bz2 caelestia-shell-74a99d2ac4dab391db7574d6c09f219591d2afcc.zip | |
plugin/fsm: allow disabling watching
Diffstat (limited to 'plugin/src/Caelestia/filesystemmodel.cpp')
| -rw-r--r-- | plugin/src/Caelestia/filesystemmodel.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugin/src/Caelestia/filesystemmodel.cpp b/plugin/src/Caelestia/filesystemmodel.cpp index 40b322b..3ba95d8 100644 --- a/plugin/src/Caelestia/filesystemmodel.cpp +++ b/plugin/src/Caelestia/filesystemmodel.cpp @@ -59,6 +59,21 @@ void FileSystemModel::setRecursive(bool recursive) { update(); } +bool FileSystemModel::watchChanges() const { + return m_watchChanges; +} + +void FileSystemModel::setWatchChanges(bool watchChanges) { + if (m_watchChanges == watchChanges) { + return; + } + + m_watchChanges = watchChanges; + emit watchChangesChanged(); + + update(); +} + FileSystemModel::Filter FileSystemModel::filter() const { return m_filter; } @@ -79,7 +94,7 @@ QList<FileSystemEntry*> FileSystemModel::entries() const { } void FileSystemModel::watchDirIfRecursive(const QString& path) { - if (m_recursive) { + if (m_recursive && m_watchChanges) { const auto currentDir = m_dir; const auto future = QtConcurrent::run([path]() { QDirIterator iter(path, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); @@ -112,7 +127,7 @@ void FileSystemModel::updateWatcher() { m_watcher.removePaths(m_watcher.directories()); } - if (m_path.isEmpty()) { + if (!m_watchChanges || m_path.isEmpty()) { return; } |