diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index a37af55c7e..4948e987c0 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -27,6 +27,7 @@ # include # include # include +# include # include # include # include @@ -791,6 +792,18 @@ void ManualAlignment::startAlignment(Base::Type mousemodel) if (myAlignModel.isEmpty()) return; +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + // save the current window state before opening the alignment viewer + previousWindowState = Qt::WindowNoState; + if (auto* activeDoc = Gui::Application::Instance->activeDocument()) { + if (auto* activeView = activeDoc->getActiveView()) { + if (auto* subWindow = qobject_cast(activeView->parentWidget())) { + previousWindowState = subWindow->windowState(); + } + } + } +#endif + // create a split window for picking the points myViewer = new AlignmentView(myDocument,Gui::getMainWindow()); myViewer->setWindowTitle(tr("Alignment[*]")); @@ -874,6 +887,34 @@ void ManualAlignment::closeViewer() if (myViewer->parentWidget()) myViewer->parentWidget()->deleteLater(); myViewer = nullptr; + +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + QTimer::singleShot(0, [this]() { + auto* activeDoc = Gui::Application::Instance->activeDocument(); + if (!activeDoc) { + return; + } + + auto* activeView = activeDoc->getActiveView(); + if (!activeView) { + return; + } + + Gui::getMainWindow()->setActiveWindow(activeView); + if (auto* subWindow = qobject_cast(activeView->parentWidget())) { + // restore the previous window state + if (previousWindowState & Qt::WindowMaximized) { + subWindow->showMaximized(); + } + else if (previousWindowState & Qt::WindowMinimized) { + subWindow->showMinimized(); + } + else { + subWindow->showNormal(); + } + } + }); +#endif } /** diff --git a/src/Gui/ManualAlignment.h b/src/Gui/ManualAlignment.h index 95b1f0a5bc..d3dbb4dc61 100644 --- a/src/Gui/ManualAlignment.h +++ b/src/Gui/ManualAlignment.h @@ -262,6 +262,10 @@ private: int myPickPoints; Base::Placement myTransform; +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + Qt::WindowStates previousWindowState; +#endif + class Private; Private* d; };