From 2675b5df3b995ca0f2a79566ee0a6c8a6fd99c74 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 14 May 2023 09:21:40 +0400 Subject: [PATCH] Use QGuiApplication::setBadgeNumber API since Qt 6.6 on Linux --- .../platform/linux/main_window_linux.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index ac9b09201..0598d9fbd 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -172,14 +172,6 @@ void ForceDisabled(QAction *action, bool disabled) { } } -uint djbStringHash(const std::string &string) { - uint hash = 5381; - for (const auto &curChar : string) { - hash = (hash << 5) + hash + curChar; - } - return hash; -} - } // namespace MainWindow::MainWindow(not_null controller) @@ -238,6 +230,17 @@ void MainWindow::updateWindowIcon() { } void MainWindow::updateUnityCounter() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + qApp->setBadgeNumber(Core::App().unreadBadge()); +#else // Qt >= 6.6.0 + static const auto djbStringHash = [](const std::string &string) { + uint hash = 5381; + for (const auto &curChar : string) { + hash = (hash << 5) + hash + curChar; + } + return hash; + }; + const auto launcherUrl = Glib::ustring( "application://" + QGuiApplication::desktopFileName().toStdString()); @@ -273,6 +276,7 @@ void MainWindow::updateUnityCounter() { })); } catch (...) { } +#endif // Qt < 6.6.0 } void MainWindow::createGlobalMenu() {