UI: QuotaManager: Process Quota exceed action

This commit is contained in:
Nodir Temirkhodjaev 2023-01-17 14:05:41 +03:00
parent 660c049d48
commit cb6558e1f2
3 changed files with 18 additions and 9 deletions

View File

@ -271,13 +271,6 @@ void FortManager::setupConfManager()
void FortManager::setupQuotaManager()
{
connect(IoC<QuotaManager>(), &QuotaManager::alert, this, [&](qint8 alertType) {
auto confManager = IoC<ConfManager>();
auto conf = confManager->conf();
if (conf->ini().quotaStopInetTraffic() && !conf->stopInetTraffic()) {
conf->setStopInetTraffic(true);
confManager->saveFlags();
}
IoC<WindowManager>()->showInfoBox(
QuotaManager::alertTypeText(alertType), tr("Quota Alert"));
});

View File

@ -74,7 +74,7 @@ void QuotaManager::checkQuotaDay(qint32 trafDay)
if (m_trafDayBytes > m_quotaDayBytes) {
setQuotaDayAlerted(trafDay);
emit alert(AlertDay);
processQuotaExceed(AlertDay);
}
}
@ -93,7 +93,7 @@ void QuotaManager::checkQuotaMonth(qint32 trafMonth)
if (m_trafMonthBytes > m_quotaMonthBytes) {
setQuotaMonthAlerted(trafMonth);
emit alert(AlertMonth);
processQuotaExceed(AlertMonth);
}
}
@ -151,3 +151,16 @@ void QuotaManager::setQuotaMonthAlerted(int v)
confManager->saveIni();
}
}
void QuotaManager::processQuotaExceed(AlertType alertType)
{
auto confManager = IoC<ConfManager>();
FirewallConf *conf = confManager->conf();
if (conf->ini().quotaStopInetTraffic() && !conf->stopInetTraffic()) {
conf->setStopInetTraffic(true);
confManager->saveFlags();
}
emit alert(alertType);
}

View File

@ -38,6 +38,9 @@ protected:
virtual int quotaMonthAlerted() const;
virtual void setQuotaMonthAlerted(qint32 v);
private:
void processQuotaExceed(AlertType alertType);
private:
int m_quotaDayAlerted = 0;
int m_quotaMonthAlerted = 0;