X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsystraynotificationbackend.cpp;h=fa7b245780d9b97f39af86772b86aca7d396f3bc;hp=a45166593c461c6edd903dfa67ce9bf5336d4451;hb=138bb708911ef06fa37859fa51bca5f47125ccdd;hpb=2e9492d9ef198bde37da1f858602ab9624c0a12a diff --git a/src/qtui/systraynotificationbackend.cpp b/src/qtui/systraynotificationbackend.cpp index a4516659..fa7b2457 100644 --- a/src/qtui/systraynotificationbackend.cpp +++ b/src/qtui/systraynotificationbackend.cpp @@ -31,7 +31,8 @@ #include "systemtray.h" SystrayNotificationBackend::SystrayNotificationBackend(QObject *parent) - : AbstractNotificationBackend(parent) + : AbstractNotificationBackend(parent), + _blockActivation(false) { NotificationSettings notificationSettings; _showBubble = notificationSettings.value("Systray/ShowBubble", true).toBool(); @@ -40,9 +41,11 @@ SystrayNotificationBackend::SystrayNotificationBackend(QObject *parent) notificationSettings.notify("Systray/ShowBubble", this, SLOT(showBubbleChanged(const QVariant &))); notificationSettings.notify("Systray/Animate", this, SLOT(animateChanged(const QVariant &))); + connect(QtUi::mainWindow()->systemTray(), SIGNAL(messageClicked()), SLOT(notificationActivated())); connect(QtUi::mainWindow()->systemTray(), SIGNAL(activated(SystemTray::ActivationReason)), SLOT(notificationActivated(SystemTray::ActivationReason))); - connect(QtUi::mainWindow()->systemTray(), SIGNAL(messageClicked()), SLOT(notificationActivated())); + + QApplication::instance()->installEventFilter(this); } void SystrayNotificationBackend::notify(const Notification ¬ification) { @@ -91,10 +94,13 @@ void SystrayNotificationBackend::closeBubble() { } void SystrayNotificationBackend::notificationActivated() { - if(QtUi::mainWindow()->systemTray()->isAlerted() && !QtUi::mainWindow()->systemTray()->isActivationInhibited()) { - QtUi::mainWindow()->systemTray()->setInhibitActivation(); - uint id = _notifications.count()? _notifications.last().notificationId : 0; - emit activated(id); + if(!_blockActivation) { + if(QtUi::mainWindow()->systemTray()->isAlerted()) { + _blockActivation = true; // prevent double activation because both tray icon and bubble might send a signal + uint id = _notifications.count()? _notifications.last().notificationId : 0; + emit activated(id); + } else + GraphicalUi::toggleMainWidget(); } } @@ -104,6 +110,14 @@ void SystrayNotificationBackend::notificationActivated(SystemTray::ActivationRea } } +// moving the mouse or releasing the button means that we're not dealing with a double activation +bool SystrayNotificationBackend::eventFilter(QObject *obj, QEvent *event) { + if(event->type() == QEvent::MouseMove || event->type() == QEvent::MouseButtonRelease) { + _blockActivation = false; + } + return AbstractNotificationBackend::eventFilter(obj, event); +} + void SystrayNotificationBackend::showBubbleChanged(const QVariant &v) { _showBubble = v.toBool(); }