From cbf1e8db8f0c2bde2404bcb68b8eed7a2e803293 Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Sun, 9 Apr 2023 22:20:44 +0200 Subject: [PATCH] 1.8.5 --- Sandboxie/apps/control/MessageDialog.cpp | 25 +++++++++++++------ .../SandMan/Windows/OptionsWindow.cpp | 19 +++++++++++--- SandboxiePlus/SandMan/Windows/PopUpWindow.cpp | 19 +++++++++++++- SandboxiePlus/SandMan/Windows/PopUpWindow.h | 1 + 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/Sandboxie/apps/control/MessageDialog.cpp b/Sandboxie/apps/control/MessageDialog.cpp index d487bd86..aea4e118 100644 --- a/Sandboxie/apps/control/MessageDialog.cpp +++ b/Sandboxie/apps/control/MessageDialog.cpp @@ -1,6 +1,6 @@ /* * Copyright 2004-2020 Sandboxie Holdings, LLC - * Copyright 2020 David Xanatos, xanasoft.com + * Copyright 2020-2023 David Xanatos, xanasoft.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,12 @@ #include "core/drv/api_defs.h" #include "core/svc/InteractiveWire.h" +#define PATTERN XPATTERN +#define _MY_POOL_H // prevent inclusion of pool.h by pattern.h +typedef void *POOL; +#include "common/list.h" +#include "common/pattern.h" + //--------------------------------------------------------------------------- // Structures and Types @@ -50,8 +56,8 @@ struct MsgEntry { struct HideEntry { ULONG code; - CString detail; - + //CString detail; + PATTERN* pattern; }; @@ -175,8 +181,10 @@ void CMessageDialog::ReloadConf() } int pos = head.Find(L','); - if (pos != -1) - entry->detail = head.Mid(pos + 1); + if (pos != -1) { + //entry->detail = head.Mid(pos + 1); + entry->pattern = Pattern_Create(NULL, head.Mid(pos + 1), TRUE, 0); + } if (entry->code) m_hidden.Add(entry); @@ -222,8 +230,11 @@ BOOL CMessageDialog::IsHiddenMessage( if (entry->code == code) { if (entry->code == MSG_1319) // hide MSG_1319 for all detail return TRUE; - BOOL match = (! entry->detail.GetLength()) || - (entry->detail.CompareNoCase(detail_1) == 0); + //BOOL match = (! entry->detail.GetLength()) || + // (entry->detail.CompareNoCase(detail_1) == 0); + CString Detail_1 = detail_1; + Detail_1.MakeLower(); + BOOL match = Pattern_Match(entry->pattern, Detail_1, Detail_1.GetLength()); if (match) return TRUE; } diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp index d82773ad..74ea86ef 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp @@ -77,8 +77,11 @@ public: }); connect(pBox, qOverload(&QComboBox::currentIndexChanged), [pBox](int index){ - if (index != -1) - pBox->setProperty("value", pBox->itemData(index)); + if (index != -1) { + QString Program = pBox->itemData(index).toString(); + pBox->setProperty("value", Program); + pBox->lineEdit()->setReadOnly(Program.left(1) == "<"); + } }); return pBox; @@ -96,6 +99,7 @@ public: QString Program = pItem->data(index.column(), Qt::UserRole).toString(); pBox->setProperty("value", Program); + pBox->lineEdit()->setReadOnly(Program.left(1) == "<"); int Index = pBox->findData(Program); pBox->setCurrentIndex(Index); @@ -107,10 +111,11 @@ public: } virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { + QTreeWidgetItem* pItem = ((QTreeWidgetHacker*)m_pTree)->itemFromIndex(index); QComboBox* pBox = qobject_cast(editor); if (pBox) { - QTreeWidgetItem* pItem = ((QTreeWidgetHacker*)m_pTree)->itemFromIndex(index); + QString Value = pBox->property("value").toString(); pItem->setText(index.column(), pBox->currentText()); //QString Text = pBox->currentText(); @@ -120,7 +125,6 @@ public: QLineEdit* pEdit = qobject_cast(editor); if (pEdit) { - QTreeWidgetItem* pItem = ((QTreeWidgetHacker*)m_pTree)->itemFromIndex(index); pItem->setText(index.column(), pEdit->text()); QString Value = pEdit->text(); if (m_Group) Value = "<" + Value + ">"; @@ -128,6 +132,13 @@ public: } } + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const + { + QSize size = QStyledItemDelegate::sizeHint(option, index); + if(size.height() < 20) size.setHeight(20); // ensure enough room for teh combo box + return size; + } + protected: COptionsWindow* m_pOptions; QTreeWidget* m_pTree; diff --git a/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp b/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp index 7032044c..1481a1a8 100644 --- a/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp @@ -11,6 +11,8 @@ bool CPopUpWindow__DarkMode = false; CPopUpWindow::CPopUpWindow(QWidget* parent) : QMainWindow(parent) { + m_HideAllMessages = false; + Qt::WindowFlags flags = windowFlags(); flags |= Qt::CustomizeWindowHint; //flags &= ~Qt::WindowContextHelpButtonHint; @@ -185,7 +187,15 @@ void CPopUpWindow::ReloadHiddenMessages() QStringList HiddenMessages = theAPI->GetUserSettings()->GetTextList("SbieCtrl_HideMessage", true); foreach(const QString& HiddenMessage, HiddenMessages) { + if (HiddenMessage == "*") { + m_HideAllMessages = true; + m_HiddenMessages.clear(); + break; + } + StrPair CodeDetail = Split2(HiddenMessage, ","); + if (CodeDetail.first.left(4) == "SBIE" || CodeDetail.first.left(4) == "SBOX") + CodeDetail.first = CodeDetail.first.mid(4); m_HiddenMessages.insert(CodeDetail.first.toInt(), CodeDetail.second); } } @@ -221,9 +231,16 @@ void CPopUpWindow::OnHideMessage() bool CPopUpWindow::IsMessageHidden(quint32 MsgCode, const QStringList& MsgData) { + if (m_HideAllMessages) + return true; + foreach(const QString& Details, m_HiddenMessages.values(MsgCode & 0xFFFF)) { - if(Details.isEmpty() || (MsgData.size() >= 2 && Details.compare(MsgData[1]) == 0)) + if(Details.isEmpty()) + return true; + + QRegularExpression exp("^" + QRegularExpression::escape(Details).replace("\\*",".*").replace("\\?",".")); + if(MsgData.size() >= 2 && exp.match(MsgData[1]).hasMatch()) return true; } return false; diff --git a/SandboxiePlus/SandMan/Windows/PopUpWindow.h b/SandboxiePlus/SandMan/Windows/PopUpWindow.h index 812e94da..604d0197 100644 --- a/SandboxiePlus/SandMan/Windows/PopUpWindow.h +++ b/SandboxiePlus/SandMan/Windows/PopUpWindow.h @@ -456,6 +456,7 @@ protected: virtual void SendPromptResult(CPopUpPrompt* pEntry, int retval); QMultiMap m_HiddenMessages; + bool m_HideAllMessages; private: bool m_ResetPosition;