29 #include "knotificationmanager_p.h"
50 #include <QStringList>
51 #include <QTextStream>
55 struct KNotification::Private
67 NotificationFlags
flags;
73 Private() : id(0),
ref(1),
widget(0l), needUpdate(false) {}
83 QObject(parent) , d(new Private)
88 connect(&d->updateTimer,SIGNAL(
timeout()),
this, SLOT(
update()));
89 d->updateTimer.setSingleShot(
true);
90 d->updateTimer.setInterval(100);
95 const NotificationFlags& flags,
102 connect(&d->updateTimer,SIGNAL(
timeout()),
this, SLOT(
update()));
103 d->updateTimer.setSingleShot(
true);
104 d->updateTimer.setInterval(100);
111 KNotificationManager::self()->close( d->id );
140 wid->installEventFilter(
this);
146 d->needUpdate =
true;
149 d->updateTimer.start();
154 d->needUpdate =
true;
157 d->updateTimer.start();
167 d->needUpdate =
true;
170 d->updateTimer.start();
180 d->needUpdate =
true;
183 d->updateTimer.start();
198 d->contexts << context;
203 d->contexts << qMakePair( context_key , context_value );
219 d->componentData = c;
249 KNotificationManager::self()->close( d->id );
263 Private::raiseWidget( d->widget );
267 void KNotification::Private::raiseWidget(
QWidget *w)
273 #if defined(Q_WS_MAC)
284 if(
QTabWidget *tab_widget=qobject_cast<QTabWidget*>(pw))
286 tab_widget->setCurrentIndex(tab_widget->indexOf(w));
292 const QPixmap& pixmap,
QWidget *widget,
const NotificationFlags &flags,
const KComponentData &componentData)
300 QTimer::singleShot(0,notify,SLOT(
sendEvent()));
306 const QPixmap& pixmap,
QWidget *widget,
const NotificationFlags &flags,
const KComponentData &componentData)
308 return event( eventid,
QString(), text, pixmap, widget, flags, componentData );
313 const QPixmap& pixmap,
QWidget *widget,
const NotificationFlags &flags)
318 message = QLatin1String(
"warning");
321 message = QLatin1String(
"fatalerror");
324 message = QLatin1String(
"catastrophe");
328 message = QLatin1String(
"notification");
335 const QPixmap& pixmap,
QWidget *widget,
const NotificationFlags &flags)
337 return event( eventid,
QString(), text, pixmap, widget , flags );
359 d->needUpdate =
false;
365 appname = QLatin1String(
"kde");
366 else if(d->componentData.isValid()) {
367 appname = d->componentData.componentName();
369 appname = KGlobal::mainComponent().componentName();
372 if (KNotificationManager::self()->notify(
this , d->pixmap , d->actions , d->contexts , appname ))
377 KNotificationManager::self()->reemit(
this , d->id );
382 d->needUpdate =
true;
386 void KNotification::slotReceivedId(
int id)
390 KNotificationManager::self()->close(
id,
true );
397 KNotificationManager::self()->insert(
this,d->id);
404 QTimer::singleShot(0,
this, SLOT(
deref()));
409 void KNotification::slotReceivedIdError(
const QDBusError& error)
416 kWarning(299) <<
"Error while contacting notify daemon" << error.message();
418 QTimer::singleShot(0,
this, SLOT(
deref()));
424 KNotificationManager::self()->update(
this, d->id);
429 if( watched == d->widget )
431 if( event->type() == QEvent::WindowActivate )
434 QTimer::singleShot(500,
this, SLOT(
close()));
443 #include "knotification.moc"