From 64846357b59c7b39a5164b36d8599dc057cf11c5 Mon Sep 17 00:00:00 2001 From: reionwong Date: Sat, 26 Mar 2022 21:19:53 +0800 Subject: [PATCH] fix: multi screen position --- src/statusbar.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/statusbar.cpp b/src/statusbar.cpp index 0576099..5837253 100644 --- a/src/statusbar.cpp +++ b/src/statusbar.cpp @@ -65,11 +65,11 @@ StatusBar::StatusBar(QQuickView *parent) connect(m_acticity, &Activity::launchPadChanged, this, &StatusBar::initState); - connect(qApp->primaryScreen(), &QScreen::virtualGeometryChanged, this, &StatusBar::updateGeometry); - connect(qApp->primaryScreen(), &QScreen::geometryChanged, this, &StatusBar::updateGeometry); + connect(screen(), &QScreen::virtualGeometryChanged, this, &StatusBar::updateGeometry); + connect(screen(), &QScreen::geometryChanged, this, &StatusBar::updateGeometry); // Always show on the main screen - connect(qApp, &QApplication::primaryScreenChanged, this, &StatusBar::onPrimaryScreenChanged); + connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &StatusBar::onPrimaryScreenChanged); } QRect StatusBar::screenRect() @@ -145,6 +145,11 @@ void StatusBar::initState() void StatusBar::onPrimaryScreenChanged(QScreen *screen) { + disconnect(this->screen()); + setScreen(screen); updateGeometry(); + + connect(screen, &QScreen::virtualGeometryChanged, this, &StatusBar::updateGeometry); + connect(screen, &QScreen::geometryChanged, this, &StatusBar::updateGeometry); }