From cbb2b8660f0ba5f1e56841d78292bf64f7931de4 Mon Sep 17 00:00:00 2001
From: love-code-yeyixiao <188240888@qq.com>
Date: Fri, 1 Mar 2024 19:19:45 +0800
Subject: [PATCH] Fixed known uncommitted issues and added an optional feature
to check the sandbox for automatic deletion when Sandman starts.
---
SandboxiePlus/SandMan/Forms/SettingsWindow.ui | 266 +++++++++---------
SandboxiePlus/SandMan/SandMan.cpp | 26 +-
.../SandMan/Windows/SettingsWindow.cpp | 3 +
3 files changed, 167 insertions(+), 128 deletions(-)
diff --git a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui
index c3ccccb5..ccf90fdc 100644
--- a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui
+++ b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui
@@ -65,43 +65,6 @@
General Options
- -
-
-
-
- 75
- true
- true
-
-
-
- SandMan Options
-
-
-
- -
-
-
- UI Language:
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
- -
-
-
- Open urls from this ui sandboxed
-
-
- true
-
-
-
-
@@ -109,48 +72,6 @@
- -
-
-
-
-
-
- Hotkey for terminating all boxed processes:
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
- Hotkey for bringing sandman to the top:
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
- Hotkey for suspending process/folder forcing:
-
-
-
- -
-
-
-
-
-
-
@@ -165,13 +86,90 @@
- -
-
+
-
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 84
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 195
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
-
+
+
+ Hotkey for terminating all boxed processes:
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+ 75
+ true
+ true
+
+
- Run box operations asynchronously whenever possible (like content deletion)
+ SandMan Options
+ -
+
+
-
+
+
+ Hotkey for bringing sandman to the top:
+
+
+
+ -
+
+
+
+
-
@@ -186,59 +184,75 @@
- -
-
+
-
+
- Show file recovery window when emptying sandboxes
+ Open urls from this ui sandboxed
+
+
+ true
+ -
+
+
+ UI Language:
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
+
-
+
+
+ Hotkey for suspending process/folder forcing:
+
+
+
+ -
+
+
+
+
-
-
+
+
+ 0
+
+
-
+
+
+ Show file recovery window when emptying sandboxes
+
+
+
+ -
+
+
+ Check sandboxes' auto-delete status when Sandman starts
+
+
+
+ -
+
+
+ Show the Recovery Window as Always on Top
+
+
+
+
+
+ -
+
- Show the Recovery Window as Always on Top
+ Run box operations asynchronously whenever possible (like content deletion)
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 84
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 195
- 20
-
-
-
-
diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp
index fb00d00c..c481c7a0 100644
--- a/SandboxiePlus/SandMan/SandMan.cpp
+++ b/SandboxiePlus/SandMan/SandMan.cpp
@@ -281,6 +281,28 @@ CSandMan::CSandMan(QWidget *parent)
connect(theAPI, SIGNAL(ConfigReloaded()), this, SLOT(OnIniReloaded()));
connect(qApp, &QGuiApplication::commitDataRequest, this, &CSandMan::commitData);
+ if (theConf->GetBool("Options/CheckAutoDelete", false)) {
+ for (auto& box : theAPI->GetAllBoxes().toStdMap()) {
+ CSandBoxPtr pBox = box.second;
+ if (box.second->GetActiveProcessCount() == 0) {
+ if (!pBox->GetBool("NeverDelete", false))
+ {
+ if (pBox->GetBool("AutoDelete", false))
+ {
+ bool DeleteSnapshots = false;
+ // if this box auto deletes first show the recovry dialog with the option to abort deletion
+ //if (!theGUI->OpenRecovery(pBox, DeleteSnapshots, true)) // unless no files are found than continue silently
+ // return;
+
+ if (theConf->GetBool("Options/AutoBoxOpsNotify", false))
+ OnLogMessage(tr("Auto deleting content of %1").arg(pBox->GetName()), true);
+
+ DeleteBoxContent(pBox, eAuto, DeleteSnapshots);
+ }
+ }
+ }
+ }
+ }
m_uTimerID = startTimer(1000);
@@ -2676,8 +2698,8 @@ void CSandMan::OnHotKey(size_t id)
case HK_SUSPEND:
{
- for (auto each : theAPI->GetAllBoxes()) {
- each->SetSuspendedAll(TRUE);
+ for (auto each : theAPI->GetAllBoxes().toStdMap()) {
+ each.second->SetSuspendedAll(TRUE);
};
break;
}
diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp
index 50591066..aae1a53b 100644
--- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp
+++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp
@@ -313,6 +313,7 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
connect(ui.chkNotifyRecovery, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkShowRecovery, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
+ connect(ui.chkCheckDelete, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkRecoveryTop, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
//
@@ -1558,6 +1559,8 @@ void CSettingsWindow::SaveSettings()
theConf->SetValue("Options/EnableSuspendKey", ui.chkSuspend->isChecked());
theConf->SetValue("Options/SuspendKeySequence", ui.keySuspend->keySequence().toString());
+ theConf->SetValue("Options/CheckAutoDelete", ui.chkCheckDelete->isChecked());
+
theConf->SetValue("Options/WatchBoxSize", ui.chkMonitorSize->isChecked());
theConf->SetValue("Options/WatchIni", ui.chkWatchConfig->isChecked());