This commit is contained in:
DavidXanatos 2022-12-21 10:14:31 +01:00
parent 4321907084
commit b871341426
8 changed files with 38 additions and 21 deletions

View File

@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- fixed on reboot auto clean up boxes are nto cleared [#2531](https://github.com/sandboxie-plus/Sandboxie/issues/2531)
-- Note: a clean up is now done after each reboot
- fixed issue with Network Location Awareness under windows 11 [#2530](https://github.com/sandboxie-plus/Sandboxie/issues/2530)
- fixed issues with recovery window [#2458](https://github.com/sandboxie-plus/Sandboxie/issues/2458)
## [1.6.2a / 5.61.2] - 2022-12-19

View File

@ -10,14 +10,14 @@
#include <Shlwapi.h>
#include <Shlobj.h>
QImage LoadWindowsIcon(const QString& Path, quint32 Index)
QPixmap LoadWindowsIcon(const QString& Path, quint32 Index)
{
std::wstring path = QString(Path).replace("/", "\\").toStdWString();
HICON icon = ExtractIconW(NULL, path.c_str(), Index);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QImage Icon = QtWin::fromHICON(icon).toImage();
QPixmap Icon = QtWin::fromHICON(icon);
#else
QImage Icon = QImage::fromHICON(icon);
QPixmap Icon = QPixmap::fromImage(QImage::fromHICON(icon));
#endif
DestroyIcon(icon);
return Icon;

View File

@ -1,5 +1,5 @@
#pragma once
QImage LoadWindowsIcon(const QString& Path, quint32 Index);
QPixmap LoadWindowsIcon(const QString& Path, quint32 Index);
bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index);

View File

@ -231,13 +231,13 @@ QList<QVariant> CSbieModel::Sync(const QMap<QString, CSandBoxPtr>& BoxList, cons
{
StrPair PathIndex = Split2(BoxIcon, ",");
if (!PathIndex.second.isEmpty() && !PathIndex.second.contains("."))
Icon = QIcon(QPixmap::fromImage(LoadWindowsIcon(PathIndex.first, PathIndex.second.toInt())));
Icon = QIcon(LoadWindowsIcon(PathIndex.first, PathIndex.second.toInt()));
else
Icon = QIcon(QPixmap(BoxIcon));
pNode->BoxIcon = BoxIcon;
}
}
else if (pNode->inUse != inUse || pNode->bOpen != bOpen || (pNode->busyState || Busy) || pNode->boxType != boxType || pNode->boxColor != boxColor || pNode->boxDel != boxDel)
else if (pNode->inUse != inUse || pNode->bOpen != bOpen || (pNode->busyState || Busy) || pNode->boxType != boxType || pNode->boxColor != boxColor || pNode->boxDel != boxDel || !pNode->BoxIcon.isEmpty())
{
pNode->inUse = inUse;
pNode->bOpen = bOpen;

View File

@ -28,18 +28,25 @@ bool CSandMan::OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteShapshots, bool
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
if (!pBoxEx) return false;
if (pBoxEx->m_pRecoveryWnd != NULL) {
if (pBoxEx->m_pRecoveryWnd->IsDeleteDialog())
return false;
pBoxEx->m_pRecoveryWnd->close();
// todo: reuse window?
}
CRecoveryWindow* pRecoveryWindow = new CRecoveryWindow(pBox, false, this);
if (pRecoveryWindow->FindFiles() == 0 && bCloseEmpty) {
delete pRecoveryWindow;
CRecoveryWindow* pRecoveryWnd = pBoxEx->m_pRecoveryWnd = new CRecoveryWindow(pBox, false, this);
if (pBoxEx->m_pRecoveryWnd->FindFiles() == 0 && bCloseEmpty) {
delete pBoxEx->m_pRecoveryWnd;
pBoxEx->m_pRecoveryWnd = NULL;
return true;
}
else if (pRecoveryWindow->exec() != 1)
else {
connect(pBoxEx->m_pRecoveryWnd, &CRecoveryWindow::Closed, [pBoxEx]() {
pBoxEx->m_pRecoveryWnd = NULL;
});
if (pBoxEx->m_pRecoveryWnd->exec() != 1)
return false;
DeleteShapshots = pRecoveryWindow->IsDeleteShapshots();
}
DeleteShapshots = pRecoveryWnd->IsDeleteShapshots();
return true;
}
@ -54,10 +61,10 @@ CRecoveryWindow* CSandMan::ShowRecovery(const CSandBoxPtr& pBox, bool bFind)
});
pBoxEx->m_pRecoveryWnd->show();
}
/*else {
else if(bFind) { // We don't want to force window in front on instant recovery
pBoxEx->m_pRecoveryWnd->setWindowState((pBoxEx->m_pRecoveryWnd->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
//SetForegroundWindow((HWND)pBoxEx->m_pRecoveryWnd->winId());
}*/
SetForegroundWindow((HWND)pBoxEx->m_pRecoveryWnd->winId());
}
if(bFind)
pBoxEx->m_pRecoveryWnd->FindFiles();
return pBoxEx->m_pRecoveryWnd;

View File

@ -195,7 +195,7 @@ void COptionsWindow::LoadGeneral()
m_pPickIcon->setEnabled(!m_BoxIcon.isEmpty());
StrPair PathIndex = Split2(m_BoxIcon, ",");
if (!PathIndex.second.isEmpty() && !PathIndex.second.contains("."))
ui.btnBorderColor->setIcon(QPixmap::fromImage(LoadWindowsIcon(PathIndex.first, PathIndex.second.toInt())));
ui.btnBorderColor->setIcon(LoadWindowsIcon(PathIndex.first, PathIndex.second.toInt()));
else if (!m_BoxIcon.isEmpty())
ui.btnBorderColor->setIcon(QPixmap(m_BoxIcon));
else
@ -410,7 +410,7 @@ void COptionsWindow::OnUseIcon(bool bUse)
if (m_BoxIcon.isEmpty()) {
QString ActionFile = GetActionFile();
if (!ActionFile.isEmpty()) {
ui.btnBorderColor->setIcon(QPixmap::fromImage(LoadWindowsIcon(ActionFile, 0)));
ui.btnBorderColor->setIcon(LoadWindowsIcon(ActionFile, 0));
m_BoxIcon = QString("%1,0").arg(ActionFile);
}
}
@ -442,7 +442,7 @@ bool COptionsWindow::OnPickIcon()
if (!PickWindowsIcon(this, Path, Index))
return false;
ui.btnBorderColor->setIcon(QPixmap::fromImage(LoadWindowsIcon(Path, Index)));
ui.btnBorderColor->setIcon(LoadWindowsIcon(Path, Index));
m_BoxIcon = QString("%1,%2").arg(Path).arg(Index);
m_GeneralChanged = true;
@ -498,7 +498,7 @@ QString COptionsWindow::GetActionFile()
CSandBoxPlus* pBoxEx = qobject_cast<CSandBoxPlus*>(m_pBox.data());
if (pBoxEx) {
QString Path = pBoxEx->GetCommandFile(Action);
ui.btnBorderColor->setIcon(QPixmap::fromImage(LoadWindowsIcon(Path, 0)));
ui.btnBorderColor->setIcon(LoadWindowsIcon(Path, 0));
return Path;
}
}
@ -512,11 +512,13 @@ void COptionsWindow::OnActionChanged()
QString ActionFile = GetActionFile();
if (!ActionFile.isEmpty()) {
ui.btnBorderColor->setIcon(QPixmap::fromImage(LoadWindowsIcon(ActionFile, 0)));
ui.btnBorderColor->setIcon(LoadWindowsIcon(ActionFile, 0));
m_pUseIcon->setChecked(true);
m_BoxIcon = QString("%1,0").arg(ActionFile);
}
else {
ui.btnBorderColor->setIcon(QPixmap());
m_pUseIcon->setChecked(false);
m_BoxIcon.clear();
}

View File

@ -163,6 +163,11 @@ int CRecoveryWindow::exec()
return QDialog::exec();
}
bool CRecoveryWindow::IsDeleteDialog() const
{
return ui.btnDeleteAll->isVisible();
}
void CRecoveryWindow::closeEvent(QCloseEvent *e)
{
emit Closed();

View File

@ -39,6 +39,7 @@ public:
CRecoveryWindow(const CSandBoxPtr& pBox, bool bImmediate = false, QWidget *parent = Q_NULLPTR);
~CRecoveryWindow();
bool IsDeleteDialog() const;
bool IsDeleteShapshots() { return m_DeleteShapshots; }
virtual void accept() {}