21 connect(&m_fileWatcher, &QFileSystemWatcher::fileChanged,
this, [
this](
const QString &filePath) {
22 if (!QFile::exists(filePath)) {
23 m_files.removeAll(filePath);
26 }, Qt::QueuedConnection);
30 for (
const QString &filePath : std::as_const(m_files)) {
31 if (QFile::exists(filePath)) {
32 m_fileWatcher.addPath(filePath);
39 Q_ASSERT(QCoreApplication::instance()->thread() == QThread::currentThread());
41 qCDebug(three) <<
"Setting recent file to: " << filePath;
43 if (!QFile(filePath).exists()) {
47 m_fileWatcher.addPath(filePath);
51 m_files.removeAll(filePath);
52 m_files.prepend(filePath);
65 Q_ASSERT(QCoreApplication::instance()->thread() == QThread::currentThread());
73 while (i < m_files.size()) {
74 QFileInfo fileInfo(m_files.at(i));
76 if (!fileInfo.exists()) {
90void RecentFiles::saveRecentFiles()
Common logging utilities, the Pandaception error type, and helper macros.
#define qCDebug(category)
Recent-files list management with filesystem watching.
Typed wrappers around QSettings for all application preferences.
static constexpr int maxFiles
void recentFilesUpdated()
Emitted whenever the recent-files list changes (add or file deleted).
QStringList recentFiles()
Returns the current list of recent file paths.
RecentFiles(QObject *parent=nullptr)
Constructs the recent-files manager with parent.
void addRecentFile(const QString &filePath)
Prepends filePath to the recent-files list and saves it.
static QStringList recentFiles()
static void setRecentFiles(const QStringList &files)