-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettingswindow.cpp
More file actions
187 lines (148 loc) · 8.48 KB
/
Copy pathsettingswindow.cpp
File metadata and controls
187 lines (148 loc) · 8.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include "settingswindow.h"
#include "ui_settingswindow.h"
SettingsWindow::SettingsWindow(QWidget *parent, InvestigatorOrchestartor *investigator,
bool *isUiLocked):
QDialog(parent),
ui(new Ui::SettingsWindow) {
ui->setupUi(this);
m_isUiLocked = isUiLocked;
setWindowTitle("Настройки программы");
ui->threadsNumberSB->setMaximum(MaxThreadNb);
ui->directoryTab->setLayout(ui->directorySettingsLayout);
ui->avsTab->setLayout(ui->avsSettingsLayout);
ui->reactionTab->setLayout(ui->reactionSettingsLayout);
setMinimumSize(ui->settingsTabWidget->size());
setMaximumSize(ui->settingsTabWidget->size());
m_investigator = investigator;
updateUi();
}
SettingsWindow::~SettingsWindow() {
delete ui;
}
void SettingsWindow::on_watchDirButton_clicked() {
m_investigator->setSourceDir(QFileDialog::getExistingDirectory(this,
QString("Выбор директории для слежения"), m_investigator->sourceDir()));
updateUi();
}
void SettingsWindow::on_tempDirButton_clicked() {
m_investigator->setProcessDir(QFileDialog::getExistingDirectory(this,
QString("Директория для временных файлов"),
m_investigator->processDir()));
updateUi();
}
void SettingsWindow::on_cleanDirButton_clicked() {
m_investigator->setCleanDir(QFileDialog::getExistingDirectory(this,
QString("Директория для чистых файлов"), m_investigator->cleanDir()));
updateUi();
}
void SettingsWindow::on_dangerousDirButton_clicked() {
m_investigator->setInfectedDir(QFileDialog::getExistingDirectory(this,
QString("Директория для зараженных файлов"),
m_investigator->infectedDir()));
updateUi();
}
void SettingsWindow::on_avsExecFileButton_clicked() {
m_investigator->setAvsExecFileName(QFileDialog::getOpenFileName(this,
QString("Выбор исполняемого файла антивируса"),
m_investigator->avsExecFileName(), tr("*.exe")));
updateUi();
}
void SettingsWindow::on_thresholdFilesNbSB_valueChanged(int thresholdFilesNb) {
m_investigator->setThresholdFilesNb(thresholdFilesNb);
}
void SettingsWindow::on_thresholdFilesSizeSB_valueChanged(int thresholdFilesSize) {
m_investigator->setThresholdFilesSize(thresholdFilesSize);
}
void SettingsWindow::on_thresholdFilesSizeUnitCB_currentIndexChanged(int thresholdFilesUnitIdx) {
m_investigator->setThresholdFilesSizeUnit(SizeConverter::sizeIdxToUnit(thresholdFilesUnitIdx));
}
void SettingsWindow::on_threadsNumberSB_valueChanged(int workersNb) {
m_investigator->setWorkersNb(workersNb);
updateUi();
}
void SettingsWindow::updateUi() {
ui->settingsTabWidget->setCurrentIndex(m_currentOpenTab);
if (m_investigator) {
// --- DIRS PAGE ---
ui->watchDirButton->setEnabled(!*m_isUiLocked);
ui->watchDirLE->setText(m_investigator->sourceDir());
ui->watchDirLE->setStyleSheet((QDir(m_investigator->sourceDir()).exists()
&& !m_investigator->sourceDir().isEmpty()) ? Stylehelper::LineEditDefaultStylesheet() :
Stylehelper::LineEditIncorrectStylesheet());
ui->watchDirLE->setEnabled(!*m_isUiLocked);
ui->tempDirButton->setEnabled(!*m_isUiLocked);
ui->tempDirLE->setText(m_investigator->processDir());
ui->tempDirLE->setStyleSheet((QDir(m_investigator->processDir()).exists()
&& !m_investigator->processDir().isEmpty()) ? Stylehelper::LineEditDefaultStylesheet() :
Stylehelper::LineEditIncorrectStylesheet());
ui->tempDirLE->setEnabled(!*m_isUiLocked);
ui->cleanDirButton->setEnabled(!*m_isUiLocked);
ui->cleanDirLE->setText(m_investigator->cleanDir());
ui->cleanDirLE->setStyleSheet((QDir(m_investigator->cleanDir()).exists()
&& !m_investigator->cleanDir().isEmpty()) ? Stylehelper::LineEditDefaultStylesheet() :
Stylehelper::LineEditIncorrectStylesheet());
ui->cleanDirLE->setEnabled(!*m_isUiLocked);
ui->dangerousDirButton->setEnabled(!*m_isUiLocked);
ui->dangerousDirLE->setText(m_investigator->infectedDir());
ui->dangerousDirLE->setStyleSheet((QDir(m_investigator->infectedDir()).exists()
&& !m_investigator->infectedDir().isEmpty()) ? Stylehelper::LineEditDefaultStylesheet() :
Stylehelper::LineEditIncorrectStylesheet());
ui->dangerousDirLE->setEnabled(!*m_isUiLocked);
// --- AVS PAGE ---
ui->saveXmlReportsLabelCB->setChecked(m_investigator->saveXmlReports());
ui->avsExecFileLE->setEnabled(!*m_isUiLocked && !m_investigator->isInWork());
ui->avsExecFileLE->setText(m_investigator->avsExecFileName());
ui->avsExecFileLE->setStyleSheet(QFile(m_investigator->avsExecFileName()).exists() ?
Stylehelper::LineEditDefaultStylesheet() : Stylehelper::LineEditIncorrectStylesheet());
ui->avsExecFileButton->setEnabled(!*m_isUiLocked && !m_investigator->isInWork());
ui->threadsNumberSB->setEnabled(!*m_isUiLocked && !m_investigator->isInWork());
ui->threadsNumberSB->setValue(m_investigator->tempCurrentWorkersNb());
ui->thresholdFilesNbSB->setEnabled(!*m_isUiLocked);
ui->thresholdFilesNbSB->setValue(m_investigator->thresholdFilesNb());
ui->thresholdFilesSizeSB->setEnabled(!*m_isUiLocked);
ui->thresholdFilesSizeSB->setValue(m_investigator->thresholdFilesSize());
ui->thresholdFilesSizeUnitCB->setEnabled(!*m_isUiLocked);
ui->thresholdFilesSizeUnitCB->setCurrentIndex(SizeConverter::sizeUnitIdx(
m_investigator->thresholdFilesSizeUnit()));
ui->saveXmlReportsLabelCB->setChecked(m_investigator->saveXmlReports());
ui->saveXmlReportsLabelCB->setEnabled(!*m_isUiLocked);
ui->externalHandlerFileCB->setEnabled(!*m_isUiLocked);
ui->externalHandlerFileCB->setChecked(m_investigator->useExternalHandler());
ui->externalHandlerFileLE->setEnabled(!*m_isUiLocked);
ui->externalHandlerFileLE->setText(m_investigator->externalHandlerPath());
ui->externalHandlerFileButton->setEnabled(!*m_isUiLocked);
// --- EVENTS PAGE ---
ui->syslogAddressLE->setEnabled(!*m_isUiLocked);
ui->syslogAddressLE->setText(m_investigator->syslogAddress());
ui->syslogAddressLE->setStyleSheet(!QHostAddress(m_investigator->syslogAddress()).isNull() ?
Stylehelper::LineEditDefaultStylesheet() : Stylehelper::LineEditIncorrectStylesheet());
ui->restartHttpServerButton->setEnabled(!*m_isUiLocked);
}
}
void SettingsWindow::on_externalHandlerFileButton_clicked() {
QString filePath = QFileDialog::getOpenFileName(this,
QString("Выбор внешнего обработчика"),
m_investigator->externalHandlerPath(), tr("*.*"));
m_investigator->setExternalHandlerPath(filePath);
updateUi();
}
void SettingsWindow::on_externalHandlerFileCB_clicked(bool checked) {
m_investigator->setUseExternalHandler(checked);
updateUi();
}
// --- SYSLOG ---
void SettingsWindow::on_syslogAddressLE_editingFinished() {
m_investigator->setSyslogAddress(ui->syslogAddressLE->text());
updateUi();
}
void SettingsWindow::on_settingsTabWidget_currentChanged(int index) {
m_currentOpenTab = index;
}
// перезапуск http сервера
void SettingsWindow::on_restartHttpServerButton_clicked() {
emit restartHttpServer();
}
// флаг сохранения xml отчетов с сопроводиловкой
void SettingsWindow::on_saveXmlReportsLabelCB_clicked(bool checked) {
m_investigator->setSaveXmlReports(checked);
}