From c672f105d3cbf1344571250af625f6e20e2e333a Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 23 Feb 2025 06:53:21 +0400 Subject: [PATCH] IconGraphic::isCounterNeeded helper for Linux tray --- Telegram/SourceFiles/platform/linux/tray_linux.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/tray_linux.cpp b/Telegram/SourceFiles/platform/linux/tray_linux.cpp index 3680f3751..5e1771871 100644 --- a/Telegram/SourceFiles/platform/linux/tray_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/tray_linux.cpp @@ -58,6 +58,7 @@ private: }; [[nodiscard]] QIcon systemIcon() const; + [[nodiscard]] bool isCounterNeeded(const State &state) const; [[nodiscard]] int counterSlice(int counter) const; [[nodiscard]] QSize dprSize(const QImage &image) const; @@ -103,6 +104,12 @@ QIcon IconGraphic::systemIcon() const { return QIcon(); } +bool IconGraphic::isCounterNeeded(const State &state) const { + return state.systemIcon.name() != PanelIconName( + state.counter, + state.muted); +} + int IconGraphic::counterSlice(int counter) const { return (counter >= 1000) ? (1000 + (counter % 100)) @@ -125,7 +132,7 @@ bool IconGraphic::isRefreshNeeded() const { return _trayIcon.isNull() || _new.iconThemeName != _current.iconThemeName || _new.systemIcon.name() != _current.systemIcon.name() - || (_new.systemIcon.name() != PanelIconName(_new.counter, _new.muted) + || (isCounterNeeded(_new) ? _new.muted != _current.muted || counterSlice(_new.counter) != counterSlice( _current.counter) @@ -141,9 +148,7 @@ QIcon IconGraphic::trayIcon() { _current = _new; }); - if (_new.systemIcon.name() == PanelIconName( - _new.counter, - _new.muted)) { + if (!isCounterNeeded(_new)) { _trayIcon = _new.systemIcon; return _trayIcon; }