X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Flegacysystemtray.cpp;h=87ff3dfe880628dd4702e2a61c80766c2f0fbedc;hb=cc9f5099567634673f181aa49ae0b5d19bf93f7c;hp=7513bc812bc3eba672101355f9c9c21f6cbbd0b3;hpb=ea5b220601473213689ef9bad6611ec74b776aa5;p=quassel.git diff --git a/src/qtui/legacysystemtray.cpp b/src/qtui/legacysystemtray.cpp index 7513bc81..87ff3dfe 100644 --- a/src/qtui/legacysystemtray.cpp +++ b/src/qtui/legacysystemtray.cpp @@ -20,25 +20,17 @@ #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) + , _trayIcon{new QSystemTrayIcon(associatedWidget())} { -#ifndef HAVE_KDE4 - _trayIcon = new QSystemTrayIcon(associatedWidget()); -#else - _trayIcon = new KSystemTrayIcon(associatedWidget()); - // We don't want to trigger a minimize if a highlight is pending, so we brutally remove the internal connection for that - disconnect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - _trayIcon, SLOT(activateOrHide(QSystemTrayIcon::ActivationReason))); -#endif + #ifndef Q_OS_MAC connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(onActivated(QSystemTrayIcon::ActivationReason))); @@ -53,13 +45,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())); connect(this, SIGNAL(iconsChanged()), this, SLOT(updateIcon())); - - _blinkTimer.setInterval(750); - _blinkTimer.setSingleShot(false); - connect(&_blinkTimer, SIGNAL(timeout()), SLOT(onBlinkTimeout())); + connect(this, SIGNAL(currentIconNameChanged()), this, SLOT(updateIcon())); updateIcon(); updateToolTip(); @@ -93,28 +81,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))); } @@ -134,13 +104,6 @@ void LegacySystemTray::updateToolTip() } -void LegacySystemTray::onBlinkTimeout() -{ - _blinkState = !_blinkState; - updateIcon(); -} - - void LegacySystemTray::onActivated(QSystemTrayIcon::ActivationReason reason) { activate((SystemTray::ActivationReason)reason);