UI: RuleEdit: Message on Global Rules count exceeded

This commit is contained in:
Nodir Temirkhodjaev 2024-04-12 17:37:47 +03:00
parent 732ae8be41
commit 9461d59c9a
2 changed files with 8 additions and 0 deletions

View File

@ -37,6 +37,11 @@ ConfRuleManager *RuleEditDialog::confRuleManager() const
return ctrl()->confRuleManager();
}
WindowManager *RuleEditDialog::windowManager() const
{
return ctrl()->windowManager();
}
void RuleEditDialog::initialize(const RuleRow &ruleRow)
{
m_ruleRow = ruleRow;
@ -397,6 +402,7 @@ bool RuleEditDialog::validateFields() const
const auto ruleType = Rule::RuleType(m_comboRuleType->currentIndex());
if (ruleType == Rule::GlobalBeforeAppsRule || ruleType == Rule::GlobalAfterAppsRule) {
if (confRuleManager()->rulesCountByType(ruleType) >= ConfUtil::ruleSetMaxCount()) {
windowManager()->showErrorBox(tr("Global rules count exceeded!"));
m_comboRuleType->setFocus();
return false;
}

View File

@ -19,6 +19,7 @@ class PlainTextEdit;
class Rule;
class RuleSetModel;
class RulesController;
class WindowManager;
class ZonesSelector;
class RuleEditDialog : public QDialog
@ -31,6 +32,7 @@ public:
RulesController *ctrl() const { return m_ctrl; }
RuleSetModel *ruleSetModel() const { return m_ruleSetModel; }
ConfRuleManager *confRuleManager() const;
WindowManager *windowManager() const;
bool isEmpty() const { return m_ruleRow.ruleId == 0; }