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))
{
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)

View File

@ -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);

View File

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