From d4b334636e70263f3e8344102dfb2dd8196c548b Mon Sep 17 00:00:00 2001 From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Thu, 2 Jan 2020 08:56:07 +0100 Subject: [PATCH] Fall back to primary screen on QT version < 5.10 instead of icon position detection Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> --- src/gui/systray.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 520450dd9..642b49453 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -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(); -- 2.30.2