From d4a32756e522d8f87cd207fbedd87c882230fe1d Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sun, 2 Jan 2011 01:13:14 +0100 Subject: [PATCH] mark selected backend in tray menue --- src/plugins/snarlnetwork/snarlnetwork.cpp | 1 + src/snorenotify.cpp | 3 ++- src/trayicon.cpp | 10 ++++++++++ src/trayicon.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/snarlnetwork/snarlnetwork.cpp b/src/plugins/snarlnetwork/snarlnetwork.cpp index 28d962b..541aecd 100644 --- a/src/plugins/snarlnetwork/snarlnetwork.cpp +++ b/src/plugins/snarlnetwork/snarlnetwork.cpp @@ -95,6 +95,7 @@ void SnarlNetworkFrontend::handleMessages(){ } void SnarlNetworkFrontend::callback(const SnarlNotification &sn,QString msg){ + qDebug()<<"SnarlNetwork callback:"<id(); notifications.remove(sn.notification->id()); if(sn.clientSocket!=NULL&&!msg.isEmpty()){ msg+=QString::number(sn.notification->id()); diff --git a/src/snorenotify.cpp b/src/snorenotify.cpp index 4cf170d..8a5c67d 100644 --- a/src/snorenotify.cpp +++ b/src/snorenotify.cpp @@ -52,9 +52,10 @@ SnoreNotify::SnoreNotify() } + load(); + _trayIcon->initConextMenu(_snore); - load(); connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(exit())); } diff --git a/src/trayicon.cpp b/src/trayicon.cpp index 3804a86..7a29894 100644 --- a/src/trayicon.cpp +++ b/src/trayicon.cpp @@ -36,6 +36,10 @@ void TrayIcon::initConextMenu(SnoreServer *snore){ foreach(Notification_Backend *back,_snore->primaryNotificationBackends()){ QAction *b= new QAction(back->name(),this); connect(b,SIGNAL(triggered()),this,SLOT(setPrimaryBackend())); + b->setCheckable(true); + if(back->name() == _snore->primaryNotificationBackend()->name()) + b->setChecked(true); + _backendActions.append(b); _trayMenu->addAction(b); } _trayMenu->addSeparator(); @@ -56,6 +60,12 @@ QSystemTrayIcon* TrayIcon::trayIcon(){ void TrayIcon::setPrimaryBackend(){ QAction *a= dynamic_cast(sender()); _snore->setPrimaryNotificationBackend(_snore->primaryNotificationBackends().value(a->text())); + + foreach(QAction *action,_backendActions){ + action->setChecked(false); + } + a->setChecked(true); + } diff --git a/src/trayicon.h b/src/trayicon.h index 49d0550..7ea39df 100644 --- a/src/trayicon.h +++ b/src/trayicon.h @@ -31,6 +31,7 @@ public: private: class QSystemTrayIcon *_trayIcon; class QMenu *_trayMenu; + class QList _backendActions; class SnoreServer *_snore;