mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-20 02:00:55 +07:00
fixed update icon linux
This commit is contained in:
@@ -32,12 +32,15 @@ void LinuxTrayIconBackend::show()
|
||||
|
||||
void LinuxTrayIconBackend::applyVisual(const TrayIconVisual &visual)
|
||||
{
|
||||
const QIcon icon = buildTrayIcon(visual.connectionState, visual.darkTheme);
|
||||
|
||||
// Some tray implementations cache the first icon; clear before applying an update.
|
||||
if (m_trayIcon.isVisible()) {
|
||||
m_trayIcon.setIcon(QIcon());
|
||||
if (m_hasLastVisual && visual.connectionState == m_lastState && visual.darkTheme == m_lastDarkTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_lastState = visual.connectionState;
|
||||
m_lastDarkTheme = visual.darkTheme;
|
||||
m_hasLastVisual = true;
|
||||
|
||||
const QIcon icon = buildTrayIcon(visual.connectionState, visual.darkTheme);
|
||||
m_trayIcon.setIcon(icon);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <QColor>
|
||||
#include <QIcon>
|
||||
#include <QString>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
class LinuxTrayIconBackend final : public TrayIconBackend
|
||||
@@ -24,6 +25,9 @@ private:
|
||||
QIcon buildTrayIcon(Vpn::ConnectionState state, bool darkTheme) const;
|
||||
|
||||
QSystemTrayIcon m_trayIcon;
|
||||
Vpn::ConnectionState m_lastState = Vpn::ConnectionState::Unknown;
|
||||
bool m_lastDarkTheme = false;
|
||||
bool m_hasLastVisual = false;
|
||||
};
|
||||
|
||||
#endif // LINUXTRAYICONBACKEND_H
|
||||
|
||||
Reference in New Issue
Block a user