Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Nov 13, 2024
1 parent 04e9c07 commit 942f2d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Added
- added the ability to hide certificates in editbox in Global Setting (idea by Yeyixiao)
- added Opening a program in several sandboxes at once [#4231](https://github.com/sandboxie-plus/Sandboxie/issues/4231)

### Fixed
- fixed Sign the .tmp file that gets dropped when installing or updating Sandboxie Plus [#2643](https://github.com/sandboxie-plus/Sandboxie/issues/2643)
Expand Down
29 changes: 23 additions & 6 deletions SandboxiePlus/SandMan/Windows/SelectBoxWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ CBoxPicker::CBoxPicker(QString DefaultBox, QWidget* parent)
LoadBoxed("", DefaultBox);
}

void CBoxPicker::EnableMultiSel(bool bEnable)
{
m_pTreeBoxes->setSelectionMode(bEnable ? QAbstractItemView::ExtendedSelection : QAbstractItemView::SingleSelection);
}

void CBoxPicker::SetFilter(const QString& Exp, int iOptions, int Column)
{
LoadBoxed(Exp);
Expand Down Expand Up @@ -101,6 +106,14 @@ QString CBoxPicker::GetBoxName() const
return pItem->data(0, Qt::UserRole).toString();
}

QStringList CBoxPicker::GetBoxNames() const
{
QStringList BoxNames;
foreach(auto pItem, m_pTreeBoxes->selectedItems())
BoxNames.append(pItem->data(0, Qt::UserRole).toString());
return BoxNames;
}

QTreeWidgetItem* CBoxPicker::GetBoxParent(const QMap<QString, QStringList>& Groups, QMap<QString, QTreeWidgetItem*>& GroupItems, QTreeWidget* treeBoxes, const QString& Name, int Depth)
{
if (Depth > 100)
Expand Down Expand Up @@ -192,6 +205,7 @@ CSelectBoxWindow::CSelectBoxWindow(const QStringList& Commands, const QString& B
connect(ui.buttonBox, SIGNAL(rejected()), SLOT(reject()));

m_pBoxPicker = new CBoxPicker(BoxName);
m_pBoxPicker->EnableMultiSel(true);
connect(m_pBoxPicker, SIGNAL(BoxDblClick()), this, SLOT(OnRun()));
ui.treeBoxes->parentWidget()->layout()->replaceWidget(ui.treeBoxes, m_pBoxPicker);
delete ui.treeBoxes;
Expand Down Expand Up @@ -225,7 +239,7 @@ void CSelectBoxWindow::OnBoxType()

void CSelectBoxWindow::OnRun()
{
QString BoxName;
QStringList BoxNames;
int Flags = CSbieAPI::eStartDefault;
if (ui.chkAdmin->isChecked())
Flags |= CSbieAPI::eStartElevated;
Expand All @@ -236,25 +250,28 @@ void CSelectBoxWindow::OnRun()
}
if (ui.radBoxedNew->isChecked())
{
BoxName = theGUI->GetBoxView()->AddNewBox(true);
QString BoxName = theGUI->GetBoxView()->AddNewBox(true);
if (BoxName.isEmpty()) {
close();
return;
}
BoxNames.append(BoxName);
}
else if (!ui.radUnBoxed->isChecked() || ui.chkFCP->isChecked())
{
if (ui.chkFCP->isChecked())
Flags |= CSbieAPI::eStartFCP;
BoxName = m_pBoxPicker->GetBoxName();
if (BoxName.isEmpty()) {
BoxNames = m_pBoxPicker->GetBoxNames();
if (BoxNames.isEmpty()) {
QMessageBox("Sandboxie-Plus", tr("Please select a sandbox."), QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this).exec();
return;
}
}

foreach(const QString& Command, m_Commands)
theGUI->RunStart(BoxName, Command, (CSbieAPI::EStartFlags)Flags, m_WrkDir);
foreach(const QString & BoxName, BoxNames) {
foreach(const QString & Command, m_Commands)
theGUI->RunStart(BoxName, Command, (CSbieAPI::EStartFlags)Flags, m_WrkDir);
}

setResult(1);
close();
Expand Down
3 changes: 3 additions & 0 deletions SandboxiePlus/SandMan/Windows/SelectBoxWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class CBoxPicker : public QWidget
public:
CBoxPicker(QString DefaultBox = "", QWidget *parent = Q_NULLPTR);

void EnableMultiSel(bool bEnable);

void LoadBoxed(const QString& Filter = QString(), const QString& SelectBox = QString());

QString GetBoxName() const;
QStringList GetBoxNames() const;

static QTreeWidgetItem* GetBoxParent(const QMap<QString, QStringList>& Groups, QMap<QString, QTreeWidgetItem*>& GroupItems, QTreeWidget* treeBoxes, const QString& Name, int Depth = 0);
static double GetBoxOrder(const QMap<QString, QStringList>& Groups, const QString& Name, double value = 0.0, int Depth = 0);
Expand Down

0 comments on commit 942f2d3

Please sign in to comment.