1.3.1
This commit is contained in:
parent
7240fc1945
commit
ae95d24a96
|
@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||
- added missing system calls to the hardened box type [88bc06a](https://github.com/sandboxie-plus/Sandboxie/commit/88bc06a0c7368a81c80a77d7a89ddc73455abb25) [b775264](https://github.com/sandboxie-plus/Sandboxie/commit/b775264a4824e49b554f1b776c377170e5f90797) [04b2377](https://github.com/sandboxie-plus/Sandboxie/commit/04b23770f53597c12eda9122c774ed5165129147) (thanks Mr.X)
|
||||
- added search box to the Plus UI Settings and box option dialogs [#2134](https://github.com/sandboxie-plus/Sandboxie/issues/2134)
|
||||
- added Korean translation to the Plus UI [#2133](https://github.com/sandboxie-plus/Sandboxie/pull/2133) (thanks VenusGirl)
|
||||
- added grouping to sandman tray menu [#2148](https://github.com/sandboxie-plus/Sandboxie/issues/2148)
|
||||
|
||||
### Changed
|
||||
- improved info label
|
||||
|
|
|
@ -189,23 +189,99 @@ void CSandMan::OnShowHide()
|
|||
show();
|
||||
}
|
||||
|
||||
void CSandMan::CreateBoxMenu(QMenu* pMenu, int iOffset, int iSysTrayFilter)
|
||||
QMenu* CSandMan__GetBoxParent(const QMap<QString, QStringList>& Groups, QMap<QString, QMenu*>& GroupItems, const QIcon& Icon, int iNoIcons, QMenu* pMenu, QAction* pPos, const QString& Name, int Depth = 0)
|
||||
{
|
||||
QMap<QString, CSandBoxPtr> Boxes = theAPI->GetAllBoxes();
|
||||
if (Depth > 100)
|
||||
return NULL;
|
||||
for (auto I = Groups.constBegin(); I != Groups.constEnd(); ++I) {
|
||||
if (I->contains(Name)) {
|
||||
if (I.key().isEmpty())
|
||||
return NULL; // global group
|
||||
QMenu*& pParent = GroupItems[I.key()];
|
||||
if (!pParent) {
|
||||
pParent = new QMenu(I.key());
|
||||
if(!iNoIcons) pParent->setIcon(Icon);
|
||||
QAction* pMenuAction = NULL;
|
||||
if (QMenu* pParent2 = CSandMan__GetBoxParent(Groups, GroupItems, Icon, iNoIcons, pMenu, pPos, I.key(), ++Depth))
|
||||
pMenuAction = pParent2->addMenu(pParent);
|
||||
else
|
||||
pMenuAction = pMenu->insertMenu(pPos, pParent);
|
||||
pMenuAction->setData("group:" + I.key());
|
||||
QFont fnt = pMenuAction->font();
|
||||
fnt.setBold(true);
|
||||
pMenuAction->setFont(fnt);
|
||||
}
|
||||
return pParent;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double CSandMan__GetBoxOrder(const QMap<QString, QStringList>& Groups, const QString& Name, double value = 0.0, int Depth = 0)
|
||||
{
|
||||
if (Depth > 100)
|
||||
return 1000000000;
|
||||
for (auto I = Groups.constBegin(); I != Groups.constEnd(); ++I) {
|
||||
int Pos = I->indexOf(Name);
|
||||
if (Pos != -1) {
|
||||
value = double(Pos) + value / 10.0;
|
||||
if (I.key().isEmpty())
|
||||
return value;
|
||||
return CSandMan__GetBoxOrder(Groups, I.key(), value, ++Depth);
|
||||
}
|
||||
}
|
||||
return 1000000000;
|
||||
}
|
||||
|
||||
QAction* CSandMan__MakeBoxEntry(QMenu* pMenu, CSandBoxPlus* pBoxEx, QFileIconProvider& IconProvider, int iNoIcons, bool ColorIcons)
|
||||
{
|
||||
static QMenu* pEmptyMenu = new QMenu();
|
||||
|
||||
while (!pMenu->actions().at(iOffset)->data().toString().isEmpty())
|
||||
pMenu->removeAction(pMenu->actions().at(iOffset));
|
||||
QAction* pBoxAction = new QAction(pBoxEx->GetName().replace("_", " "));
|
||||
if (!iNoIcons) {
|
||||
QIcon Icon;
|
||||
if (ColorIcons)
|
||||
Icon = theGUI->GetColorIcon(pBoxEx->GetColor(), pBoxEx->GetActiveProcessCount());
|
||||
else
|
||||
Icon = theGUI->GetBoxIcon(pBoxEx->GetType(), pBoxEx->GetActiveProcessCount() != 0);
|
||||
pBoxAction->setIcon(Icon);
|
||||
}
|
||||
pBoxAction->setData("box:" + pBoxEx->GetName());
|
||||
pBoxAction->setMenu(pEmptyMenu);
|
||||
//pBoxAction->setIcon
|
||||
//connect(pBoxAction, SIGNAL(triggered()), this, SLOT(OnBoxMenu()));
|
||||
return pBoxAction;
|
||||
}
|
||||
|
||||
void CSandMan::CreateBoxMenu(QMenu* pMenu, int iOffset, int iSysTrayFilter)
|
||||
{
|
||||
int iNoIcons = theConf->GetInt("Options/NoIcons", 2);
|
||||
if (iNoIcons == 2)
|
||||
iNoIcons = theConf->GetInt("Options/ViewMode", 1) == 2 ? 1 : 0;
|
||||
QFileIconProvider IconProvider;
|
||||
bool ColorIcons = theConf->GetBool("Options/ColorBoxIcons", false);
|
||||
|
||||
while (!pMenu->actions().at(iOffset)->data().toString().isEmpty())
|
||||
pMenu->removeAction(pMenu->actions().at(iOffset));
|
||||
|
||||
QAction* pPos = pMenu->actions().at(iOffset);
|
||||
foreach(const CSandBoxPtr & pBox, Boxes)
|
||||
|
||||
bool bPlus = (theAPI->GetFeatureFlags() & CSbieAPI::eSbieFeatureCert) != 0;
|
||||
QIcon Icon = QIcon(bPlus ? ":/Boxes/Group2" : ":/Boxes/Group"); // theGUI->GetBoxIcon(CSandBoxPlus::eDefault, false);
|
||||
|
||||
QList<CSandBoxPtr> Boxes = theAPI->GetAllBoxes().values(); // map is sorted by key (box name)
|
||||
QMap<QString, QStringList> Groups = theGUI->GetBoxView()->GetGroups();
|
||||
|
||||
if (theConf->GetBool("MainWindow/BoxTree_UseOrder", false)) {
|
||||
QMultiMap<double, CSandBoxPtr> Boxes2;
|
||||
foreach(const CSandBoxPtr &pBox, Boxes) {
|
||||
Boxes2.insertMulti(CSandMan__GetBoxOrder(Groups, pBox->GetName()), pBox);
|
||||
}
|
||||
Boxes = Boxes2.values();
|
||||
}
|
||||
|
||||
QMap<QString, QMenu*> GroupItems;
|
||||
foreach(const CSandBoxPtr &pBox, Boxes)
|
||||
{
|
||||
if (!pBox->IsEnabled())
|
||||
continue;
|
||||
|
@ -221,19 +297,12 @@ void CSandMan::CreateBoxMenu(QMenu* pMenu, int iOffset, int iSysTrayFilter)
|
|||
continue;
|
||||
}
|
||||
|
||||
QAction* pBoxAction = new QAction(pBox->GetName().replace("_", " "));
|
||||
if (!iNoIcons) {
|
||||
QIcon Icon;
|
||||
if (ColorIcons)
|
||||
Icon = theGUI->GetColorIcon(pBoxEx->GetColor(), pBox->GetActiveProcessCount());
|
||||
QMenu* pSubMenu = CSandMan__GetBoxParent(Groups, GroupItems, Icon, iNoIcons, pMenu, pPos, pBox->GetName());
|
||||
|
||||
QAction* pBoxAction = CSandMan__MakeBoxEntry(pMenu, pBoxEx, IconProvider, iNoIcons, ColorIcons);
|
||||
if (pSubMenu)
|
||||
pSubMenu->addAction(pBoxAction);
|
||||
else
|
||||
Icon = theGUI->GetBoxIcon(pBoxEx->GetType(), pBox->GetActiveProcessCount() != 0);
|
||||
pBoxAction->setIcon(Icon);
|
||||
}
|
||||
pBoxAction->setData("box:" + pBox->GetName());
|
||||
pBoxAction->setMenu(pEmptyMenu);
|
||||
//pBoxAction->setIcon
|
||||
//connect(pBoxAction, SIGNAL(triggered()), this, SLOT(OnBoxMenu()));
|
||||
pMenu->insertAction(pPos, pBoxAction);
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +328,9 @@ void CSandMan::OnBoxMenuHover(QAction* action)
|
|||
}
|
||||
}
|
||||
|
||||
double CSelectBoxWindow__GetBoxOrder(const QMap<QString, QStringList>& Groups, const QString& Name, double value = 0.0, int Depth = 0);
|
||||
QTreeWidgetItem* CSelectBoxWindow__GetBoxParent(const QMap<QString, QStringList>& Groups, QMap<QString, QTreeWidgetItem*>& GroupItems, QTreeWidget* treeBoxes, const QString& Name, int Depth = 0);
|
||||
|
||||
void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
|
||||
{
|
||||
static bool TriggerSet = false;
|
||||
|
@ -273,6 +345,62 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
|
|||
CreateBoxMenu(m_pTrayMenu, m_iTrayPos, iSysTrayFilter);
|
||||
else
|
||||
{
|
||||
QFileIconProvider IconProvider;
|
||||
bool ColorIcons = theConf->GetBool("Options/ColorBoxIcons", false);
|
||||
|
||||
/**/
|
||||
m_pTrayBoxes->clear();
|
||||
|
||||
QList<CSandBoxPtr> Boxes = theAPI->GetAllBoxes().values(); // map is sorted by key (box name)
|
||||
QMap<QString, QStringList> Groups = theGUI->GetBoxView()->GetGroups();
|
||||
|
||||
if (theConf->GetBool("MainWindow/BoxTree_UseOrder", false)) {
|
||||
QMultiMap<double, CSandBoxPtr> Boxes2;
|
||||
foreach(const CSandBoxPtr &pBox, Boxes) {
|
||||
Boxes2.insertMulti(CSelectBoxWindow__GetBoxOrder(Groups, pBox->GetName()), pBox);
|
||||
}
|
||||
Boxes = Boxes2.values();
|
||||
}
|
||||
|
||||
QMap<QString, QTreeWidgetItem*> GroupItems;
|
||||
foreach(const CSandBoxPtr &pBox, Boxes)
|
||||
{
|
||||
if (!pBox->IsEnabled())
|
||||
continue;
|
||||
|
||||
CSandBoxPlus* pBoxEx = qobject_cast<CSandBoxPlus*>(pBox.data());
|
||||
|
||||
if (iSysTrayFilter == 2) { // pinned only
|
||||
if (!pBox->GetBool("PinToTray", false))
|
||||
continue;
|
||||
}
|
||||
else if (iSysTrayFilter == 1) { // active + pinned
|
||||
if (pBoxEx->GetActiveProcessCount() == 0 && !pBox->GetBool("PinToTray", false))
|
||||
continue;
|
||||
}
|
||||
|
||||
QTreeWidgetItem* pParent = CSelectBoxWindow__GetBoxParent(Groups, GroupItems, m_pTrayBoxes, pBox->GetName());
|
||||
|
||||
QTreeWidgetItem* pItem = new QTreeWidgetItem();
|
||||
pItem->setText(0, pBox->GetName().replace("_", " "));
|
||||
pItem->setData(0, Qt::UserRole, pBox->GetName());
|
||||
QIcon Icon;
|
||||
QString Action = pBox->GetText("DblClickAction");
|
||||
if(ColorIcons)
|
||||
Icon = theGUI->GetColorIcon(pBoxEx->GetColor(), pBox->GetActiveProcessCount());
|
||||
else
|
||||
Icon = theGUI->GetBoxIcon(pBoxEx->GetType(), pBox->GetActiveProcessCount() != 0);
|
||||
pItem->setData(0, Qt::DecorationRole, Icon);
|
||||
if (pParent)
|
||||
pParent->addChild(pItem);
|
||||
else
|
||||
m_pTrayBoxes->addTopLevelItem(pItem);
|
||||
}
|
||||
|
||||
m_pTrayBoxes->expandAll();
|
||||
/**/
|
||||
|
||||
/*/
|
||||
QMap<QString, CSandBoxPtr> Boxes = theAPI->GetAllBoxes();
|
||||
|
||||
bool bAdded = false;
|
||||
|
@ -287,9 +415,6 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
|
|||
OldBoxes.insert(Name, pItem);
|
||||
}
|
||||
|
||||
QFileIconProvider IconProvider;
|
||||
bool ColorIcons = theConf->GetBool("Options/ColorBoxIcons", false);
|
||||
|
||||
foreach(const CSandBoxPtr & pBox, Boxes)
|
||||
{
|
||||
if (!pBox->IsEnabled())
|
||||
|
@ -318,7 +443,10 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
|
|||
}
|
||||
|
||||
QIcon Icon;
|
||||
if (ColorIcons)
|
||||
QString Action = pBox->GetText("DblClickAction");
|
||||
if (!Action.isEmpty() && Action.left(1) != "!")
|
||||
Icon = IconProvider.icon(QFileInfo(pBoxEx->GetCommandFile(Action)));
|
||||
else if (ColorIcons)
|
||||
Icon = theGUI->GetColorIcon(pBoxEx->GetColor(), pBox->GetActiveProcessCount());
|
||||
else
|
||||
Icon = theGUI->GetBoxIcon(pBoxEx->GetType(), pBox->GetActiveProcessCount() != 0);
|
||||
|
@ -327,8 +455,9 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
|
|||
|
||||
foreach(QTreeWidgetItem * pItem, OldBoxes)
|
||||
delete pItem;
|
||||
/*/
|
||||
|
||||
if (!OldBoxes.isEmpty() || bAdded)
|
||||
//if (!OldBoxes.isEmpty() || bAdded)
|
||||
{
|
||||
auto palette = m_pTrayBoxes->palette();
|
||||
palette.setColor(QPalette::Base, m_pTrayMenu->palette().color(m_DarkTheme ? QPalette::Base : QPalette::Window));
|
||||
|
|
Loading…
Reference in New Issue