diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 8d8e7fc2f..ede17c597 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -100,6 +100,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include #include +#include namespace Core { namespace { @@ -676,6 +677,13 @@ bool Application::eventFilter(QObject *object, QEvent *e) { } } } break; + + case QEvent::ThemeChange: { + if (Platform::IsLinux() && object == QGuiApplication::allWindows().first()) { + Core::App().refreshApplicationIcon(); + Core::App().tray().updateIconCounters(); + } + } break; } return QObject::eventFilter(object, e); diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index fb5bfb546..f19623e48 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -400,6 +400,8 @@ OverlayWidget::OverlayWidget() e->ignore(); close(); return base::EventFilterResult::Cancel; + } else if (type == QEvent::ThemeChange && Platform::IsLinux()) { + _window->setWindowIcon(Window::CreateIcon(_session)); } return base::EventFilterResult::Continue; }); diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 0598d9fbd..98c6ff40a 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -179,6 +179,12 @@ MainWindow::MainWindow(not_null controller) } void MainWindow::initHook() { + events() | rpl::start_with_next([=](not_null e) { + if (e->type() == QEvent::ThemeChange) { + updateWindowIcon(); + } + }, lifetime()); + base::install_event_filter(windowHandle(), [=](not_null e) { if (e->type() == QEvent::Expose) { auto ee = static_cast(e.get()); @@ -221,12 +227,7 @@ void MainWindow::updateWindowIcon() { const auto session = sessionController() ? &sessionController()->session() : nullptr; - const auto supportIcon = session && session->supportMode(); - if (supportIcon != _usingSupportIcon || _icon.isNull()) { - _icon = Window::CreateIcon(session); - _usingSupportIcon = supportIcon; - } - setWindowIcon(_icon); + setWindowIcon(Window::CreateIcon(session)); } void MainWindow::updateUnityCounter() { diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h index 3f074db1f..467f690b7 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.h +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h @@ -60,9 +60,6 @@ private: QAction *psMonospace = nullptr; QAction *psClearFormat = nullptr; - QIcon _icon; - bool _usingSupportIcon = false; - }; [[nodiscard]] inline int32 ScreenNameChecksum(const QString &name) {