diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e41d97..89e3d90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/SandboxiePlus/MiscHelpers/Common/Common.cpp b/SandboxiePlus/MiscHelpers/Common/Common.cpp index 542d9142..a6c7aef0 100644 --- a/SandboxiePlus/MiscHelpers/Common/Common.cpp +++ b/SandboxiePlus/MiscHelpers/Common/Common.cpp @@ -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); +//} diff --git a/SandboxiePlus/MiscHelpers/Common/Common.h b/SandboxiePlus/MiscHelpers/Common/Common.h index febbff92..c30b1455 100644 --- a/SandboxiePlus/MiscHelpers/Common/Common.h +++ b/SandboxiePlus/MiscHelpers/Common/Common.h @@ -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 QSet ListToSet(const QList& qList) { return QSet(qList.begin(), qList.end()); } diff --git a/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.cpp b/SandboxiePlus/MiscHelpers/Common/MultiErrorDialog.cpp similarity index 69% rename from SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.cpp rename to SandboxiePlus/MiscHelpers/Common/MultiErrorDialog.cpp index a7375298..c976211a 100644 --- a/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.cpp +++ b/SandboxiePlus/MiscHelpers/Common/MultiErrorDialog.cpp @@ -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()); } diff --git a/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.h b/SandboxiePlus/MiscHelpers/Common/MultiErrorDialog.h similarity index 52% rename from SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.h rename to SandboxiePlus/MiscHelpers/Common/MultiErrorDialog.h index d9bde152..4689f9e8 100644 --- a/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.h +++ b/SandboxiePlus/MiscHelpers/Common/MultiErrorDialog.h @@ -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: diff --git a/SandboxiePlus/MiscHelpers/MiscHelpers.pri b/SandboxiePlus/MiscHelpers/MiscHelpers.pri index bd82b14e..0584df96 100644 --- a/SandboxiePlus/MiscHelpers/MiscHelpers.pri +++ b/SandboxiePlus/MiscHelpers/MiscHelpers.pri @@ -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 \ diff --git a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui index 558c368c..40e89c82 100644 --- a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui +++ b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui @@ -1088,20 +1088,64 @@ - - - - - + + - Font Scaling + High DPI Scaling Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + + + + % + + + + + + + External Ini Editor + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Ini Editor Font + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + @@ -1138,8 +1182,11 @@ - - + + + + + Qt::Horizontal @@ -1155,7 +1202,6 @@ - 75 true true @@ -1165,18 +1211,8 @@ - - - - High DPI Scaling - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + + Qt::Horizontal @@ -1188,28 +1224,7 @@ - - - - - 75 - true - true - - - - Ini Options - - - - - - - % - - - - + Qt::Horizontal @@ -1222,17 +1237,24 @@ - - + + - Ini Editor Font + Font Scaling Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + + + + # + + + + Qt::Vertical @@ -1245,19 +1267,8 @@ - - - - # - - - - - - - true - - + + @@ -1266,29 +1277,23 @@ - - - - Qt::Horizontal + + + + + true + true + - - - 40 - 20 - - - - - - - - - - External Ini Editor + Ini Options - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + Hide SandMan windows from screen capture (UI restart required) diff --git a/SandboxiePlus/SandMan/Helpers/WinHelper.cpp b/SandboxiePlus/SandMan/Helpers/WinHelper.cpp index 8a946309..da2b1b9c 100644 --- a/SandboxiePlus/SandMan/Helpers/WinHelper.cpp +++ b/SandboxiePlus/SandMan/Helpers/WinHelper.cpp @@ -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); } \ No newline at end of file diff --git a/SandboxiePlus/SandMan/Helpers/WinHelper.h b/SandboxiePlus/SandMan/Helpers/WinHelper.h index 3b734df7..91bbf372 100644 --- a/SandboxiePlus/SandMan/Helpers/WinHelper.h +++ b/SandboxiePlus/SandMan/Helpers/WinHelper.h @@ -4,4 +4,6 @@ QVariantMap ResolveShortcut(const QString& LinkPath); QPixmap LoadWindowsIcon(const QString& Path, quint32 Index); -bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index); \ No newline at end of file +bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index); + +void ProtectWindow(void* hWnd); \ No newline at end of file diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 92fbb5f6..9a84071d 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -6,7 +6,7 @@ #include "Views/SbieView.h" #include "../MiscHelpers/Common/CheckableMessageBox.h" #include -#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 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); } } diff --git a/SandboxiePlus/SandMan/SandMan.h b/SandboxiePlus/SandMan/SandMan.h index c5f84d00..451f8c33 100644 --- a/SandboxiePlus/SandMan/SandMan.h +++ b/SandboxiePlus/SandMan/SandMan.h @@ -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()); diff --git a/SandboxiePlus/SandMan/SandMan.pri b/SandboxiePlus/SandMan/SandMan.pri index 9e65518a..5cda6208 100644 --- a/SandboxiePlus/SandMan/SandMan.pri +++ b/SandboxiePlus/SandMan/SandMan.pri @@ -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 \ diff --git a/SandboxiePlus/SandMan/Views/SbieView.cpp b/SandboxiePlus/SandMan/Views/SbieView.cpp index 71f3b8e2..61e7e9d3 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.cpp +++ b/SandboxiePlus/SandMan/Views/SbieView.cpp @@ -1334,7 +1334,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList& 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); diff --git a/SandboxiePlus/SandMan/Views/TraceView.h b/SandboxiePlus/SandMan/Views/TraceView.h index b06b967b..cfcbf1bd 100644 --- a/SandboxiePlus/SandMan/Views/TraceView.h +++ b/SandboxiePlus/SandMan/Views/TraceView.h @@ -105,15 +105,13 @@ protected: }; QMapm_PidMap; + bool m_FullRefresh; quint64 m_LastID; int m_LastCount; bool m_bUpdatePending; QVector m_TraceList; QMap m_MonitorMap; -protected: - bool m_FullRefresh; - quint32 m_FilterPid; quint32 m_FilterTid; QList m_FilterTypes; diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp index c64c319b..965a2602 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp @@ -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) diff --git a/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp b/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp index 77cafebb..16b2142e 100644 --- a/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/PopUpWindow.cpp @@ -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() diff --git a/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp b/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp index b7a36d8b..5551174f 100644 --- a/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp @@ -160,7 +160,7 @@ int CRecoveryWindow::exec() { //QDialog::setWindowModality(Qt::WindowModal); ui.btnDeleteAll->setVisible(true); - SafeShow(this); + CSandMan::SafeShow(this); return QDialog::exec(); } diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index a04171f7..eaeb00bc 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -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());