UI: ProgramEditDialog: Simplify fillApp()

This commit is contained in:
Nodir Temirkhodjaev 2024-01-29 19:48:17 +03:00
parent 91c4974fe8
commit 5abc3981bb
2 changed files with 23 additions and 13 deletions

View File

@ -642,21 +642,29 @@ void ProgramEditDialog::fillApp(App &app) const
app.acceptZones = m_btZones->zones(); app.acceptZones = m_btZones->zones();
app.rejectZones = m_btZones->uncheckedZones(); app.rejectZones = m_btZones->uncheckedZones();
// App Path fillAppPath(app);
{ fillAppEndTime(app);
const QString appPath = m_editPath->text(); }
app.appOriginPath = isWildcard() ? m_editWildcard->toPlainText() : appPath;
app.appPath = FileUtil::normalizePath(appPath);
}
if (!app.blocked) { void ProgramEditDialog::fillAppPath(App &app) const
if (m_cscBlockAppIn->checkBox()->isChecked()) { {
const int minutes = m_cscBlockAppIn->spinBox()->value(); const QString appPath = m_editPath->text();
app.endTime = QDateTime::currentDateTime().addSecs(minutes * 60); app.appOriginPath = isWildcard() ? m_editWildcard->toPlainText() : appPath;
} else if (m_cbBlockAppAt->isChecked()) { app.appPath = FileUtil::normalizePath(appPath);
app.endTime = m_dteBlockAppAt->dateTime(); }
}
void ProgramEditDialog::fillAppEndTime(App &app) const
{
if (app.blocked)
return;
if (m_cscBlockAppIn->checkBox()->isChecked()) {
const int minutes = m_cscBlockAppIn->spinBox()->value();
app.endTime = QDateTime::currentDateTime().addSecs(minutes * 60);
} else if (m_cbBlockAppAt->isChecked()) {
app.endTime = m_dteBlockAppAt->dateTime();
} }
} }

View File

@ -73,6 +73,8 @@ private:
bool validateFields() const; bool validateFields() const;
void fillApp(App &app) const; void fillApp(App &app) const;
void fillAppPath(App &app) const;
void fillAppEndTime(App &app) const;
bool isWildcard() const; bool isWildcard() const;