This commit is contained in:
DavidXanatos 2024-09-15 14:26:58 +02:00
parent 0750445028
commit 28fea2e0bc
14 changed files with 267 additions and 36 deletions

View File

@ -141,6 +141,12 @@ void CSandBox::SetBoxPaths(const QString& FilePath, const QString& RegPath, cons
m_IpcPath = IpcPath; m_IpcPath = IpcPath;
} }
void CSandBox::SetFileRoot(const QString& FilePath)
{
SetText("FileRootPath", FilePath);
m_pAPI->UpdateBoxPaths(this);
}
SB_STATUS CSandBox::RunStart(const QString& Command, bool Elevated) SB_STATUS CSandBox::RunStart(const QString& Command, bool Elevated)
{ {
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -43,6 +43,7 @@ public:
virtual void UpdateDetails(); virtual void UpdateDetails();
virtual void SetBoxPaths(const QString& FilePath, const QString& RegPath, const QString& IpcPath); virtual void SetBoxPaths(const QString& FilePath, const QString& RegPath, const QString& IpcPath);
virtual void SetFileRoot(const QString& FilePath);
virtual QString GetFileRoot() const { return m_FilePath; } virtual QString GetFileRoot() const { return m_FilePath; }
virtual QString GetRegRoot() const { return m_RegPath; } virtual QString GetRegRoot() const { return m_RegPath; }
virtual QString GetIpcRoot() const { return m_IpcPath; } virtual QString GetIpcRoot() const { return m_IpcPath; }

View File

@ -16,9 +16,6 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QComboBox" name="cmbCompression"/>
</item>
<item row="3" column="0"> <item row="3" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@ -32,14 +29,10 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="0"> <item row="1" column="2">
<widget class="QLabel" name="label"> <widget class="QComboBox" name="cmbCompression"/>
<property name="text">
<string>Compression</string>
</property>
</widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="2">
<widget class="QCheckBox" name="chkEncrypt"> <widget class="QCheckBox" name="chkEncrypt">
<property name="toolTip"> <property name="toolTip">
<string>When selected you will be prompted for a password after clicking OK</string> <string>When selected you will be prompted for a password after clicking OK</string>
@ -49,7 +42,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="2">
<widget class="QCheckBox" name="chkSolid"> <widget class="QCheckBox" name="chkSolid">
<property name="toolTip"> <property name="toolTip">
<string>Solid archiving improves compression ratios by treating multiple files as a single continuous data block. Ideal for a large number of small files, it makes the archive more compact but may increase the time required for extracting individual files.</string> <string>Solid archiving improves compression ratios by treating multiple files as a single continuous data block. Ideal for a large number of small files, it makes the archive more compact but may increase the time required for extracting individual files.</string>
@ -59,10 +52,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2"> <item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Compression</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmbFormat">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Export Sandbox to a 7z or Zip archive, Choose Your Compression Rate and Customize Additional Compression Settings.</string> <string>Export Sandbox to a archive, Choose Your Compression Rate and Customize Additional Compression Settings.</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtractDialog</class>
<widget class="QDialog" name="ExtractDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>207</height>
</rect>
</property>
<property name="windowTitle">
<string>Extract Files</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="txtName"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Export Sandbox from an archive</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Import Sandbox Name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Box Root Folder</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="btnRoot">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cmbRoot">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -38,6 +38,7 @@ HEADERS += ./stdafx.h \
./Wizards/BoxAssistant.h \ ./Wizards/BoxAssistant.h \
./Windows/BoxImageWindow.h \ ./Windows/BoxImageWindow.h \
./Windows/CompressDialog.h \ ./Windows/CompressDialog.h \
./Windows/ExtractDialog.h \
./Engine/BoxEngine.h \ ./Engine/BoxEngine.h \
./Engine/ScriptManager.h \ ./Engine/ScriptManager.h \
./Engine/BoxObject.h \ ./Engine/BoxObject.h \
@ -88,6 +89,7 @@ SOURCES += ./main.cpp \
./Wizards/BoxAssistant.cpp \ ./Wizards/BoxAssistant.cpp \
./Windows/BoxImageWindow.cpp \ ./Windows/BoxImageWindow.cpp \
./Windows/CompressDialog.cpp \ ./Windows/CompressDialog.cpp \
./Windows/ExtractDialog.cpp \
./Engine/BoxEngine.cpp \ ./Engine/BoxEngine.cpp \
./Engine/ScriptManager.cpp \ ./Engine/ScriptManager.cpp \
./Engine/BoxObject.cpp \ ./Engine/BoxObject.cpp \
@ -105,6 +107,7 @@ FORMS += ./Forms/SelectBoxWindow.ui \
./Forms/SnapshotsWindow.ui \ ./Forms/SnapshotsWindow.ui \
./Forms/BoxImageWindow.ui \ ./Forms/BoxImageWindow.ui \
./Forms/CompressDialog.ui \ ./Forms/CompressDialog.ui \
./Forms/ExtractDialog.ui \
./Forms/TestProxyDialog.ui ./Forms/TestProxyDialog.ui
TRANSLATIONS += sandman_de.ts \ TRANSLATIONS += sandman_de.ts \

View File

@ -348,6 +348,7 @@
<ClCompile Include="Views\StackView.cpp" /> <ClCompile Include="Views\StackView.cpp" />
<ClCompile Include="Views\TraceView.cpp" /> <ClCompile Include="Views\TraceView.cpp" />
<ClCompile Include="Windows\CompressDialog.cpp" /> <ClCompile Include="Windows\CompressDialog.cpp" />
<ClCompile Include="Windows\ExtractDialog.cpp" />
<ClCompile Include="Windows\OptionsAccess.cpp"> <ClCompile Include="Windows\OptionsAccess.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@ -443,6 +444,7 @@
<ClCompile Include="Windows\TestProxyDialog.cpp" /> <ClCompile Include="Windows\TestProxyDialog.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="Windows\ExtractDialog.h" />
<QtMoc Include="Windows\TestProxyDialog.h" /> <QtMoc Include="Windows\TestProxyDialog.h" />
<QtMoc Include="Windows\CompressDialog.h" /> <QtMoc Include="Windows\CompressDialog.h" />
<QtMoc Include="Wizards\BoxAssistant.h" /> <QtMoc Include="Wizards\BoxAssistant.h" />
@ -504,6 +506,7 @@
<ItemGroup> <ItemGroup>
<QtUic Include="Forms\BoxImageWindow.ui" /> <QtUic Include="Forms\BoxImageWindow.ui" />
<QtUic Include="Forms\CompressDialog.ui" /> <QtUic Include="Forms\CompressDialog.ui" />
<QtUic Include="Forms\ExtractDialog.ui" />
<QtUic Include="Forms\OptionsWindow.ui" /> <QtUic Include="Forms\OptionsWindow.ui" />
<QtUic Include="Forms\PopUpWindow.ui" /> <QtUic Include="Forms\PopUpWindow.ui" />
<QtUic Include="Forms\RecoveryWindow.ui" /> <QtUic Include="Forms\RecoveryWindow.ui" />

View File

@ -234,6 +234,9 @@
<ClCompile Include="Windows\TestProxyDialog.cpp"> <ClCompile Include="Windows\TestProxyDialog.cpp">
<Filter>Windows</Filter> <Filter>Windows</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Windows\ExtractDialog.cpp">
<Filter>Windows</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="stdafx.h"> <ClInclude Include="stdafx.h">
@ -385,6 +388,9 @@
<QtMoc Include="Windows\TestProxyDialog.h"> <QtMoc Include="Windows\TestProxyDialog.h">
<Filter>Windows</Filter> <Filter>Windows</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="Windows\ExtractDialog.h">
<Filter>Windows</Filter>
</QtMoc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtRcc Include="Resources\SandMan.qrc"> <QtRcc Include="Resources\SandMan.qrc">
@ -428,7 +434,10 @@
<Filter>Form Files</Filter> <Filter>Form Files</Filter>
</QtUic> </QtUic>
<QtUic Include="Forms\TestProxyDialog.ui"> <QtUic Include="Forms\TestProxyDialog.ui">
<Filter>Form Files</Filter> <Filter>Form Files</Filter>
</QtUic>
<QtUic Include="Forms\ExtractDialog.ui">
<Filter>Form Files</Filter>
</QtUic> </QtUic>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -332,15 +332,13 @@ void CSandBoxPlus::ImportBoxAsync(const CSbieProgressPtr& pProgress, const QStri
pProgress->Finish(Status); pProgress->Finish(Status);
} }
SB_PROGRESS CSandBoxPlus::ImportBox(const QString& FileName, const QString& RootFolder, const QString& Password) SB_PROGRESS CSandBoxPlus::ImportBox(const QString& FileName, const QString& Password)
{ {
if (!CArchive::IsInit()) if (!CArchive::IsInit())
return SB_ERR((ESbieMsgCodes)SBX_7zNotReady); return SB_ERR((ESbieMsgCodes)SBX_7zNotReady);
CSbieProgressPtr pProgress = CSbieProgressPtr(new CSbieProgress()); CSbieProgressPtr pProgress = CSbieProgressPtr(new CSbieProgress());
QString filepath = RootFolder.isEmpty()?m_FilePath:RootFolder; QtConcurrent::run(CSandBoxPlus::ImportBoxAsync, pProgress, FileName, m_FilePath, m_Name, Password);
QtConcurrent::run(CSandBoxPlus::ImportBoxAsync, pProgress, FileName, filepath, m_Name, Password);
return SB_PROGRESS(OP_ASYNC, pProgress); return SB_PROGRESS(OP_ASYNC, pProgress);
} }

View File

@ -75,7 +75,7 @@ public:
virtual QString GetDisplayName() const; virtual QString GetDisplayName() const;
SB_PROGRESS ExportBox(const QString& FileName, const QString& Password = "", int Level = 5, bool Solid = false); SB_PROGRESS ExportBox(const QString& FileName, const QString& Password = "", int Level = 5, bool Solid = false);
SB_PROGRESS ImportBox(const QString& FileName, const QString& RootFolder,const QString& Password); SB_PROGRESS ImportBox(const QString& FileName, const QString& Password);
virtual void UpdateDetails(); virtual void UpdateDetails();

View File

@ -17,6 +17,7 @@
#include "../MiscHelpers/Archive/Archive.h" #include "../MiscHelpers/Archive/Archive.h"
#include "../Windows/SettingsWindow.h" #include "../Windows/SettingsWindow.h"
#include "../Windows/CompressDialog.h" #include "../Windows/CompressDialog.h"
#include "../Windows/ExtractDialog.h"
#include "qt_windows.h" #include "qt_windows.h"
#include "qwindowdefs_win.h" #include "qwindowdefs_win.h"
@ -1072,26 +1073,23 @@ QString CSbieView::ImportSandbox()
StrPair NameEx = Split2(PathName.second, ".", true); StrPair NameEx = Split2(PathName.second, ".", true);
QString Name = NameEx.first; QString Name = NameEx.first;
CSandBoxPtr pBox; CExtractDialog optWnd(Name, this);
for (;;) { if (!theGUI->SafeExec(&optWnd) == 1)
pBox = theAPI->GetBoxByName(Name); return "";
if (pBox.isNull()) Name = optWnd.GetName();
break; QString BoxRoot = optWnd.GetRoot();
Name = QInputDialog::getText(this, "Sandboxie-Plus", tr("This name is already in use, please select an alternative box name"), QLineEdit::Normal, Name);
if (Name.isEmpty())
return "";
}
CSandBoxPtr pBox;
SB_PROGRESS Status = theAPI->CreateBox(Name); SB_PROGRESS Status = theAPI->CreateBox(Name);
if (!Status.IsError()) { if (!Status.IsError()) {
pBox = theAPI->GetBoxByName(Name); pBox = theAPI->GetBoxByName(Name);
if (pBox) { if (pBox) {
QString rootname = "";
if (QMessageBox::question(this, tr("Importing Sandbox"), tr("Do you want to select custom root folder?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
rootname=QFileDialog::getExistingDirectory(this);
}
auto pBoxEx = pBox.objectCast<CSandBoxPlus>(); auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
if (!BoxRoot.isEmpty())
pBox->SetFileRoot(BoxRoot);
if (!Password.isEmpty()) { if (!Password.isEmpty()) {
Status = pBoxEx->ImBoxCreate(ImageSize / 1024, Password); Status = pBoxEx->ImBoxCreate(ImageSize / 1024, Password);
if (!Status.IsError()) if (!Status.IsError())
@ -1099,11 +1097,13 @@ QString CSbieView::ImportSandbox()
} }
if (!Status.IsError()) if (!Status.IsError())
Status = pBoxEx->ImportBox(Path,rootname,Password); Status = pBoxEx->ImportBox(Path, Password);
if(!rootname.isEmpty())
pBox->SetText("FileRootPath", rootname); // always overwirte restored FileRootPath
pBox->SetText("FileRootPath", BoxRoot);
} }
} }
if (Status.GetStatus() == OP_ASYNC) { if (Status.GetStatus() == OP_ASYNC) {
Status = theGUI->AddAsyncOp(Status.GetValue(), true, tr("Importing: %1").arg(Path)); Status = theGUI->AddAsyncOp(Status.GetValue(), true, tr("Importing: %1").arg(Path));
if (Status.IsError()) { if (Status.IsError()) {
@ -1405,7 +1405,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
Password = pwWnd.GetPassword(); Password = pwWnd.GetPassword();
} }
QString Path = QFileDialog::getSaveFileName(this, tr("Select file name"), SandBoxes.first()->GetName() + ".7z", tr("7-zip Archive (*.7z);;Zip Archive (*.zip)")); QString Path = QFileDialog::getSaveFileName(this, tr("Select file name"), SandBoxes.first()->GetName() + optWnd.GetFormat(), tr("7-Zip Archive (*.7z);;Zip Archive (*.zip)"));
if (Path.isEmpty()) if (Path.isEmpty())
return; return;

View File

@ -22,6 +22,11 @@ CCompressDialog::CCompressDialog(QWidget *parent)
ui.setupUi(this); ui.setupUi(this);
this->setWindowTitle(tr("Sandboxie-Plus - Sandbox Export")); this->setWindowTitle(tr("Sandboxie-Plus - Sandbox Export"));
connect(ui.cmbFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFormatChanged(int)));
ui.cmbFormat->addItem(tr("7-Zip"), ".7z");
ui.cmbFormat->addItem(tr("Zip"), ".zip");
ui.cmbCompression->addItem(tr("Store"), 0); ui.cmbCompression->addItem(tr("Store"), 0);
ui.cmbCompression->addItem(tr("Fastest"), 1); ui.cmbCompression->addItem(tr("Fastest"), 1);
ui.cmbCompression->addItem(tr("Fast"), 3); ui.cmbCompression->addItem(tr("Fast"), 3);
@ -41,6 +46,17 @@ CCompressDialog::~CCompressDialog()
//theConf->SetBlob("CompressDialog/Window_Geometry", saveGeometry()); //theConf->SetBlob("CompressDialog/Window_Geometry", saveGeometry());
} }
void CCompressDialog::OnFormatChanged(int index)
{
ui.chkSolid->setEnabled(index == 0);
ui.chkEncrypt->setEnabled(index == 0);
}
QString CCompressDialog::GetFormat()
{
return ui.cmbFormat->currentData().toString();
}
int CCompressDialog::GetLevel() int CCompressDialog::GetLevel()
{ {
return ui.cmbCompression->currentData().toInt(); return ui.cmbCompression->currentData().toInt();

View File

@ -12,12 +12,16 @@ public:
CCompressDialog(QWidget *parent = Q_NULLPTR); CCompressDialog(QWidget *parent = Q_NULLPTR);
~CCompressDialog(); ~CCompressDialog();
QString GetFormat();
int GetLevel(); int GetLevel();
bool MakeSolid(); bool MakeSolid();
void SetMustEncrypt(); void SetMustEncrypt();
bool UseEncryption(); bool UseEncryption();
private slots:
void OnFormatChanged(int index);
private: private:
Ui::CompressDialog ui; Ui::CompressDialog ui;
}; };

View File

@ -0,0 +1,72 @@
#include "stdafx.h"
#include "ExtractDialog.h"
#include "SandMan.h"
#include "../MiscHelpers/Common/Settings.h"
#include "../MiscHelpers/Common/Common.h"
CExtractDialog::CExtractDialog(const QString& Name, QWidget *parent)
: QDialog(parent)
{
Qt::WindowFlags flags = windowFlags();
flags |= Qt::CustomizeWindowHint;
//flags &= ~Qt::WindowContextHelpButtonHint;
//flags &= ~Qt::WindowSystemMenuHint;
//flags &= ~Qt::WindowMinMaxButtonsHint;
//flags |= Qt::WindowMinimizeButtonHint;
//flags &= ~Qt::WindowCloseButtonHint;
flags &= ~Qt::WindowContextHelpButtonHint;
//flags &= ~Qt::WindowSystemMenuHint;
setWindowFlags(flags);
ui.setupUi(this);
this->setWindowTitle(tr("Sandboxie-Plus - Sandbox Import"));
ui.txtName->setText(Name);
QString Location = theAPI->GetGlobalSettings()->GetText("FileRootPath", "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%");
ui.cmbRoot->addItem(Location/*.replace("%SANDBOX%", field("boxName").toString())*/);
QStringList StdLocations = QStringList()
<< "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%"
<< "\\??\\%SystemDrive%\\Sandbox\\%SANDBOX%"
<< "\\??\\%SystemDrive%\\Users\\%USER%\\Sandbox\\%SANDBOX%";
foreach(auto StdLocation, StdLocations) {
if (StdLocation != Location)
ui.cmbRoot->addItem(StdLocation);
}
connect(ui.btnRoot, &QPushButton::clicked, [&]() {
QString FilePath = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
if (!FilePath.isEmpty())
ui.cmbRoot->setCurrentText(FilePath.replace("/", "\\"));
});
connect(ui.buttonBox, SIGNAL(accepted()), SLOT(OnAccept()));
connect(ui.buttonBox, SIGNAL(rejected()), SLOT(reject()));
//restoreGeometry(theConf->GetBlob("ExtractDialog/Window_Geometry"));
}
CExtractDialog::~CExtractDialog()
{
//theConf->SetBlob("ExtractDialog/Window_Geometry", saveGeometry());
}
void CExtractDialog::OnAccept()
{
CSandBoxPtr pBox = theAPI->GetBoxByName(ui.txtName->text());
if (!pBox.isNull()) {
QMessageBox::warning(this, "Sandboxie-Plus", tr("This name is already in use, please select an alternative box name"));
return;
}
accept();
}
QString CExtractDialog::GetRoot() const
{
QString Location = theAPI->GetGlobalSettings()->GetText("FileRootPath", "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%");
if (Location == ui.cmbRoot->currentText())
return "";
return ui.cmbRoot->currentText();
}

View File

@ -0,0 +1,23 @@
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_ExtractDialog.h"
#include "SbiePlusAPI.h"
class CExtractDialog : public QDialog
{
Q_OBJECT
public:
CExtractDialog(const QString& Name, QWidget *parent = Q_NULLPTR);
~CExtractDialog();
QString GetName() const { return ui.txtName->text(); }
QString GetRoot() const;
private slots:
void OnAccept();
private:
Ui::ExtractDialog ui;
};