mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Update icons when icon theme on Linux changes
This commit is contained in:
parent
6aef6d7f4e
commit
2ce9e610fa
4 changed files with 17 additions and 9 deletions
|
@ -100,6 +100,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtCore/QMimeDatabase>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtGui/QWindow>
|
||||
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -179,6 +179,12 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
|||
}
|
||||
|
||||
void MainWindow::initHook() {
|
||||
events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
if (e->type() == QEvent::ThemeChange) {
|
||||
updateWindowIcon();
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
base::install_event_filter(windowHandle(), [=](not_null<QEvent*> e) {
|
||||
if (e->type() == QEvent::Expose) {
|
||||
auto ee = static_cast<QExposeEvent*>(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() {
|
||||
|
|
|
@ -60,9 +60,6 @@ private:
|
|||
QAction *psMonospace = nullptr;
|
||||
QAction *psClearFormat = nullptr;
|
||||
|
||||
QIcon _icon;
|
||||
bool _usingSupportIcon = false;
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] inline int32 ScreenNameChecksum(const QString &name) {
|
||||
|
|
Loading…
Add table
Reference in a new issue