From 407c1cf85cad6c3ec951f943f2a272cb02a10a62 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Tue, 25 Dec 2018 12:36:11 +0500 Subject: [PATCH] UI: Minor fixes. --- src/ui/fortmanager.cpp | 44 +++++++++++++-------------------------- src/ui/fortmanager.h | 5 +++-- src/ui/log/logmanager.cpp | 2 +- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index 489d62dc..0c54dd4b 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -61,19 +61,17 @@ FortManager::FortManager(FortSettings *fortSettings, m_taskManager(new TaskManager(this, this)) { setupLogger(); - setupDriver(); setupDatabaseManager(); setupLogManager(); + setupDriver(); loadSettings(m_firewallConf); m_taskManager->loadSettings(m_fortSettings); - TranslationManager::instance()->switchLanguageByName( - m_fortSettings->language()); - registerQmlTypes(); + setupTranslationManager(); setupTrayIcon(); } @@ -162,6 +160,12 @@ void FortManager::setupLogManager() m_logManager->initialize(); } +void FortManager::setupTranslationManager() +{ + TranslationManager::instance()->switchLanguageByName( + m_fortSettings->language()); +} + void FortManager::setupTrayIcon() { m_trayIcon->setToolTip(qApp->applicationDisplayName()); @@ -418,11 +422,10 @@ bool FortManager::saveSettings(FirewallConf *newConf, bool onlyFlags, updateTrayMenu(); } - return onlyFlags ? updateDriverConfFlags(m_firewallConf) - : updateDriverConf(m_firewallConf); + return updateDriverConf(m_firewallConf, onlyFlags); } -bool FortManager::updateDriverConf(FirewallConf *conf) +bool FortManager::updateDriverConf(FirewallConf *conf, bool onlyFlags) { if (!m_driverManager->isDeviceOpened()) return true; @@ -430,7 +433,10 @@ bool FortManager::updateDriverConf(FirewallConf *conf) updateLogManager(false); // Update driver - const bool res = m_driverManager->writeConf(*conf); + const bool res = onlyFlags + ? m_driverManager->writeConfFlags(*conf) + : m_driverManager->writeConf(*conf); + if (res) { updateDatabaseManager(conf); } else { @@ -442,26 +448,6 @@ bool FortManager::updateDriverConf(FirewallConf *conf) return res; } -bool FortManager::updateDriverConfFlags(FirewallConf *conf) -{ - if (!m_driverManager->isDeviceOpened()) - return true; - - updateLogManager(false); - - // Update driver - const bool res = m_driverManager->writeConfFlags(*conf); - if (res) { - updateDatabaseManager(conf); - } else { - showErrorBox("Update Driver Conf Flags: " + m_driverManager->errorMessage()); - } - - updateLogManager(true); - - return res; -} - void FortManager::updateLogManager(bool active) { m_logManager->setActive(active); @@ -497,7 +483,7 @@ void FortManager::saveTrayFlags() m_fortSettings->writeConfIni(*m_firewallConf); - updateDriverConfFlags(m_firewallConf); + updateDriverConf(m_firewallConf, true); } FirewallConf *FortManager::cloneConf(const FirewallConf &conf) diff --git a/src/ui/fortmanager.h b/src/ui/fortmanager.h index bd64a70f..ecc652fa 100644 --- a/src/ui/fortmanager.h +++ b/src/ui/fortmanager.h @@ -91,6 +91,8 @@ private: void setupLogger(); void setupLogManager(); + void setupTranslationManager(); + void setupTrayIcon(); bool setupEngine(); @@ -100,8 +102,7 @@ private: bool saveSettings(FirewallConf *newConf, bool onlyFlags = false, bool immediateFlags = false); - bool updateDriverConf(FirewallConf *conf); - bool updateDriverConfFlags(FirewallConf *conf); + bool updateDriverConf(FirewallConf *conf, bool onlyFlags = false); void updateLogManager(bool active); void updateDatabaseManager(FirewallConf *conf); diff --git a/src/ui/log/logmanager.cpp b/src/ui/log/logmanager.cpp index 162f4627..6299b17f 100644 --- a/src/ui/log/logmanager.cpp +++ b/src/ui/log/logmanager.cpp @@ -55,7 +55,7 @@ void LogManager::close() { QCoreApplication::sendPostedEvents(this); - m_driverWorker->disconnect(this); + disconnect(m_driverWorker); } void LogManager::setupDriverWorker()