mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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]] QIcon systemIcon() const;
|
||||||
|
[[nodiscard]] bool isCounterNeeded(const State &state) const;
|
||||||
[[nodiscard]] int counterSlice(int counter) const;
|
[[nodiscard]] int counterSlice(int counter) const;
|
||||||
[[nodiscard]] QSize dprSize(const QImage &image) const;
|
[[nodiscard]] QSize dprSize(const QImage &image) const;
|
||||||
|
|
||||||
|
@ -103,6 +104,12 @@ QIcon IconGraphic::systemIcon() const {
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IconGraphic::isCounterNeeded(const State &state) const {
|
||||||
|
return state.systemIcon.name() != PanelIconName(
|
||||||
|
state.counter,
|
||||||
|
state.muted);
|
||||||
|
}
|
||||||
|
|
||||||
int IconGraphic::counterSlice(int counter) const {
|
int IconGraphic::counterSlice(int counter) const {
|
||||||
return (counter >= 1000)
|
return (counter >= 1000)
|
||||||
? (1000 + (counter % 100))
|
? (1000 + (counter % 100))
|
||||||
|
@ -125,7 +132,7 @@ bool IconGraphic::isRefreshNeeded() const {
|
||||||
return _trayIcon.isNull()
|
return _trayIcon.isNull()
|
||||||
|| _new.iconThemeName != _current.iconThemeName
|
|| _new.iconThemeName != _current.iconThemeName
|
||||||
|| _new.systemIcon.name() != _current.systemIcon.name()
|
|| _new.systemIcon.name() != _current.systemIcon.name()
|
||||||
|| (_new.systemIcon.name() != PanelIconName(_new.counter, _new.muted)
|
|| (isCounterNeeded(_new)
|
||||||
? _new.muted != _current.muted
|
? _new.muted != _current.muted
|
||||||
|| counterSlice(_new.counter) != counterSlice(
|
|| counterSlice(_new.counter) != counterSlice(
|
||||||
_current.counter)
|
_current.counter)
|
||||||
|
@ -141,9 +148,7 @@ QIcon IconGraphic::trayIcon() {
|
||||||
_current = _new;
|
_current = _new;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_new.systemIcon.name() == PanelIconName(
|
if (!isCounterNeeded(_new)) {
|
||||||
_new.counter,
|
|
||||||
_new.muted)) {
|
|
||||||
_trayIcon = _new.systemIcon;
|
_trayIcon = _new.systemIcon;
|
||||||
return _trayIcon;
|
return _trayIcon;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue