mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 <QtCore/QMimeDatabase>
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtGui/QScreen>
|
#include <QtGui/QScreen>
|
||||||
|
#include <QtGui/QWindow>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -676,6 +677,13 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case QEvent::ThemeChange: {
|
||||||
|
if (Platform::IsLinux() && object == QGuiApplication::allWindows().first()) {
|
||||||
|
Core::App().refreshApplicationIcon();
|
||||||
|
Core::App().tray().updateIconCounters();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::eventFilter(object, e);
|
return QObject::eventFilter(object, e);
|
||||||
|
|
|
@ -400,6 +400,8 @@ OverlayWidget::OverlayWidget()
|
||||||
e->ignore();
|
e->ignore();
|
||||||
close();
|
close();
|
||||||
return base::EventFilterResult::Cancel;
|
return base::EventFilterResult::Cancel;
|
||||||
|
} else if (type == QEvent::ThemeChange && Platform::IsLinux()) {
|
||||||
|
_window->setWindowIcon(Window::CreateIcon(_session));
|
||||||
}
|
}
|
||||||
return base::EventFilterResult::Continue;
|
return base::EventFilterResult::Continue;
|
||||||
});
|
});
|
||||||
|
|
|
@ -179,6 +179,12 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initHook() {
|
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) {
|
base::install_event_filter(windowHandle(), [=](not_null<QEvent*> e) {
|
||||||
if (e->type() == QEvent::Expose) {
|
if (e->type() == QEvent::Expose) {
|
||||||
auto ee = static_cast<QExposeEvent*>(e.get());
|
auto ee = static_cast<QExposeEvent*>(e.get());
|
||||||
|
@ -221,12 +227,7 @@ void MainWindow::updateWindowIcon() {
|
||||||
const auto session = sessionController()
|
const auto session = sessionController()
|
||||||
? &sessionController()->session()
|
? &sessionController()->session()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto supportIcon = session && session->supportMode();
|
setWindowIcon(Window::CreateIcon(session));
|
||||||
if (supportIcon != _usingSupportIcon || _icon.isNull()) {
|
|
||||||
_icon = Window::CreateIcon(session);
|
|
||||||
_usingSupportIcon = supportIcon;
|
|
||||||
}
|
|
||||||
setWindowIcon(_icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateUnityCounter() {
|
void MainWindow::updateUnityCounter() {
|
||||||
|
|
|
@ -60,9 +60,6 @@ private:
|
||||||
QAction *psMonospace = nullptr;
|
QAction *psMonospace = nullptr;
|
||||||
QAction *psClearFormat = nullptr;
|
QAction *psClearFormat = nullptr;
|
||||||
|
|
||||||
QIcon _icon;
|
|
||||||
bool _usingSupportIcon = false;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] inline int32 ScreenNameChecksum(const QString &name) {
|
[[nodiscard]] inline int32 ScreenNameChecksum(const QString &name) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue