diff --git a/CHANGELOG.md b/CHANGELOG.md index cb4c9790..f48ccc05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/SandboxiePlus/SandMan/Helpers/WinHelper.cpp b/SandboxiePlus/SandMan/Helpers/WinHelper.cpp index 09fe393d..ddf2ab2d 100644 --- a/SandboxiePlus/SandMan/Helpers/WinHelper.cpp +++ b/SandboxiePlus/SandMan/Helpers/WinHelper.cpp @@ -10,14 +10,14 @@ #include #include -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; diff --git a/SandboxiePlus/SandMan/Helpers/WinHelper.h b/SandboxiePlus/SandMan/Helpers/WinHelper.h index adf04552..90b165c4 100644 --- a/SandboxiePlus/SandMan/Helpers/WinHelper.h +++ b/SandboxiePlus/SandMan/Helpers/WinHelper.h @@ -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); \ No newline at end of file diff --git a/SandboxiePlus/SandMan/Models/SbieModel.cpp b/SandboxiePlus/SandMan/Models/SbieModel.cpp index ea59f315..897f3749 100644 --- a/SandboxiePlus/SandMan/Models/SbieModel.cpp +++ b/SandboxiePlus/SandMan/Models/SbieModel.cpp @@ -231,13 +231,13 @@ QList CSbieModel::Sync(const QMap& 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; diff --git a/SandboxiePlus/SandMan/SandManRecovery.cpp b/SandboxiePlus/SandMan/SandManRecovery.cpp index a82cde21..5f22ef2a 100644 --- a/SandboxiePlus/SandMan/SandManRecovery.cpp +++ b/SandboxiePlus/SandMan/SandManRecovery.cpp @@ -28,18 +28,25 @@ bool CSandMan::OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteShapshots, bool auto pBoxEx = pBox.objectCast(); 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) - return false; - DeleteShapshots = pRecoveryWindow->IsDeleteShapshots(); + else { + connect(pBoxEx->m_pRecoveryWnd, &CRecoveryWindow::Closed, [pBoxEx]() { + pBoxEx->m_pRecoveryWnd = NULL; + }); + if (pBoxEx->m_pRecoveryWnd->exec() != 1) + return false; + } + 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; diff --git a/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp b/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp index 71e5f9f7..8d3b1165 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp +++ b/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp @@ -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(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(); } diff --git a/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp b/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp index b34490b5..4ef98c75 100644 --- a/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp @@ -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(); diff --git a/SandboxiePlus/SandMan/Windows/RecoveryWindow.h b/SandboxiePlus/SandMan/Windows/RecoveryWindow.h index 16932add..0c8745e7 100644 --- a/SandboxiePlus/SandMan/Windows/RecoveryWindow.h +++ b/SandboxiePlus/SandMan/Windows/RecoveryWindow.h @@ -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() {}