Fix tray icon counter on Linux.

Fixes #5525.
This commit is contained in:
John Preston 2019-01-10 17:55:56 +04:00
parent 2773a675d0
commit 3e7a688811
2 changed files with 5 additions and 1 deletions

View File

@ -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();

View File

@ -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;