Skip to content

Commit

Permalink
1.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Oct 21, 2023
1 parent d5d5885 commit 10e017a
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 32 deletions.
40 changes: 25 additions & 15 deletions SandboxiePlus/SandMan/SandMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ CSandMan::CSandMan(QWidget *parent)
QMessageBox::critical(this, "Sandboxie-Plus", tr("WARNING: Sandboxie-Plus.ini in %1 cannot be written to, settings will not be saved.").arg(theConf->GetConfigDir()));
}

m_bOnTop = false;
m_bExit = false;

m_ImDiskReady = true;
Expand Down Expand Up @@ -1358,6 +1359,12 @@ void CSandMan::changeEvent(QEvent* e)
{
if (isMinimized())
{
if (m_bOnTop) {
m_bOnTop = false;
this->setWindowFlag(Qt::WindowStaysOnTopHint, m_bOnTop);
SafeShow(this);
}

if (m_pTrayIcon->isVisible() && theConf->GetBool("Options/MinimizeToTray", false))
{
StoreState();
Expand Down Expand Up @@ -2574,22 +2581,18 @@ void CSandMan::OnHotKey(size_t id)
break;

case HK_TOP:
if (this->isActiveWindow() && m_pWndTopMost->isCheckable()) {
m_pWndTopMost->setChecked(false);
OnAlwaysTop();
return;
}

if (!isVisible()) {
CheckSupport();
show();
if (this->isActiveWindow() && m_bOnTop)
m_bOnTop = false;
else {
m_bOnTop = true;
QTimer::singleShot(100, [this]() {
this->setWindowState((this->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
SetForegroundWindow(MainWndHandle);
});
}
m_pWndTopMost->setChecked(true);
OnAlwaysTop();
QTimer::singleShot(100, [this]() {
this->setWindowState((this->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
SetForegroundWindow(MainWndHandle);
} );
this->setWindowFlag(Qt::WindowStaysOnTopHint, m_bOnTop);
SafeShow(this);
break;
}
}
Expand Down Expand Up @@ -3308,6 +3311,8 @@ void CSandMan::OnViewMode(QAction* pAction)

void CSandMan::OnAlwaysTop()
{
m_bOnTop = false;

StoreState();
bool bAlwaysOnTop = m_pWndTopMost->isChecked();
theConf->SetValue("Options/AlwaysOnTop", bAlwaysOnTop);
Expand All @@ -3319,6 +3324,11 @@ void CSandMan::OnAlwaysTop()
m_pProgressDialog->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
}

bool CSandMan::IsAlwaysOnTop() const
{
return m_bOnTop || theConf->GetBool("Options/AlwaysOnTop", false);
}

void CSandMan::OnRefresh()
{
if (!theAPI->IsConnected())
Expand Down
4 changes: 4 additions & 0 deletions SandboxiePlus/SandMan/SandMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class CSandMan : public QMainWindow

bool CheckCertificate(QWidget* pWidget, bool bAdvanced = false);

bool IsAlwaysOnTop() const;

void UpdateTheme();
void UpdateTitleTheme(const HWND& hwnd);

Expand Down Expand Up @@ -460,6 +462,8 @@ private slots:
bool m_bIconSun;
int m_iDeletingContent;

bool m_bOnTop;

bool m_bExit;

CProgressDialog* m_pProgressDialog;
Expand Down
5 changes: 2 additions & 3 deletions SandboxiePlus/SandMan/SandManRecovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void CSandMan::OnFileToRecover(const QString& BoxName, const QString& FilePath,
{
CRecoveryWindow* pWnd = ShowRecovery(pBox, false);

//if (!theConf->GetBool("Options/AlwaysOnTop", false)) {
//if (!theGUI->IsAlwaysOnTop()) {
// SetWindowPos((HWND)pWnd->winId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
// QTimer::singleShot(100, this, [pWnd]() {
// SetWindowPos((HWND)pWnd->winId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
Expand Down Expand Up @@ -356,8 +356,7 @@ void CRecoveryLogWnd::OnDblClick(QTreeWidgetItem* pItem)
void CSandMan::OnRecoveryLog()
{
if (!m_pRecoveryLogWnd->isVisible()) {
bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
m_pRecoveryLogWnd->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
m_pRecoveryLogWnd->setWindowFlag(Qt::WindowStaysOnTopHint, theGUI->IsAlwaysOnTop());
SafeShow(m_pRecoveryLogWnd);
}
}
3 changes: 1 addition & 2 deletions SandboxiePlus/SandMan/Views/FileView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,7 @@ CFileBrowserWindow::CFileBrowserWindow(const CSandBoxPtr& pBox, QWidget *parent)
//flags &= ~Qt::WindowCloseButtonHint;
setWindowFlags(flags);

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
this->setWindowFlag(Qt::WindowStaysOnTopHint, theGUI->IsAlwaysOnTop());

m_pMainLayout = new QGridLayout(this);
m_FileView = new CFileView();
Expand Down
3 changes: 1 addition & 2 deletions SandboxiePlus/SandMan/Views/TraceView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,7 @@ CTraceWindow::CTraceWindow(QWidget *parent)

this->setWindowTitle(tr("Sandboxie-Plus - Trace Monitor"));

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
this->setWindowFlag(Qt::WindowStaysOnTopHint, theGUI->IsAlwaysOnTop());

QGridLayout* pLayout = new QGridLayout();
pLayout->setContentsMargins(3,3,3,3);
Expand Down
3 changes: 1 addition & 2 deletions SandboxiePlus/SandMan/Windows/OptionsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ COptionsWindow::COptionsWindow(const QSharedPointer<CSbieIni>& pBox, const QStri
//flags &= ~Qt::WindowCloseButtonHint;
setWindowFlags(flags);

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
this->setWindowFlag(Qt::WindowStaysOnTopHint, theGUI->IsAlwaysOnTop());

ui.setupUi(this);
this->setWindowTitle(tr("Sandboxie Plus - '%1' Options").arg(QString(Name).replace("_", " ")));
Expand Down
2 changes: 1 addition & 1 deletion SandboxiePlus/SandMan/Windows/RecoveryWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CRecoveryWindow::CRecoveryWindow(const CSandBoxPtr& pBox, bool bImmediate, QWidg
//setWindowState(Qt::WindowActive);
SetForegroundWindow((HWND)QWidget::winId());

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false) || (bImmediate && theConf->GetBool("Options/RecoveryOnTop", true));
bool bAlwaysOnTop = theGUI->IsAlwaysOnTop() || (bImmediate && theConf->GetBool("Options/RecoveryOnTop", true));
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);

if (!bAlwaysOnTop) {
Expand Down
2 changes: 1 addition & 1 deletion SandboxiePlus/SandMan/Windows/SelectBoxWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ CSelectBoxWindow::CSelectBoxWindow(const QStringList& Commands, const QString& B
//setWindowState(Qt::WindowActive);
SetForegroundWindow((HWND)QWidget::winId());

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
bool bAlwaysOnTop = theGUI->IsAlwaysOnTop();
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);

if (!bAlwaysOnTop) {
Expand Down
3 changes: 1 addition & 2 deletions SandboxiePlus/SandMan/Windows/SettingsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
//flags &= ~Qt::WindowCloseButtonHint;
setWindowFlags(flags);

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
this->setWindowFlag(Qt::WindowStaysOnTopHint, theGUI->IsAlwaysOnTop());

ui.setupUi(this);
this->setWindowTitle(tr("Sandboxie Plus - Global Settings"));
Expand Down
3 changes: 1 addition & 2 deletions SandboxiePlus/SandMan/Windows/SnapshotsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ CSnapshotsWindow::CSnapshotsWindow(const CSandBoxPtr& pBox, QWidget *parent)
//flags &= ~Qt::WindowCloseButtonHint;
setWindowFlags(flags);

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
this->setWindowFlag(Qt::WindowStaysOnTopHint, theGUI->IsAlwaysOnTop());

ui.setupUi(this);
this->setWindowTitle(tr("%1 - Snapshots").arg(pBox->GetName()));
Expand Down
3 changes: 1 addition & 2 deletions SandboxiePlus/SandMan/Windows/SupportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ CSupportDialog::CSupportDialog(const QString& Message, bool NoGo, int Wait, QWid
//setWindowState(Qt::WindowActive);
SetForegroundWindow((HWND)QWidget::winId());

bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false);
this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop);
this->setWindowFlag(Qt::WindowStaysOnTopHint, theGUI->IsAlwaysOnTop());

this->setWindowTitle(tr("Sandboxie-Plus - Support Reminder"));

Expand Down

0 comments on commit 10e017a

Please sign in to comment.