diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 959b6afe9..6dbb5a970 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -883,6 +883,13 @@ namespace BlackGui c = connect(a, &QAction::triggered, this, &CGuiApplication::windowToBack); Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed"); + a = menu.addAction("Toggle normal or minimized"); + c = connect(a, &QAction::triggered, this, [ = ]() + { + if (!w) { return; } + this->windowMinimizeNormalToggle(); + }); + Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); Q_UNUSED(c) } @@ -1182,14 +1189,8 @@ namespace BlackGui w->showNormal(); // bring window to top on OSX w->raise(); // bring window from minimized state on OSX - // In order to show also on top if another window is (permanent) on top - if (!CGuiUtility::staysOnTop(w)) - { - CGuiUtility::stayOnTop(true, w); - emit this->alwaysOnTop(true); - } - - // w->activateWindow(); // bring window to front/unminimize on windows + // if (!CGuiUtility::staysOnTop(w)) { CGuiUtility::stayOnTop(true, w); emit this->alwaysOnTop(true); } + w->activateWindow(); // bring window to front/unminimize on windows } void CGuiApplication::windowToBack() @@ -1226,6 +1227,24 @@ namespace BlackGui } } + void CGuiApplication::windowMinimizeNormalToggle() + { + if (this->isShuttingDown()) { return; } + QMainWindow *w = sGui->mainApplicationWindow(); + if (!w) { return; } + if (m_normalizeMinimize) + { + w->showMinimized(); + } + else + { + // trick here is to minimize first and the normalize from minimized state + w->showMinimized(); + w->showNormal(); + } + m_normalizeMinimize = !m_normalizeMinimize; + } + void CGuiApplication::triggerNewVersionCheck(int delayedMs) { if (!m_updateSetting.get()) { return; } diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index f5e8482e9..5029ae625 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -239,6 +239,9 @@ namespace BlackGui void windowToFrontBackToggle(); //! @} + //! Window minimize/normalize + void windowMinimizeNormalToggle(); + //! Save the main widget state? void setSaveMainWidgetState(bool save) { m_saveMainWidgetState = save; } @@ -344,7 +347,8 @@ namespace BlackGui CStyleSheetUtility m_styleSheetUtility {{}, this}; //!< style sheet utility bool m_uiSetupCompleted = false; //!< ui setup completed bool m_saveMainWidgetState = true; //!< save/restore main widget's state - bool m_frontBack = true; + bool m_frontBack = true; //!< for front/back toggle + bool m_normalizeMinimize = true; //!< for normalize/minimize toggle QScopedPointer m_splashScreen; //!< splash screen Components::CUpdateInfoDialog *m_updateDialog = nullptr; //!< software installation dialog Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent)