X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Flegacysystemtray.cpp;h=40cd2ed8f756fd6567420f9f440896675263b074;hp=8e7d2b726183f0fc66c823ab5e8dad1100726cb9;hb=54ebc1bf00f4f9a8376629925329f0e72be04662;hpb=39dffd095bb5dbca49199d2173438c7f90c4e6fa diff --git a/src/qtui/legacysystemtray.cpp b/src/qtui/legacysystemtray.cpp index 8e7d2b72..40cd2ed8 100644 --- a/src/qtui/legacysystemtray.cpp +++ b/src/qtui/legacysystemtray.cpp @@ -20,16 +20,14 @@ #ifndef QT_NO_SYSTEMTRAYICON -#include - #include "legacysystemtray.h" + +#include "icon.h" #include "mainwin.h" #include "qtui.h" LegacySystemTray::LegacySystemTray(QWidget *parent) - : SystemTray(parent), - _blinkState(false), - _lastMessageId(0) + : SystemTray(parent) { #ifndef HAVE_KDE4 _trayIcon = new QSystemTrayIcon(associatedWidget()); @@ -53,12 +51,9 @@ LegacySystemTray::LegacySystemTray(QWidget *parent) connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool))); connect(this, SIGNAL(modeChanged(Mode)), this, SLOT(onModeChanged(Mode))); - connect(this, SIGNAL(stateChanged(State)), this, SLOT(onStateChanged(State))); connect(this, SIGNAL(toolTipChanged(QString, QString)), SLOT(updateToolTip())); - - _blinkTimer.setInterval(750); - _blinkTimer.setSingleShot(false); - connect(&_blinkTimer, SIGNAL(timeout()), SLOT(onBlinkTimeout())); + connect(this, SIGNAL(iconsChanged()), this, SLOT(updateIcon())); + connect(this, SIGNAL(currentIconNameChanged()), this, SLOT(updateIcon())); updateIcon(); updateToolTip(); @@ -92,28 +87,10 @@ void LegacySystemTray::onModeChanged(Mode mode) } -void LegacySystemTray::onStateChanged(State state) -{ - if (state == NeedsAttention && animationEnabled()) - _blinkTimer.start(); - else { - _blinkTimer.stop(); - _blinkState = false; - } - updateIcon(); -} - - void LegacySystemTray::updateIcon() { - QString icon; - if (state() == State::NeedsAttention && !_blinkState) { - icon = iconName(State::Active); - } - else { - icon = iconName(state()); - } - _trayIcon->setIcon(QIcon::fromTheme(icon, QIcon{QString{":/icons/hicolor/24x24/status/%1.svg"}.arg(icon)})); + QString iconName = (state() == NeedsAttention) ? currentAttentionIconName() : currentIconName(); + _trayIcon->setIcon(icon::get(iconName, QString{":/icons/hicolor/24x24/status/%1.svg"}.arg(iconName))); } @@ -133,13 +110,6 @@ void LegacySystemTray::updateToolTip() } -void LegacySystemTray::onBlinkTimeout() -{ - _blinkState = !_blinkState; - updateIcon(); -} - - void LegacySystemTray::onActivated(QSystemTrayIcon::ActivationReason reason) { activate((SystemTray::ActivationReason)reason);