From 3e7a688811e293e837497512a5d71ab839635f51 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 10 Jan 2019 17:55:56 +0400 Subject: [PATCH] Fix tray icon counter on Linux. Fixes #5525. --- Telegram/SourceFiles/mainwindow.cpp | 2 ++ Telegram/SourceFiles/platform/linux/main_window_linux.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 6c06d76168..c29f3cdf10 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -836,6 +836,8 @@ QImage MainWindow::iconWithCounter(int size, int count, style::color bg, style:: if (layer) { if (size != 16 && size != 20 && size != 24) size = 32; + // platform/linux/main_window_linux depends on count used the same + // way for all the same (count % 1000) values. QString cnt = (count < 1000) ? QString("%1").arg(count) : QString("..%1").arg(count % 100, 2, 10, QChar('0')); QImage result(size, size, QImage::Format_ARGB32); int32 cntSize = cnt.size(); diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index e4dbc47ef0..f3a504136c 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -92,6 +92,8 @@ QImage _trayIconImageGen() { } } _trayIconImage = _trayIconImageBack; + _trayIconMuted = muted; + _trayIconCount = counterSlice; if (counter > 0) { QPainter p(&_trayIconImage); int32 layerSize = -16; @@ -116,7 +118,7 @@ QString _trayIconImageFile() { const auto muted = Messenger::Instance().unreadBadgeMuted(); const auto counterSlice = (counter >= 1000) ? (1000 + (counter % 100)) : counter; - QString name = cWorkingDir() + qsl("tdata/ticons/ico%1_%2_%3.png").arg(muted ? "mute" : "").arg(_trayIconSize).arg(counterSlice); + QString name = cWorkingDir() + qsl("tdata/ticons/icon%1_%2_%3.png").arg(muted ? "mute" : "").arg(_trayIconSize).arg(counterSlice); QFileInfo info(name); if (info.exists()) return name;