From e4259124908c268f41d3521b700cf5af10f205c5 Mon Sep 17 00:00:00 2001 From: ilya-fedin Date: Wed, 6 May 2020 22:55:57 +0400 Subject: [PATCH] Fixes for window icon (#38) * Give priority for custom icon on linux * Add support for icon from file, as in tray --- Telegram/SourceFiles/window/main_window.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 5e0a313d8..b109bc10e 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -119,20 +119,37 @@ void ConvertIconToBlack(QImage &image) { } QIcon CreateOfficialIcon(Main::Account *account) { - auto image = Core::IsAppLaunched() ? Core::App().logo(cCustomAppIcon()) : LoadLogo(cCustomAppIcon()); + const auto customIcon = QImage(cWorkingDir() + "tdata/icon.png"); + + auto image = customIcon.isNull() + ? Core::IsAppLaunched() + ? Core::App().logo(cCustomAppIcon()) + : LoadLogo(cCustomAppIcon()) + : customIcon; + if (account && account->sessionExists() && account->session().supportMode()) { ConvertIconToBlack(image); } + return QIcon(App::pixmapFromImageInPlace(std::move(image))); } QIcon CreateIcon(Main::Account *account) { auto result = CreateOfficialIcon(account); + #ifdef Q_OS_LINUX - return QIcon::fromTheme(Platform::GetIconName(), result); + if ( + (!account + || !account->sessionExists() + || !account->session().supportMode()) + && cCustomAppIcon() == 0 + && !QFileInfo::exists(cWorkingDir() + "tdata/icon.png")) { + return QIcon::fromTheme(Platform::GetIconName(), result); + } #endif + return result; }