From 1b0ed39a085c3beea5069bacdbfcf0147c3b8e99 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 29 May 2024 15:38:36 +0300 Subject: [PATCH] UI: DbErrorManager: Check profile's dir for portable only --- deploy/data/FortFirewall.exe.example.ini | 3 +++ src/ui/fortsettings.cpp | 1 + src/ui/fortsettings.h | 2 ++ src/ui/manager/dberrormanager.cpp | 16 ++++++++++------ src/ui/manager/dberrormanager.h | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/deploy/data/FortFirewall.exe.example.ini b/deploy/data/FortFirewall.exe.example.ini index 431d2dda..d4afb339 100644 --- a/deploy/data/FortFirewall.exe.example.ini +++ b/deploy/data/FortFirewall.exe.example.ini @@ -49,3 +49,6 @@ ;Try to start a Service on startup. ;canStartService=false + +;Periodically check that Profile's directory is online. +;checkProfileOnline=false diff --git a/src/ui/fortsettings.cpp b/src/ui/fortsettings.cpp index e08bbf22..9ce6f026 100644 --- a/src/ui/fortsettings.cpp +++ b/src/ui/fortsettings.cpp @@ -121,6 +121,7 @@ void FortSettings::setupGlobal() m_forceDebug = settings.value("global/forceDebug").toBool(); m_canInstallDriver = settings.value("global/canInstallDriver").toBool(); m_canStartService = settings.value("global/canStartService").toBool(); + m_checkProfileOnline = settings.value("global/checkProfileOnline").toBool(); m_defaultLanguage = settings.value("global/defaultLanguage").toString(); m_profilePath = settings.value("global/profileDir").toString(); diff --git a/src/ui/fortsettings.h b/src/ui/fortsettings.h index 69e9299e..d06f07bb 100644 --- a/src/ui/fortsettings.h +++ b/src/ui/fortsettings.h @@ -35,6 +35,7 @@ public: bool forceDebug() const { return m_forceDebug; } bool canInstallDriver() const { return m_canInstallDriver; } bool canStartService() const { return m_canStartService; } + bool checkProfileOnline() const { return m_checkProfileOnline; } bool isLaunch() const { return m_isLaunch; } @@ -137,6 +138,7 @@ private: uint m_forceDebug : 1 = false; uint m_canInstallDriver : 1 = false; uint m_canStartService : 1 = false; + uint m_checkProfileOnline : 1 = false; uint m_isLaunch : 1 = false; uint m_isService : 1 = false; uint m_hasService : 1 = false; diff --git a/src/ui/manager/dberrormanager.cpp b/src/ui/manager/dberrormanager.cpp index b738e54c..94de4d48 100644 --- a/src/ui/manager/dberrormanager.cpp +++ b/src/ui/manager/dberrormanager.cpp @@ -52,19 +52,23 @@ void DbErrorManager::checkConfDir() void DbErrorManager::setupTimer() { + auto settings = IoC(); + + const bool checkProfileOnline = (settings->checkProfileOnline() || settings->isPortable()); + if (!checkProfileOnline) + return; + + setupDirInfo(settings->confFilePath()); + auto timer = new QTimer(this); timer->setInterval(1500); timer->start(); connect(timer, &QTimer::timeout, this, &DbErrorManager::checkConfDir); - - setupDirInfo(); } -void DbErrorManager::setupDirInfo() +void DbErrorManager::setupDirInfo(const QString &path) { - auto settings = IoC(); - - m_confDir.setPath(settings->confFilePath()); + m_confDir.setPath(path); m_confDir.open(); } diff --git a/src/ui/manager/dberrormanager.h b/src/ui/manager/dberrormanager.h index e7edda6c..21e944ff 100644 --- a/src/ui/manager/dberrormanager.h +++ b/src/ui/manager/dberrormanager.h @@ -21,7 +21,7 @@ private slots: protected: virtual void setupTimer(); - void setupDirInfo(); + void setupDirInfo(const QString &path); private: DirInfo m_confDir;