diff options
Diffstat (limited to 'system-tray-icon.patch')
-rw-r--r-- | system-tray-icon.patch | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/system-tray-icon.patch b/system-tray-icon.patch new file mode 100644 index 000000000000..51a8e370d0ad --- /dev/null +++ b/system-tray-icon.patch @@ -0,0 +1,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; + |