This commit is contained in:
DavidXanatos 2024-11-13 12:46:37 +01:00
parent 04e9c0745c
commit 942f2d3014
3 changed files with 27 additions and 6 deletions

View File

@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- added the ability to hide certificates in editbox in Global Setting (idea by Yeyixiao) - 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
- fixed Sign the .tmp file that gets dropped when installing or updating Sandboxie Plus [#2643](https://github.com/sandboxie-plus/Sandboxie/issues/2643) - fixed Sign the .tmp file that gets dropped when installing or updating Sandboxie Plus [#2643](https://github.com/sandboxie-plus/Sandboxie/issues/2643)

View File

@ -34,6 +34,11 @@ CBoxPicker::CBoxPicker(QString DefaultBox, QWidget* parent)
LoadBoxed("", DefaultBox); 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) void CBoxPicker::SetFilter(const QString& Exp, int iOptions, int Column)
{ {
LoadBoxed(Exp); LoadBoxed(Exp);
@ -101,6 +106,14 @@ QString CBoxPicker::GetBoxName() const
return pItem->data(0, Qt::UserRole).toString(); 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) QTreeWidgetItem* CBoxPicker::GetBoxParent(const QMap<QString, QStringList>& Groups, QMap<QString, QTreeWidgetItem*>& GroupItems, QTreeWidget* treeBoxes, const QString& Name, int Depth)
{ {
if (Depth > 100) if (Depth > 100)
@ -192,6 +205,7 @@ CSelectBoxWindow::CSelectBoxWindow(const QStringList& Commands, const QString& B
connect(ui.buttonBox, SIGNAL(rejected()), SLOT(reject())); connect(ui.buttonBox, SIGNAL(rejected()), SLOT(reject()));
m_pBoxPicker = new CBoxPicker(BoxName); m_pBoxPicker = new CBoxPicker(BoxName);
m_pBoxPicker->EnableMultiSel(true);
connect(m_pBoxPicker, SIGNAL(BoxDblClick()), this, SLOT(OnRun())); connect(m_pBoxPicker, SIGNAL(BoxDblClick()), this, SLOT(OnRun()));
ui.treeBoxes->parentWidget()->layout()->replaceWidget(ui.treeBoxes, m_pBoxPicker); ui.treeBoxes->parentWidget()->layout()->replaceWidget(ui.treeBoxes, m_pBoxPicker);
delete ui.treeBoxes; delete ui.treeBoxes;
@ -225,7 +239,7 @@ void CSelectBoxWindow::OnBoxType()
void CSelectBoxWindow::OnRun() void CSelectBoxWindow::OnRun()
{ {
QString BoxName; QStringList BoxNames;
int Flags = CSbieAPI::eStartDefault; int Flags = CSbieAPI::eStartDefault;
if (ui.chkAdmin->isChecked()) if (ui.chkAdmin->isChecked())
Flags |= CSbieAPI::eStartElevated; Flags |= CSbieAPI::eStartElevated;
@ -236,25 +250,28 @@ void CSelectBoxWindow::OnRun()
} }
if (ui.radBoxedNew->isChecked()) if (ui.radBoxedNew->isChecked())
{ {
BoxName = theGUI->GetBoxView()->AddNewBox(true); QString BoxName = theGUI->GetBoxView()->AddNewBox(true);
if (BoxName.isEmpty()) { if (BoxName.isEmpty()) {
close(); close();
return; return;
} }
BoxNames.append(BoxName);
} }
else if (!ui.radUnBoxed->isChecked() || ui.chkFCP->isChecked()) else if (!ui.radUnBoxed->isChecked() || ui.chkFCP->isChecked())
{ {
if (ui.chkFCP->isChecked()) if (ui.chkFCP->isChecked())
Flags |= CSbieAPI::eStartFCP; Flags |= CSbieAPI::eStartFCP;
BoxName = m_pBoxPicker->GetBoxName(); BoxNames = m_pBoxPicker->GetBoxNames();
if (BoxName.isEmpty()) { if (BoxNames.isEmpty()) {
QMessageBox("Sandboxie-Plus", tr("Please select a sandbox."), QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this).exec(); QMessageBox("Sandboxie-Plus", tr("Please select a sandbox."), QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this).exec();
return; return;
} }
} }
foreach(const QString& Command, m_Commands) foreach(const QString & BoxName, BoxNames) {
theGUI->RunStart(BoxName, Command, (CSbieAPI::EStartFlags)Flags, m_WrkDir); foreach(const QString & Command, m_Commands)
theGUI->RunStart(BoxName, Command, (CSbieAPI::EStartFlags)Flags, m_WrkDir);
}
setResult(1); setResult(1);
close(); close();

View File

@ -15,9 +15,12 @@ class CBoxPicker : public QWidget
public: public:
CBoxPicker(QString DefaultBox = "", QWidget *parent = Q_NULLPTR); CBoxPicker(QString DefaultBox = "", QWidget *parent = Q_NULLPTR);
void EnableMultiSel(bool bEnable);
void LoadBoxed(const QString& Filter = QString(), const QString& SelectBox = QString()); void LoadBoxed(const QString& Filter = QString(), const QString& SelectBox = QString());
QString GetBoxName() const; 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 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); static double GetBoxOrder(const QMap<QString, QStringList>& Groups, const QString& Name, double value = 0.0, int Depth = 0);