UI: Minor fixes.

This commit is contained in:
Nodir Temirkhodjaev 2018-12-25 12:36:11 +05:00
parent bc37a34142
commit 407c1cf85c
3 changed files with 19 additions and 32 deletions

View File

@ -61,19 +61,17 @@ FortManager::FortManager(FortSettings *fortSettings,
m_taskManager(new TaskManager(this, this)) m_taskManager(new TaskManager(this, this))
{ {
setupLogger(); setupLogger();
setupDriver();
setupDatabaseManager(); setupDatabaseManager();
setupLogManager(); setupLogManager();
setupDriver();
loadSettings(m_firewallConf); loadSettings(m_firewallConf);
m_taskManager->loadSettings(m_fortSettings); m_taskManager->loadSettings(m_fortSettings);
TranslationManager::instance()->switchLanguageByName(
m_fortSettings->language());
registerQmlTypes(); registerQmlTypes();
setupTranslationManager();
setupTrayIcon(); setupTrayIcon();
} }
@ -162,6 +160,12 @@ void FortManager::setupLogManager()
m_logManager->initialize(); m_logManager->initialize();
} }
void FortManager::setupTranslationManager()
{
TranslationManager::instance()->switchLanguageByName(
m_fortSettings->language());
}
void FortManager::setupTrayIcon() void FortManager::setupTrayIcon()
{ {
m_trayIcon->setToolTip(qApp->applicationDisplayName()); m_trayIcon->setToolTip(qApp->applicationDisplayName());
@ -418,11 +422,10 @@ bool FortManager::saveSettings(FirewallConf *newConf, bool onlyFlags,
updateTrayMenu(); updateTrayMenu();
} }
return onlyFlags ? updateDriverConfFlags(m_firewallConf) return updateDriverConf(m_firewallConf, onlyFlags);
: updateDriverConf(m_firewallConf);
} }
bool FortManager::updateDriverConf(FirewallConf *conf) bool FortManager::updateDriverConf(FirewallConf *conf, bool onlyFlags)
{ {
if (!m_driverManager->isDeviceOpened()) if (!m_driverManager->isDeviceOpened())
return true; return true;
@ -430,7 +433,10 @@ bool FortManager::updateDriverConf(FirewallConf *conf)
updateLogManager(false); updateLogManager(false);
// Update driver // Update driver
const bool res = m_driverManager->writeConf(*conf); const bool res = onlyFlags
? m_driverManager->writeConfFlags(*conf)
: m_driverManager->writeConf(*conf);
if (res) { if (res) {
updateDatabaseManager(conf); updateDatabaseManager(conf);
} else { } else {
@ -442,26 +448,6 @@ bool FortManager::updateDriverConf(FirewallConf *conf)
return res; 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) void FortManager::updateLogManager(bool active)
{ {
m_logManager->setActive(active); m_logManager->setActive(active);
@ -497,7 +483,7 @@ void FortManager::saveTrayFlags()
m_fortSettings->writeConfIni(*m_firewallConf); m_fortSettings->writeConfIni(*m_firewallConf);
updateDriverConfFlags(m_firewallConf); updateDriverConf(m_firewallConf, true);
} }
FirewallConf *FortManager::cloneConf(const FirewallConf &conf) FirewallConf *FortManager::cloneConf(const FirewallConf &conf)

View File

@ -91,6 +91,8 @@ private:
void setupLogger(); void setupLogger();
void setupLogManager(); void setupLogManager();
void setupTranslationManager();
void setupTrayIcon(); void setupTrayIcon();
bool setupEngine(); bool setupEngine();
@ -100,8 +102,7 @@ private:
bool saveSettings(FirewallConf *newConf, bool onlyFlags = false, bool saveSettings(FirewallConf *newConf, bool onlyFlags = false,
bool immediateFlags = false); bool immediateFlags = false);
bool updateDriverConf(FirewallConf *conf); bool updateDriverConf(FirewallConf *conf, bool onlyFlags = false);
bool updateDriverConfFlags(FirewallConf *conf);
void updateLogManager(bool active); void updateLogManager(bool active);
void updateDatabaseManager(FirewallConf *conf); void updateDatabaseManager(FirewallConf *conf);

View File

@ -55,7 +55,7 @@ void LogManager::close()
{ {
QCoreApplication::sendPostedEvents(this); QCoreApplication::sendPostedEvents(this);
m_driverWorker->disconnect(this); disconnect(m_driverWorker);
} }
void LogManager::setupDriverWorker() void LogManager::setupDriverWorker()