From 70a8ced4b8c3e914092ff4a808c4fd8c052fabef Mon Sep 17 00:00:00 2001 From: iaom <18504285112@163.com> Date: Mon, 17 May 2021 20:54:48 +0800 Subject: [PATCH] Fix: Block list conf won't work. --- libsearch/global-settings.cpp | 8 ++++++++ libsearch/global-settings.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/libsearch/global-settings.cpp b/libsearch/global-settings.cpp index 838ac79..32df70c 100644 --- a/libsearch/global-settings.cpp +++ b/libsearch/global-settings.cpp @@ -37,6 +37,14 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent) { // m_settings->setAtomicSyncRequired(false); m_block_dirs_settings = new QSettings(BLOCK_DIRS, QSettings::IniFormat, this); m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8")); + m_block_dirs_settings->setValue("These_are_block_dirs_conf_for_ukui_search","0"); + m_block_dirs_settings->sync(); + m_confWatcher = new QFileSystemWatcher(this); + m_confWatcher->addPath(BLOCK_DIRS); + connect(m_confWatcher, &QFileSystemWatcher::fileChanged, this, [ & ]() { + m_block_dirs_settings->sync(); + m_confWatcher->addPath(BLOCK_DIRS); + }); m_search_record_settings = new QSettings(SEARCH_HISTORY, QSettings::IniFormat, this); m_search_record_settings->setIniCodec(QTextCodec::codecForName("UTF-8")); diff --git a/libsearch/global-settings.h b/libsearch/global-settings.h index 3de9ded..4a61cc2 100644 --- a/libsearch/global-settings.h +++ b/libsearch/global-settings.h @@ -26,6 +26,7 @@ #include #include #include +#include //#include //If use pkg_config, it wont build succes,why????????? //My demo can build access yet. @@ -102,6 +103,7 @@ private: QSettings *m_search_record_settings; QMap m_cache; QStringList m_history; + QFileSystemWatcher *m_confWatcher; QMutex m_mutex; // size_t test = 0;