X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Flegacysystemtray.cpp;h=9176dbd769f2951c309b91f908f7778e69e5619e;hp=3368b299bf020b4c26c3149315f67db9401143dd;hb=f266d6afd50d03b21b136b6a34454c49d55878cf;hpb=42d2c195b272f42fdcad7f44b9db4ae4f708bdf6
diff --git a/src/qtui/legacysystemtray.cpp b/src/qtui/legacysystemtray.cpp
index 3368b299..9176dbd7 100644
--- a/src/qtui/legacysystemtray.cpp
+++ b/src/qtui/legacysystemtray.cpp
@@ -21,12 +21,14 @@
#ifndef QT_NO_SYSTEMTRAYICON
#include "legacysystemtray.h"
+#include "mainwin.h"
#include "qtui.h"
LegacySystemTray::LegacySystemTray(QWidget *parent)
: SystemTray(parent),
_blinkState(false),
- _isVisible(true)
+ _isVisible(true),
+ _lastMessageId(0)
{
#ifndef HAVE_KDE
_trayIcon = new QSystemTrayIcon(associatedWidget());
@@ -41,7 +43,7 @@ LegacySystemTray::LegacySystemTray(QWidget *parent)
SLOT(on_activated(QSystemTrayIcon::ActivationReason)));
#endif
connect(_trayIcon, SIGNAL(messageClicked()),
- SIGNAL(messageClicked()));
+ SLOT(on_messageClicked()));
_blinkTimer.setInterval(500);
_blinkTimer.setSingleShot(false);
@@ -62,9 +64,16 @@ void LegacySystemTray::init() {
void LegacySystemTray::syncLegacyIcon() {
_trayIcon->setIcon(stateIcon());
+#if defined Q_WS_MAC || defined Q_WS_WIN
+ QString tooltip = QString("%1").arg(toolTipTitle());
+ if(!toolTipSubTitle().isEmpty())
+ tooltip += QString("\n%1").arg(toolTipSubTitle());
+#else
QString tooltip = QString("%1").arg(toolTipTitle());
if(!toolTipSubTitle().isEmpty())
tooltip += QString("
%1").arg(toolTipSubTitle());
+#endif
+
_trayIcon->setToolTip(tooltip);
}
@@ -104,7 +113,7 @@ void LegacySystemTray::setState(State state_) {
State oldstate = state();
SystemTray::setState(state_);
if(oldstate != state()) {
- if(state() == NeedsAttention && mode() == Legacy)
+ if(state() == NeedsAttention && mode() == Legacy && animationEnabled())
_blinkTimer.start();
else {
_blinkTimer.stop();
@@ -130,8 +139,24 @@ void LegacySystemTray::on_activated(QSystemTrayIcon::ActivationReason reason) {
activate((SystemTray::ActivationReason)reason);
}
-void LegacySystemTray::showMessage(const QString &title, const QString &message, SystemTray::MessageIcon icon, int millisecondsTimeoutHint) {
- _trayIcon->showMessage(title, message, (QSystemTrayIcon::MessageIcon)icon, millisecondsTimeoutHint);
+void LegacySystemTray::on_messageClicked() {
+ emit messageClicked(_lastMessageId);
+}
+
+void LegacySystemTray::showMessage(const QString &title, const QString &message, SystemTray::MessageIcon icon, int msTimeout, uint id) {
+ // fancy stuff later: show messages in order
+ // for now, we just show the last message
+ _lastMessageId = id;
+ _trayIcon->showMessage(title, message, (QSystemTrayIcon::MessageIcon)icon, msTimeout);
+}
+
+void LegacySystemTray::closeMessage(uint notificationId) {
+ Q_UNUSED(notificationId)
+
+ // there really seems to be no sane way to close the bubble... :(
+#ifdef Q_WS_X11
+ showMessage("", "", NoIcon, 1);
+#endif
}
#endif /* QT_NO_SYSTEMTRAYICON */