mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
IconGraphic::isCounterNeeded helper for Linux tray
This commit is contained in:
parent
e60d501e4a
commit
c672f105d3
1 changed files with 9 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue