fix(src/windows): 添加监听屏幕尺寸变化

This commit is contained in:
youdiansaodongxi 2024-07-25 10:50:50 +08:00
parent 685ece3b0c
commit 0028840607
1 changed files with 9 additions and 3 deletions

View File

@ -78,7 +78,7 @@ void WindowHelper::setRegion(QWindow *window, qreal x, qreal y, qreal w, qreal h
WindowGeometryHelper::WindowGeometryHelper(QObject *parent) : QObject(parent) WindowGeometryHelper::WindowGeometryHelper(QObject *parent) : QObject(parent)
{ {
initPanelSetting(); initPanelSetting();
initScreenMonitor(); // initScreenMonitor();
updateGeometry(); updateGeometry();
connect(MenuSetting::instance(), &MenuSetting::changed, this, [this] (const QString& key) { connect(MenuSetting::instance(), &MenuSetting::changed, this, [this] (const QString& key) {
@ -483,8 +483,14 @@ void MenuWindow::activeMenuWindow(bool active)
} }
if (active) { if (active) {
this->setScreen(UkuiQuick::WindowProxy::currentScreen()); if (screen() != UkuiQuick::WindowProxy::currentScreen()) {
updateGeometry(); if (screen()) {
screen()->disconnect(this);
}
this->setScreen(UkuiQuick::WindowProxy::currentScreen());
connect(screen(), &QScreen::geometryChanged, this, &MenuWindow::updateGeometry);
updateGeometry();
}
} }
setVisible(active); setVisible(active);