mark selected backend in tray menue
This commit is contained in:
parent
02667e4285
commit
d4a32756e5
|
@ -95,6 +95,7 @@ void SnarlNetworkFrontend::handleMessages(){
|
|||
}
|
||||
|
||||
void SnarlNetworkFrontend::callback(const SnarlNotification &sn,QString msg){
|
||||
qDebug()<<"SnarlNetwork callback:"<<sn.notification->id();
|
||||
notifications.remove(sn.notification->id());
|
||||
if(sn.clientSocket!=NULL&&!msg.isEmpty()){
|
||||
msg+=QString::number(sn.notification->id());
|
||||
|
|
|
@ -52,9 +52,10 @@ SnoreNotify::SnoreNotify()
|
|||
}
|
||||
|
||||
|
||||
load();
|
||||
|
||||
_trayIcon->initConextMenu(_snore);
|
||||
|
||||
load();
|
||||
connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(exit()));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<QAction*>(sender());
|
||||
_snore->setPrimaryNotificationBackend(_snore->primaryNotificationBackends().value(a->text()));
|
||||
|
||||
foreach(QAction *action,_backendActions){
|
||||
action->setChecked(false);
|
||||
}
|
||||
a->setChecked(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
private:
|
||||
class QSystemTrayIcon *_trayIcon;
|
||||
class QMenu *_trayMenu;
|
||||
class QList<class QAction*> _backendActions;
|
||||
class SnoreServer *_snore;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue