This commit is contained in:
DavidXanatos 2024-04-20 14:32:15 +02:00
parent e1c46bb269
commit cc63194b5f
18 changed files with 162 additions and 124 deletions

View File

@ -15,7 +15,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Note: this option may cause issues in games hence do not enable it for gaming boxes.
- added support for hardlinks [#3826](https://github.com/sandboxie-plus/Sandboxie/issues/3826)
- added mechanism to terminate stuck sandboxed processes from the driver
- added Sandman: Make the trigger list editable [#3742](https://github.com/sandboxie-plus/Sandboxie/issues/3742)
- added Make the trigger list editable [#3742](https://github.com/sandboxie-plus/Sandboxie/issues/3742)
- added Optionally extend the screenshot protection to the UI [#3739](https://github.com/sandboxie-plus/Sandboxie/issues/3739)
### Changed
- improved Avast template [#3777](https://github.com/sandboxie-plus/Sandboxie/pull/3777)

View File

@ -617,16 +617,16 @@ bool InitConsole(bool bCreateIfNeeded)
// avoid flashing a bright white window when in dark mode
//
void SafeShow(QWidget* pWidget) {
static bool Lock = false;
pWidget->setProperty("windowOpacity", 0.0);
if (Lock == false) {
Lock = true;
pWidget->show();
QApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
Lock = false;
} else
pWidget->show();
pWidget->setProperty("windowOpacity", 1.0);
}
//void SafeShow(QWidget* pWidget) {
// static bool Lock = false;
// pWidget->setProperty("windowOpacity", 0.0);
// if (Lock == false) {
// Lock = true;
// pWidget->show();
// QApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
// Lock = false;
// } else
// pWidget->show();
// pWidget->setProperty("windowOpacity", 1.0);
//}

View File

@ -115,7 +115,7 @@ MISCHELPERS_EXPORT void SetPaleteTexture(QPalette& palette, QPalette::ColorRole
MISCHELPERS_EXPORT bool InitConsole(bool bCreateIfNeeded = true);
#endif
MISCHELPERS_EXPORT void SafeShow(QWidget* pWidget);
//MISCHELPERS_EXPORT void SafeShow(QWidget* pWidget);
template <typename T>
QSet<T> ListToSet(const QList<T>& qList) { return QSet<T>(qList.begin(), qList.end()); }

View File

@ -1,22 +1,21 @@
#include "stdafx.h"
#include "../../MiscHelpers/Common/Settings.h"
#include "Settings.h"
#include "MultiErrorDialog.h"
#include "..\SandMan.h"
CMultiErrorDialog::CMultiErrorDialog(const QString& Message, const QStringList& Errors, QWidget* parent)
CMultiErrorDialog::CMultiErrorDialog(const QString& Title, const QString& Message, const QStringList& Errors, QWidget* parent)
: QDialog(parent)
{
this->setWindowTitle(tr("Sandboxie-Plus - Error"));
this->setWindowTitle(Title);
m_pMainLayout = new QGridLayout(this);
int Row = 0;
m_pMainLayout->addWidget(new QLabel(Message), Row++, 0, 1, 4);
m_pErrors = new CPanelWidgetEx();
m_pErrors->GetTree()->setItemDelegate(new CTreeItemDelegate());
//m_pErrors->GetTree()->setItemDelegate(new CTreeItemDelegate());
m_pErrors->GetTree()->setHeaderLabels(tr("Message").split("|"));
//m_pErrors->GetTree()->setHeaderLabels(tr("Message").split("|"));
m_pErrors->GetView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_pErrors->GetView()->setSortingEnabled(false);
@ -31,7 +30,7 @@ CMultiErrorDialog::CMultiErrorDialog(const QString& Message, const QStringList&
connect(m_pButtonBox,SIGNAL(accepted()),this,SLOT(accept()));
connect(m_pButtonBox,SIGNAL(rejected()),this,SLOT(reject()));
restoreGeometry(theConf->GetBlob("ErrorWindow/Window_Geometry"));
//restoreGeometry(theConf->GetBlob("ErrorWindow/Window_Geometry"));
foreach(const QString& Error, Errors)
@ -47,5 +46,5 @@ CMultiErrorDialog::CMultiErrorDialog(const QString& Message, const QStringList&
CMultiErrorDialog::~CMultiErrorDialog()
{
theConf->SetBlob("ErrorWindow/Window_Geometry", saveGeometry());
//theConf->SetBlob("ErrorWindow/Window_Geometry", saveGeometry());
}

View File

@ -1,13 +1,12 @@
#pragma once
#include "../../MiscHelpers/Common/PanelView.h"
#include "../../QSbieAPI/SbieStatus.h"
#include "PanelView.h"
class CMultiErrorDialog : public QDialog
class MISCHELPERS_EXPORT CMultiErrorDialog : public QDialog
{
Q_OBJECT
public:
CMultiErrorDialog(const QString& Message, const QStringList& Errors, QWidget* parent = 0);
CMultiErrorDialog(const QString& Title, const QString& Message, const QStringList& Errors, QWidget* parent = 0);
virtual ~CMultiErrorDialog();
private:

View File

@ -35,6 +35,7 @@ HEADERS += ./MiscHelpers.h \
./Common/NeonEffect.h \
./Common/NetworkAccessManager.h \
./Common/MT/ThreadLock.h \
./Common/MultiErrorDialog.h \
./Archive/Archive.h \
./Archive/ArchiveFS.h \
./Archive/ArchiveExtractor.h \
@ -70,6 +71,7 @@ SOURCES += ./MiscHelpers.cpp \
./Common/TreeItemModel.cpp \
./Common/Xml.cpp \
./Common/MT/ThreadLock.cpp \
./Common/MultiErrorDialog.cpp \
./Archive/Archive.cpp \
./Archive/ArchiveFS.cpp \
./Archive/ArchiveExtractor.cpp \

View File

@ -1088,20 +1088,64 @@
<layout class="QGridLayout" name="gridLayout_32">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_31">
<item row="1" column="2">
<widget class="QComboBox" name="cmbDPI"/>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_24">
<item row="1" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Font Scaling</string>
<string>High DPI Scaling</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="3">
<item row="2" column="3">
<widget class="QLabel" name="label_13">
<property name="text">
<string>%</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_26">
<property name="text">
<string>External Ini Editor</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Ini Editor Font</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cmbFontScale">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="4">
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="btnSelectIniFont">
@ -1138,8 +1182,11 @@
</item>
</layout>
</item>
<item row="6" column="2">
<spacer name="horizontalSpacer_18">
<item row="1" column="2">
<widget class="QComboBox" name="cmbDPI"/>
</item>
<item row="7" column="0">
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -1155,7 +1202,6 @@
<widget class="QLabel" name="lblDisplay">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
@ -1165,18 +1211,8 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>High DPI Scaling</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="4">
<spacer name="horizontalSpacer_20">
<item row="7" column="2">
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -1188,28 +1224,7 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblIni">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Ini Options</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_13">
<property name="text">
<string>%</string>
</property>
</widget>
</item>
<item row="6" column="3">
<item row="7" column="3">
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -1222,17 +1237,24 @@
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_6">
<item row="2" column="1">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Ini Editor Font</string>
<string>Font Scaling</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="5" column="2">
<widget class="QLabel" name="lblIniEditFont">
<property name="text">
<string>#</string>
</property>
</widget>
</item>
<item row="7" column="1">
<spacer name="verticalSpacer_10">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -1245,19 +1267,8 @@
</property>
</spacer>
</item>
<item row="4" column="2">
<widget class="QLabel" name="lblIniEditFont">
<property name="text">
<string>#</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cmbFontScale">
<property name="editable">
<bool>true</bool>
</property>
</widget>
<item row="6" column="2" colspan="2">
<widget class="QLineEdit" name="txtEditor"/>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label">
@ -1266,29 +1277,23 @@
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="4" column="0">
<widget class="QLabel" name="lblIni">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="2" colspan="2">
<widget class="QLineEdit" name="txtEditor"/>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_26">
<property name="text">
<string>External Ini Editor</string>
<string>Ini Options</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</widget>
</item>
<item row="3" column="1" colspan="4">
<widget class="QCheckBox" name="chkHide">
<property name="text">
<string>Hide SandMan windows from screen capture (UI restart required)</string>
</property>
</widget>
</item>

View File

@ -117,4 +117,14 @@ bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index)
BOOL Ret = PickIconDlg((HWND)pParent->window()->winId(), iconPath, MAX_PATH, (int*)&Index);
Path = QString::fromWCharArray(iconPath);
return !!Ret;
}
void ProtectWindow(void* hWnd)
{
typedef BOOL(*LPSETWINDOWDISPLAYAFFINITY)(HWND, DWORD);
static LPSETWINDOWDISPLAYAFFINITY pSetWindowDisplayAffinity = NULL;
if (!pSetWindowDisplayAffinity)
pSetWindowDisplayAffinity = (LPSETWINDOWDISPLAYAFFINITY)GetProcAddress(LoadLibraryA("user32.dll"), "SetWindowDisplayAffinity");
if (pSetWindowDisplayAffinity)
pSetWindowDisplayAffinity((HWND)hWnd, 0x00000011);
}

View File

@ -4,4 +4,6 @@ QVariantMap ResolveShortcut(const QString& LinkPath);
QPixmap LoadWindowsIcon(const QString& Path, quint32 Index);
bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index);
bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index);
void ProtectWindow(void* hWnd);

View File

@ -6,7 +6,7 @@
#include "Views/SbieView.h"
#include "../MiscHelpers/Common/CheckableMessageBox.h"
#include <QWinEventNotifier>
#include "./Dialogs/MultiErrorDialog.h"
#include "../MiscHelpers/Common/MultiErrorDialog.h"
#include "../QSbieAPI/SbieUtils.h"
#include "../QSbieAPI/Sandboxie/BoxBorder.h"
#include "../QSbieAPI/Sandboxie/SbieTemplates.h"
@ -119,7 +119,7 @@ CSandMan::CSandMan(QWidget *parent)
: QMainWindow(parent)
{
#if defined(Q_OS_WIN)
MainWndHandle = (HWND)QWidget::winId();
MainWndHandle = (HWND)winId();
QApplication::instance()->installNativeEventFilter(new CNativeEventFilter);
#endif
@ -1596,6 +1596,23 @@ bool CSandMan::IsSilentMode()
return IsFullScreenMode();
}
void CSandMan::SafeShow(QWidget* pWidget)
{
if(theConf->GetBool("Options/CoverWindows", false))
ProtectWindow((HWND)pWidget->winId());
static bool Lock = false;
pWidget->setProperty("windowOpacity", 0.0);
if (Lock == false) {
Lock = true;
pWidget->show();
QApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
Lock = false;
} else
pWidget->show();
pWidget->setProperty("windowOpacity", 1.0);
}
QWidget* g_GUIParent = NULL;
int CSandMan::SafeExec(QDialog* pDialog)
@ -3992,8 +4009,8 @@ void CSandMan::CheckResults(QList<SB_STATUS> Results, QWidget* pParent, bool bAs
else if (Errors.count() == 1)
QMessageBox::warning(pParent ? pParent : this, tr("Sandboxie-Plus - Error"), Errors.first());
else if (Errors.count() > 1) {
CMultiErrorDialog Dialog(tr("Operation failed for %1 item(s).").arg(Errors.size()), Errors, pParent ? pParent : this);
Dialog.exec();
CMultiErrorDialog Dialog("Sandboxie-Plus", tr("Operation failed for %1 item(s).").arg(Errors.size()), Errors, pParent ? pParent : this);
theGUI->SafeExec(&Dialog);
}
}

View File

@ -88,6 +88,7 @@ public:
QString FormatSbieMessage(quint32 MsgCode, const QStringList& MsgData, QString ProcessName, QString* pLink = NULL);
QString MakeSbieMsgLink(quint32 MsgCode, const QStringList& MsgData, QString ProcessName);
static void SafeShow(QWidget* pWidget);
int SafeExec(QDialog* pDialog);
bool RunSandboxed(const QStringList& Commands, QString BoxName = QString(), const QString& WrkDir = QString());

View File

@ -16,7 +16,6 @@ HEADERS += ./stdafx.h \
./Views/FileView.h \
./Views/TraceView.h \
./Views/StackView.h \
./Dialogs/MultiErrorDialog.h \
./Helpers/FindTool.h \
./Helpers/FullScreen.h \
./Helpers/WinAdmin.h \
@ -65,7 +64,6 @@ SOURCES += ./main.cpp \
./Views/FileView.cpp \
./Views/TraceView.cpp \
./Views/StackView.cpp \
./Dialogs/MultiErrorDialog.cpp \
./Helpers/FindTool.cpp \
./Helpers/FullScreen.cpp \
./Helpers/WinAdmin.cpp \

View File

@ -1334,7 +1334,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
connect(pSnapshotsWindow, &CSnapshotsWindow::Closed, [this, pBox]() {
SnapshotWindows.remove(pBox.data());
});
SafeShow(pSnapshotsWindow);
CSandMan::SafeShow(pSnapshotsWindow);
}
else {
pSnapshotsWindow->setWindowState((pSnapshotsWindow->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
@ -1725,7 +1725,7 @@ void CSbieView::ShowOptions(const CSandBoxPtr& pBox)
connect(pBoxEx->m_pOptionsWnd, &COptionsWindow::Closed, [pBoxEx]() {
pBoxEx->m_pOptionsWnd = NULL;
});
SafeShow(pBoxEx->m_pOptionsWnd);
CSandMan::SafeShow(pBoxEx->m_pOptionsWnd);
}
else {
pBoxEx->m_pOptionsWnd->setWindowState((pBoxEx->m_pOptionsWnd->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
@ -1749,7 +1749,7 @@ void CSbieView::ShowBrowse(const CSandBoxPtr& pBox)
connect(pFileBrowserWindow, &CFileBrowserWindow::Closed, [this, pBox]() {
FileBrowserWindows.remove(pBox.data());
});
SafeShow(pFileBrowserWindow);
CSandMan::SafeShow(pFileBrowserWindow);
}
else {
pFileBrowserWindow->setWindowState((pFileBrowserWindow->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);

View File

@ -105,15 +105,13 @@ protected:
};
QMap<quint32, SProgInfo>m_PidMap;
bool m_FullRefresh;
quint64 m_LastID;
int m_LastCount;
bool m_bUpdatePending;
QVector<CTraceEntryPtr> m_TraceList;
QMap<QString, CMonitorEntryPtr> m_MonitorMap;
protected:
bool m_FullRefresh;
quint32 m_FilterPid;
quint32 m_FilterTid;
QList<quint32> m_FilterTypes;

View File

@ -1080,7 +1080,7 @@ void COptionsWindow::showTab(const QString& Name)
else
m_pStack->setCurrentWidget(pWidget);
SafeShow(this);
CSandMan::SafeShow(this);
}
void COptionsWindow::SetProgramItem(QString Program, QTreeWidgetItem* pItem, int Column, const QString& Suffix, bool bList)

View File

@ -104,7 +104,7 @@ void CPopUpWindow::Show()
this->move(scrRect.width() - 600 - 20, scrRect.height() - 200 - 50);
}
SafeShow(this);
CSandMan::SafeShow(this);
}
void CPopUpWindow::Poke()

View File

@ -160,7 +160,7 @@ int CRecoveryWindow::exec()
{
//QDialog::setWindowModality(Qt::WindowModal);
ui.btnDeleteAll->setVisible(true);
SafeShow(this);
CSandMan::SafeShow(this);
return QDialog::exec();
}

View File

@ -362,6 +362,8 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
connect(ui.cmbFontScale, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChangeGUI()));
connect(ui.cmbFontScale, SIGNAL(currentTextChanged(const QString&)), this, SLOT(OnChangeGUI()));
connect(ui.chkHide, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.txtEditor, SIGNAL(textChanged(const QString&)), this, SLOT(OnOptChanged()));
m_bRebuildUI = false;
@ -680,7 +682,7 @@ void CSettingsWindow::showTab(const QString& Name, bool bExclusive)
}
}
SafeShow(this);
CSandMan::SafeShow(this);
}
void CSettingsWindow::closeEvent(QCloseEvent *e)
@ -905,6 +907,8 @@ void CSettingsWindow::LoadSettings()
//ui.cmbFontScale->setCurrentIndex(ui.cmbFontScale->findData(theConf->GetInt("Options/FontScaling", 100)));
ui.cmbFontScale->setCurrentText(QString::number(theConf->GetInt("Options/FontScaling", 100)));
ui.chkHide->setChecked(theConf->GetBool("Options/CoverWindows", false));
ui.txtEditor->setText(theConf->GetString("Options/Editor", "notepad.exe"));
@ -1552,6 +1556,8 @@ void CSettingsWindow::SaveSettings()
else if (Scaling > 500)
Scaling = 500;
theConf->SetValue("Options/FontScaling", Scaling);
theConf->SetValue("Options/CoverWindows", ui.chkHide->isChecked());
theConf->SetValue("Options/Editor", ui.txtEditor->text());