added possebility to make a notification silent, dont use app id for now

This commit is contained in:
Patrick von Reth 2013-07-16 13:53:23 +02:00
parent 775cd3cd84
commit 10ed363d23
3 changed files with 23 additions and 6 deletions

View File

@ -172,9 +172,13 @@ void Notification::setCloseReason(const NotificationEnums::CloseReasons::closeRe
d->m_closeReason = r;
}
const QVariant Notification::hint ( const QString &key ) const
const QVariant Notification::hint(const QString &key , const QVariant &defaultValue ) const
{
return d->m_hints.value ( key );
if(d->m_hints.contains(key))
{
return d->m_hints.value ( key );
}
return defaultValue;
}
bool Notification::hintExists ( const QString &key )
@ -187,6 +191,11 @@ void Notification::insertHint ( const QString &key, const QVariant &val )
d->m_hints.insert ( key,val );
}
void Notification::setSilent(bool silent)
{
d->m_hints["silent"] = silent;
}
bool Notification::isValid() const
{
return d;

View File

@ -72,10 +72,12 @@ public:
void addAction(Action *a);
const NotificationEnums::CloseReasons::closeReasons &closeReason();
void setCloseReason(const NotificationEnums::CloseReasons::closeReasons &r);
const QVariant hint ( const QString &key ) const;
const QVariant hint(const QString &key , const QVariant &defaultValue ) const;
bool hintExists ( const QString &key );
void insertHint ( const QString &key,const QVariant &val );
void setSilent(bool silent);
bool isValid() const;
//protected://TODO::make only accesable from a backend

View File

@ -67,6 +67,7 @@ void SnoreToast::slotUnregisterApplication(Application *application)
void SnoreToast::slotNotify(Notification notification)
{
QProcess *p = new QProcess(this);
p->setReadChannelMode(QProcess::MergedChannels);
connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus)));
connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill()));
@ -80,8 +81,13 @@ void SnoreToast::slotNotify(Notification notification)
// << notification.icon().isLocalFile()?QDir::toNativeSeparators(notification.icon().localUrl()):notification.icon().url()
<< QDir::toNativeSeparators(notification.icon().localUrl())
<< "-w"
<< "-appID"
<< m_appID;
// << "-appID"
// << m_appID
;
if(notification.hint("silent",true).toBool())
{
arguements << "-silent";
}
qDebug() << "SnoreToast" << arguements;
p->start("SnoreToast", arguements);
@ -116,7 +122,7 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
break;
case -1:
//failed
qWarning() << "SnoreToast failed to display " << n;
qWarning() << "SnoreToast failed to display " << n << p->readAll();
break;
}