Gui: Fix window restoration after Edit->Alignment completion
After completing Edit->Alignment, main window remains small instead of maximized. It looks like this is Qt 6 regression as the automatic maximization behavior was somehow changed. Previously it didn't need explicit handling to restore the maximisation. So, this patch preserves the previous window state before entering Alignment editor and restores window being maximized/minimized or normal upon finishing the operation.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
# include <QLabel>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
# include <QMdiSubWindow>
|
||||
# include <QPainter>
|
||||
# include <QSplitter>
|
||||
# include <QSurfaceFormat>
|
||||
@@ -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<QMdiSubWindow*>(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<QMdiSubWindow*>(activeView->parentWidget())) {
|
||||
// restore the previous window state
|
||||
if (previousWindowState & Qt::WindowMaximized) {
|
||||
subWindow->showMaximized();
|
||||
}
|
||||
else if (previousWindowState & Qt::WindowMinimized) {
|
||||
subWindow->showMinimized();
|
||||
}
|
||||
else {
|
||||
subWindow->showNormal();
|
||||
}
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user