Fall back to primary screen on QT version < 5.10 instead of icon position detection
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Thu, 2 Jan 2020 07:56:07 +0000 (08:56 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Thu, 2 Jan 2020 07:56:07 +0000 (08:56 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/systray.cpp

index 520450dd98297e7e1cff460b35b108f625120b09..642b49453be356083b8ce39162aebdd9e0e34878 100644 (file)
@@ -101,7 +101,12 @@ void Systray::setToolTip(const QString &tip)
 
 int Systray::calcTrayWindowX()
 {
-    QScreen* trayScreen = QGuiApplication::screenAt(this->geometry().topRight());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+    QScreen *trayScreen = QGuiApplication::screenAt(this->geometry().topRight());
+#else
+    QScreen *trayScreen = QGuiApplication::primaryScreen();
+#endif
+
     // get coordinates from top center point of tray icon
     int trayIconTopCenterX = (this->geometry().topRight() - ((this->geometry().topRight() - this->geometry().topLeft()) * 0.5)).x();
     int trayIconTopCenterY = (this->geometry().topRight() - ((this->geometry().topRight() - this->geometry().topLeft()) * 0.5)).y();
@@ -129,7 +134,12 @@ int Systray::calcTrayWindowX()
 }
 int Systray::calcTrayWindowY()
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
     QScreen *trayScreen = QGuiApplication::screenAt(this->geometry().topRight());
+#else
+    QScreen *trayScreen = QGuiApplication::primaryScreen();
+#endif
+    
     // get coordinates from top center point of tray icon
     int trayIconTopCenterX = (this->geometry().topRight() - ((this->geometry().topRight() - this->geometry().topLeft()) * 0.5)).x();
     int trayIconTopCenterY = (this->geometry().topRight() - ((this->geometry().topRight() - this->geometry().topLeft()) * 0.5)).y();