diff --git a/src/windows/menu-main-window.cpp b/src/windows/menu-main-window.cpp index 0c6eb360f83bbce20c28d118061709927e49ba67..657e92ebc91b6219a7c55dd3208a7092dafe6011 100644 --- a/src/windows/menu-main-window.cpp +++ b/src/windows/menu-main-window.cpp @@ -233,7 +233,18 @@ void MenuWindow::init() }); setScreen(QGuiApplication::primaryScreen()); connect(screen(), &QScreen::geometryChanged, this, &MenuWindow::updateGeometry); - connect(qGuiApp, &QGuiApplication::layoutDirectionChanged, this, &MenuWindow::updateGeometry); + + connect(qGuiApp, &QGuiApplication::layoutDirectionChanged, this, &MenuWindow::updateGeometry, Qt::UniqueConnection); + connect(qGuiApp, &QGuiApplication::screenRemoved, this, [&](QScreen *qScreen) { + if(qScreen == screen()) { + if (screen()) { + screen()->disconnect(this); + } + this->setScreen(UkuiQuick::WindowProxy::currentScreen()); + connect(screen(), &QScreen::geometryChanged, this, &MenuWindow::updateGeometry); + updateGeometry(); + } + }, Qt::UniqueConnection); setTitle(QCoreApplication::applicationName()); setResizeMode(SizeRootObjectToView); @@ -501,7 +512,6 @@ void MenuWindow::activeMenuWindow(bool active) } this->setScreen(UkuiQuick::WindowProxy::currentScreen()); connect(screen(), &QScreen::geometryChanged, this, &MenuWindow::updateGeometry); - connect(qGuiApp, &QGuiApplication::layoutDirectionChanged, this, &MenuWindow::updateGeometry); updateGeometry(); } }