UI: Fix tray icon animation switching

This commit is contained in:
Nodir Temirkhodjaev 2023-12-29 20:16:56 +03:00
parent f7ab740a50
commit 1b6283e3be
2 changed files with 31 additions and 10 deletions

View File

@ -541,19 +541,13 @@ void TrayIcon::sendAlertMessage()
void TrayIcon::updateAlertTimer()
{
if (!iniUser()->trayAnimateAlert())
if (!iniUser()->trayAnimateAlert()) {
removeAlertTimer();
return;
if (!m_alertTimer) {
m_alertTimer = new QTimer(this);
m_alertTimer->setInterval(1000);
connect(m_alertTimer, &QTimer::timeout, this, [&] {
m_animatedAlert = !m_animatedAlert;
updateTrayIconShape();
});
}
setupAlertTimer();
m_animatedAlert = m_alerted;
if (m_alerted) {
@ -563,6 +557,29 @@ void TrayIcon::updateAlertTimer()
}
}
void TrayIcon::setupAlertTimer()
{
if (m_alertTimer)
return;
m_alertTimer = new QTimer(this);
m_alertTimer->setInterval(1000);
connect(m_alertTimer, &QTimer::timeout, this, [&] {
m_animatedAlert = !m_animatedAlert;
updateTrayIconShape();
});
}
void TrayIcon::removeAlertTimer()
{
if (!m_alertTimer)
return;
delete m_alertTimer;
m_alertTimer = nullptr;
}
void TrayIcon::updateTrayIconShape()
{
QString mainIconPath;

View File

@ -105,6 +105,10 @@ private:
void sendAlertMessage();
void updateAlertTimer();
void setupAlertTimer();
void removeAlertTimer();
void updateTrayIconShape();
void addHotKey(QAction *action, const QString &shortcutText);