diff options
Diffstat (limited to 'options/globals.cpp')
-rw-r--r-- | options/globals.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/options/globals.cpp b/options/globals.cpp index 386ef56d..963cab90 100644 --- a/options/globals.cpp +++ b/options/globals.cpp @@ -3,8 +3,10 @@ #include "defs.hpp" #include <QFile> +#include <QFileInfo> #include <QDir> #include <QStandardPaths> +#include <QDateTime> #include <QDebug> namespace options::globals::detail { @@ -124,9 +126,24 @@ QString ini_combine(const QString& filename) QStringList ini_list() { - QDir settings_dir(ini_directory()); + static QMutex mtx; + static QStringList list; + QMutexLocker l{&mtx}; + + const QString dirname = ini_directory(); + + { + static QDateTime last_time = {}; + auto time = QFileInfo{dirname}.lastModified(); + if (time == last_time) + return list; + last_time = time; + } + + QDir settings_dir(dirname); + using f = QDir::Filter; - auto list = settings_dir.entryList({ QStringLiteral("*.ini") }, f::Files | f::Readable, QDir::Name); + list = settings_dir.entryList({ QStringLiteral("*.ini") }, f::Files | f::Readable, QDir::Name); std::sort(list.begin(), list.end()); return list; } |