1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
index d076b90f3..7c40ecb90 100644
--- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp
@@ -42,6 +42,7 @@ int32 _trayIconSize = 22;
bool _trayIconMuted = true;
int32 _trayIconCount = 0;
QImage _trayIconImageBack, _trayIconImage;
+QString _trayIconThemeName, _trayIconName;
QString _desktopFile;
QString _dbusPath = "/";
@@ -83,17 +84,32 @@ QImage _trayIconImageGen() {
const auto counterSlice = (counter >= 1000)
? (1000 + (counter % 100))
: counter;
- if (_trayIconImage.isNull() || _trayIconImage.width() != _trayIconSize || muted != _trayIconMuted || counterSlice != _trayIconCount) {
- if (_trayIconImageBack.isNull() || _trayIconImageBack.width() != _trayIconSize) {
- _trayIconImageBack = Core::App().logo().scaled(_trayIconSize, _trayIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+
+ QString iconThemeName = QIcon::themeName();
+ QString iconName = (counter > 0) ? (muted ? "telegram-mute-panel" : "telegram-attention-panel")
+ : "telegram-panel";
+
+ if (_trayIconImage.isNull() || _trayIconImage.width() != _trayIconSize ||
+ iconThemeName != _trayIconThemeName || iconName != _trayIconName ||
+ muted != _trayIconMuted || counterSlice != _trayIconCount) {
+ if (_trayIconImageBack.isNull() || _trayIconImageBack.width() != _trayIconSize ||
+ iconThemeName != _trayIconThemeName || iconName != _trayIconName) {
+ _trayIconImageBack = QIcon::fromTheme(iconName, QIcon::fromTheme("kotatogram", QIcon(QPixmap::fromImage(Core::App().logo()))))
+ .pixmap(256, 256).toImage();
+ _trayIconImageBack = _trayIconImageBack.scaled(_trayIconSize, _trayIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
_trayIconImageBack = _trayIconImageBack.convertToFormat(QImage::Format_ARGB32);
}
+
_trayIconImage = _trayIconImageBack;
_trayIconMuted = muted;
_trayIconCount = counterSlice;
+ _trayIconThemeName = iconThemeName;
+ _trayIconName = iconName;
+
if (counter > 0) {
QPainter p(&_trayIconImage);
int32 layerSize = -16;
+
if (_trayIconSize >= 48) {
layerSize = -32;
} else if (_trayIconSize >= 36) {
@@ -101,12 +117,15 @@ QImage _trayIconImageGen() {
} else if (_trayIconSize >= 32) {
layerSize = -20;
}
+
auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg);
auto &fg = st::trayCounterFg;
auto layer = App::wnd()->iconWithCounter(layerSize, counter, bg, fg, false);
+
p.drawImage(_trayIconImage.width() - layer.width() - 1, _trayIconImage.height() - layer.height() - 1, layer);
}
}
+
return _trayIconImage;
}
@@ -115,7 +134,11 @@ QString _trayIconImageFile() {
const auto muted = Core::App().unreadBadgeMuted();
const auto counterSlice = (counter >= 1000) ? (1000 + (counter % 100)) : counter;
- QString name = cWorkingDir() + qsl("tdata/ticons/icon%1_%2_%3.png").arg(muted ? "mute" : "").arg(_trayIconSize).arg(counterSlice);
+ QString iconThemeName = QIcon::themeName();
+
+ QString name = cWorkingDir() + qsl("tdata/ticons/icon%1_%2_%3_%4.png").arg(muted ? "mute" : "").arg(iconThemeName)
+ .arg(_trayIconSize).arg(counterSlice);
+
QFileInfo info(name);
if (info.exists()) return name;
|