From 9d6e5f2a5bcba1f10d3727de2dcb4d341ed3803e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 10 Nov 2020 03:09:16 +0400 Subject: [PATCH] Adapt linux tray icon implementation to the new QIcon::pixmap behavior More info: https://codereview.qt-project.org/c/qt/qtbase/+/314618 --- .../platform/linux/main_window_linux.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 9becbfffcb..a85bdbab0d 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -201,7 +201,7 @@ QIcon TrayIconGen(int counter, bool muted) { QIcon result; QIcon systemIcon; - const auto iconSizes = { + static const auto iconSizes = { 22, 24, 32, @@ -240,9 +240,12 @@ QIcon TrayIconGen(int counter, bool muted) { currentImageBack = Core::App().logo(); } - if (currentImageBack.size() != desiredSize) { + const auto currentImageBackSize = currentImageBack.size() + / currentImageBack.devicePixelRatio(); + + if (currentImageBackSize != desiredSize) { currentImageBack = currentImageBack.scaled( - desiredSize, + desiredSize * currentImageBack.devicePixelRatio(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } @@ -327,8 +330,7 @@ std::unique_ptr TrayIconFile( static const auto templateName = AppRuntimeDirectory() + kTrayIconFilename.utf16(); - const auto dpr = style::DevicePixelRatio(); - const auto desiredSize = QSize(22 * dpr, 22 * dpr); + static const auto desiredSize = QSize(22, 22); auto ret = std::make_unique( templateName, @@ -346,10 +348,11 @@ std::unique_ptr TrayIconFile( std::less<>(), &QSize::width); - icon - .pixmap(*biggestSize) + const auto iconPixmap = icon.pixmap(*biggestSize); + + iconPixmap .scaled( - desiredSize, + desiredSize * iconPixmap.devicePixelRatio(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) .save(ret.get());