Merge pull request #4100 from offhub/fix019

improve AddForce
This commit is contained in:
DavidXanatos 2024-07-23 07:55:46 +02:00 committed by GitHub
commit e92ab64b81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 6 deletions

View File

@ -1639,19 +1639,28 @@ void CSandMan::OnMessage(const QString& MsgData)
else if (Message.left(9) == "AddForce:") else if (Message.left(9) == "AddForce:")
{ {
QString response = QInputDialog::getText(g_GUIParent, tr("Which box you want to add in?"), tr("Type the box name which you are going to set:")); QString response = QInputDialog::getText(g_GUIParent, tr("Which box you want to add in?"), tr("Type the box name which you are going to set:"));
if(!response.isEmpty()) if (!response.isEmpty())
{ {
if (theAPI->GetBoxByName(response) != NULL) { if (theAPI->GetBoxByName(response) != NULL) {
if (Message.right(1)=="\\"||!Message.contains(".", Qt::CaseInsensitive)) { QString dirOrFile = Message.mid(9).replace("\"", "").trimmed();
theAPI->GetBoxByName(response)->AppendText("ForceFolder", Message.mid(9).replace("\"","")); QFileInfo fileInfo(dirOrFile);
if (Message.right(1) == "\\" || !Message.contains(".", Qt::CaseInsensitive)) {
theAPI->GetBoxByName(response)->AppendText("ForceFolder", dirOrFile);
} }
else { else {
theAPI->GetBoxByName(response)->AppendText("ForceProcess", Message.mid(9).replace("\"", "").mid(Message.mid(9).replace("\"", "").lastIndexOf("\\")+1)); if (fileInfo.exists() && fileInfo.isDir()) {
theAPI->GetBoxByName(response)->AppendText("ForceFolder", dirOrFile);
}
else if (fileInfo.exists() && fileInfo.isExecutable()) {
theAPI->GetBoxByName(response)->AppendText("ForceProcess", dirOrFile.mid(dirOrFile.lastIndexOf("\\") + 1));
}
else {
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("The value is not an existing directory or executable."), QMessageBox::Ok, 0);
}
} }
} }
else { else {
QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("You typed a wrong box name!Nothing was changed."), QMessageBox::Ok, 0); QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("You typed a wrong box name! Nothing was changed."), QMessageBox::Ok, 0);
} }
} }
else { else {