fixed sticky stuff :P

This commit is contained in:
Patrick von Reth 2011-08-12 14:51:20 +02:00
parent 1f809a2d95
commit 98b9f23434
7 changed files with 24 additions and 27 deletions

View File

@ -176,15 +176,14 @@ const QString &Notification::alert() const
bool Notification::sticky() const
{
return d->_timeout == -1;
return d->_timeout == 0;
}
void Notification::setSticky()
{
d->_timeout = -1;
d->_timeout = 0;
}
const NotificationEnums::Prioritys::prioritys &Notification::priority() const
{
return d->_priority;

View File

@ -113,8 +113,9 @@ void SnoreServer::publicatePlugin ( SnorePlugin *plugin )
uint SnoreServer::broadcastNotification ( Notification notification )
{
qDebug()<<"Broadcasting"<<notification.title()<<notification.timeout();
emit notify ( notification );
if ( _notificationBackend!=NULL )
if ( _notificationBackend != NULL )
{
notification.setId(_notificationBackend->notify ( notification ));
return notification.id();

View File

@ -87,17 +87,12 @@ uint FreedesktopNotification_Frontend::Notify(const QString &app_name, uint repl
priotity = NotificationEnums::Prioritys::prioritys(hints["urgency"].toInt()-1);
}
Notification noti(app_name,"DBus Alert",summary,body,icon,timeout==-1?-1:timeout/1000,replaces_id,priotity);
Notification noti(app_name,"DBus Alert",summary,body,icon,timeout==-1?Notification::DefaultTimeout:timeout/1000,replaces_id,priotity);
noti.setSource(this);
qDebug()<<"Actions"<<actions;
for(int i = 0;i < actions.length(); i+=2){
noti.addAction(new Notification::Action(actions.at(i).toInt(),actions.at(i+1)));
}
snore()->broadcastNotification(noti);
activeNotifications[noti.id()] = noti;
startTimeout(noti.id(),noti.timeout());

View File

@ -101,7 +101,7 @@ uint Snarl_Backend::notify(Notification notification){
id = snarlInterface->Notify(notification.alert().toUtf8().constData(),
Notification::toPlainText(notification.title()).toUtf8().constData(),
Notification::toPlainText(notification.text()).toUtf8().constData(),
notification.timeout()+1,//+1 make a sticke snarl sticky and doesnt matter for the rest
notification.timeout(),
notification.icon().isLocalFile()?notification.icon().localUrl().toUtf8().constData():0,
!notification.icon().isLocalFile()?notification.icon().imageData().toBase64().constData():0,
notification.priority());
@ -118,7 +118,7 @@ uint Snarl_Backend::notify(Notification notification){
notification.alert().toUtf8().constData(),
Notification::toPlainText(notification.title()).toUtf8().constData(),
Notification::toPlainText(notification.text()).toUtf8().constData(),
notification.timeout()+1,
notification.timeout(),
notification.icon().isLocalFile()?notification.icon().localUrl().toUtf8().constData():0,
!notification.icon().isLocalFile()?notification.icon().imageData().toBase64().constData():0,
notification.priority());

View File

@ -65,9 +65,11 @@ void SnoreNotify::save(){
void SnoreNotify::exit(){
qDebug()<<"Saving snore settings";
foreach(Application *a,_snore->aplications()){
_snore->removeApplication(a->name());
}
save();
_trayIcon->hide();
}

View File

@ -27,7 +27,7 @@ TrayIcon::TrayIcon()
}
void TrayIcon::initConextMenu(SnoreServer *snore){
_snore = snore;
_snore = snore;
_trayIcon->setVisible(true);
_trayMenu = new QMenu("SnoreNotify");
@ -36,10 +36,10 @@ void TrayIcon::initConextMenu(SnoreServer *snore){
foreach(const QString &back,_snore->primaryNotificationBackends()){
QAction *b= new QAction(back,this);
connect(b,SIGNAL(triggered()),this,SLOT(setPrimaryBackend()));
b->setCheckable(true);
b->setCheckable(true);
if(back == _snore->primaryNotificationBackend())
b->setChecked(true);
_backendActions.append(b);
b->setChecked(true);
_backendActions.append(b);
_trayMenu->addAction(b);
}
_trayMenu->addSeparator();
@ -54,18 +54,18 @@ void TrayIcon::hide(){
}
QSystemTrayIcon* TrayIcon::trayIcon(){
return _trayIcon;
return _trayIcon;
}
void TrayIcon::setPrimaryBackend(){
QAction *a= dynamic_cast<QAction*>(sender());
_snore->setPrimaryNotificationBackend(a->text());
foreach(QAction *action,_backendActions){
action->setChecked(false);
}
a->setChecked(true);
foreach(QAction *action,_backendActions){
action->setChecked(false);
}
a->setChecked(true);
}

View File

@ -25,13 +25,13 @@ class TrayIcon:public QObject
public:
TrayIcon();
void initConextMenu(class SnoreServer *snore);
void hide();
class QSystemTrayIcon* trayIcon();
void hide();
class QSystemTrayIcon* trayIcon();
private:
class QSystemTrayIcon *_trayIcon;
class QMenu *_trayMenu;
class QList<class QAction*> _backendActions;
class QList<class QAction*> _backendActions;
class SnoreServer *_snore;