/***************************************************************************
- * Copyright (C) 2005-2012 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) version 3. *
+ * This file is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Library General Public License (LGPL) *
+ * as published by the Free Software Foundation; either version 2 of the *
+ * License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef QT_NO_SYSTEMTRAYICON
_blinkState(false),
_lastMessageId(0)
{
-#ifndef HAVE_KDE
+#ifndef HAVE_KDE4
_trayIcon = new QSystemTrayIcon(associatedWidget());
#else
_trayIcon = new KSystemTrayIcon(associatedWidget());
disconnect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
_trayIcon, SLOT(activateOrHide(QSystemTrayIcon::ActivationReason)));
#endif
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
SLOT(on_activated(QSystemTrayIcon::ActivationReason)));
#endif
void LegacySystemTray::syncLegacyIcon()
{
- _trayIcon->setIcon(stateIcon());
+ updateIcon();
-#if defined Q_WS_MAC || defined Q_WS_WIN
+#if defined Q_OS_MAC || defined Q_OS_WIN
QString tooltip = QString("%1").arg(toolTipTitle());
if (!toolTipSubTitle().isEmpty())
tooltip += QString("\n%1").arg(toolTipSubTitle());
_blinkState = false;
}
}
- if (mode() == Legacy)
- _trayIcon->setIcon(stateIcon());
+ updateIcon();
}
-Icon LegacySystemTray::stateIcon() const
+void LegacySystemTray::updateIcon()
{
- if (mode() == Legacy && state() == NeedsAttention && !_blinkState)
- return SystemTray::stateIcon(Active);
- return SystemTray::stateIcon();
+ 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)}));
}
void LegacySystemTray::on_blinkTimeout()
{
_blinkState = !_blinkState;
- _trayIcon->setIcon(stateIcon());
+ updateIcon();
}