mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
Revert "Revert file watcher in VDS"
This commit is contained in:
parent
5238087ddf
commit
50dbc763d3
2 changed files with 20 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <QComboBox>
|
||||
#include <QDirIterator>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QMouseEvent>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
|
@ -125,6 +126,12 @@ VisualDeckStorageWidget::VisualDeckStorageWidget(QWidget *parent) : QWidget(pare
|
|||
} else {
|
||||
scrollArea->setWidget(databaseLoadIndicator);
|
||||
}
|
||||
|
||||
addRecursiveWatch(watcher, SettingsCache::instance().getDeckPath());
|
||||
|
||||
// Signals for changes
|
||||
connect(&watcher, &QFileSystemWatcher::fileChanged, this, &VisualDeckStorageWidget::refreshIfPossible);
|
||||
connect(&watcher, &QFileSystemWatcher::directoryChanged, this, &VisualDeckStorageWidget::refreshIfPossible);
|
||||
}
|
||||
|
||||
void VisualDeckStorageWidget::refreshIfPossible()
|
||||
|
|
@ -134,6 +141,16 @@ void VisualDeckStorageWidget::refreshIfPossible()
|
|||
}
|
||||
}
|
||||
|
||||
void VisualDeckStorageWidget::addRecursiveWatch(QFileSystemWatcher &watcher, const QString &dirPath)
|
||||
{
|
||||
QDir dir(dirPath);
|
||||
watcher.addPath(dirPath); // Watch the root directory
|
||||
|
||||
for (const QFileInfo &entry : dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||
addRecursiveWatch(watcher, entry.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
void VisualDeckStorageWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <QCheckBox>
|
||||
#include <QFileSystemModel>
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
class VisualDeckStorageSearchWidget;
|
||||
class VisualDeckStorageSortWidget;
|
||||
|
|
@ -26,6 +27,7 @@ class VisualDeckStorageWidget final : public QWidget
|
|||
public:
|
||||
explicit VisualDeckStorageWidget(QWidget *parent);
|
||||
void refreshIfPossible();
|
||||
void addRecursiveWatch(QFileSystemWatcher &watcher, const QString &dirPath);
|
||||
void retranslateUi();
|
||||
|
||||
CardSizeWidget *cardSizeWidget;
|
||||
|
|
@ -66,6 +68,7 @@ private:
|
|||
QCheckBox *searchFolderNamesCheckBox;
|
||||
QScrollArea *scrollArea;
|
||||
VisualDeckStorageFolderDisplayWidget *folderWidget;
|
||||
QFileSystemWatcher watcher;
|
||||
|
||||
void reapplySortAndFilters();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue