summaryrefslogtreecommitdiffstats
path: root/src/daemon/NotifyWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/NotifyWidget.cpp')
-rw-r--r--src/daemon/NotifyWidget.cpp151
1 files changed, 116 insertions, 35 deletions
diff --git a/src/daemon/NotifyWidget.cpp b/src/daemon/NotifyWidget.cpp
index 482fe84..78d8445 100644
--- a/src/daemon/NotifyWidget.cpp
+++ b/src/daemon/NotifyWidget.cpp
@@ -21,55 +21,41 @@
*/
#include <kdebug.h>
-#include <tdeapplication.h>
#include <tqtimer.h>
-#include <tqpixmap.h>
+#include <tqdbusvariant.h>
#include "NotifyWidget.h"
#include "NotificationsService.h"
#define FADE_SPEED 5
+#define EXPTIMEOUT 15000 //msec
NotifyWidget::NotifyWidget(TQWidget *parent, const char *name, NotificationsService *ns, TQ_INT32 id )
-: TQLabel( parent, name, WStyle_Customize | TQt::WStyle_StaysOnTop | TQt::WStyle_NoBorder),
- mName(TQString(name)), notificationService(ns), mId(id)
+ : TQLabel( parent, name, WStyle_Customize | TQt::WStyle_StaysOnTop | TQt::WStyle_NoBorder),
+ mName(TQString(name)),
+ notificationService(ns),
+ mId(id),
+ mUrgency(0),
+ mPersistence(false),
+ mSuppressSound(false),
+ mTransient(false),
+ mSenderPid(0)
{
- // TODO Auto-generated constructor stub
- TQDesktopWidget *d = TQApplication::desktop();
- mPosition=TQPoint(d->width()-50, d->height()-20);
- move(mPosition);
// TODO: give the user an option to configure if he/she wants to have
// the notification fading away from down to top
// TQTimer::singleShot(100, this, TQ_SLOT(fadeAway()));
+ mTimer = new TQTimer( this );
+ connect( mTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotTimeout()) );
}
NotifyWidget::~NotifyWidget()
{
+ if(mTimer)
+ delete mTimer;
if(notificationService)
delete notificationService;
}
-void NotifyWidget::mousePressEvent( TQMouseEvent *e )
-{
- if (e->button() == TQMouseEvent::LeftButton)
- {
- // The notification was dismissed by the user.
- notificationService->closeNotifyWidget(mId, 2);
- }
-}
-
-void NotifyWidget::timeout()
-{
- notificationService->closeNotifyWidget(mId, 1); // The notification expired.
-}
-
-void NotifyWidget::fadeAway()
-{
- mPosition.setY(mPosition.y()-1);
- move(mPosition);
- TQTimer::singleShot(FADE_SPEED, this, TQ_SLOT(fadeAway()));
-}
-
void NotifyWidget::setAutoMask(bool b)
{
if (b)
@@ -91,19 +77,114 @@ bool NotifyWidget::setIcon(const TQString& icon) {
return true;
}
+/**
+ * The actions send a request message back to the notification client when invoked. This functionality may not be implemented by the notification server, conforming clients should check if it is available before using it (see the GetCapabilities message in Protocol). An implementation is free to ignore any requested by the client. As an example one possible rendering of actions would be as buttons in the notification popup.
+
+Actions are sent over as a list of pairs. Each even element in the list (starting at index 0) represents the identifier for the action. Each odd element in the list is the localized string that will be displayed to the user.
+
+The default action (usually invoked by clicking the notification) should have a key named "default". The name can be anything, though implementations are free not to display it.
+ */
void NotifyWidget::setActions(const TQStringList& actions) {
mActions = actions;
- // TODO handle actions
+ // not implemented
+}
+
+/**
+ * Hints are a way to provide extra data to a notification server that the server may be able to make use of.
+
+Neither clients nor notification servers are required to support any hints. Both sides should assume that hints are not passed, and should ignore any hints they do not understand.
+ */
+
+/**
+ * Notifications can optionally have a type indicator. Although neither client or nor server must support this, some may choose to. Those servers implementing categories may use them to intelligently display the notification in a certain way, or group notifications of similar types.
+ */
+void NotifyWidget::setCategory(const TQString& c) {
+ mCategory = c;
+}
+
+void NotifyWidget::setPersistence(bool p) {
+ mPersistence = p;
+}
+
+void NotifyWidget::setImage(const TQString& i) {
+ mIcon = i;
+}
+void NotifyWidget::setImageData(const TQValueList<TQT_DBusData>& data) {
+
+ int x = data[0].toInt32();
+ int y = data[1].toInt32();
+ int r = data[2].toInt32(); // rowstride
+ int a = data[3].toBool(); // alpha
+ int b = data[4].toInt32(); // bits per sample
+ int c = data[5].toInt32(); // channels
+ TQValueList<TQT_DBusData> v = data[6].toTQValueList(); // image bytes
+// int w, int h, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian
+ mImageData = TQPixmap(x,y);
+ TQByteArray i;
+ TQValueList<TQT_DBusData>::Iterator it;
+ TQ_UINT32 count;
+ for ( it = v.begin(); it != v.end(); ++it )
+ i[count++]=(*it).toByte();
+ mImageData.loadFromData(i);
+ setPixmap(mImageData);
}
-void NotifyWidget::setHints(const TQMap< TQString, TQT_DBusVariant >& hints) {
- mHints = hints;
- // TODO handle hints
+void NotifyWidget::setSoundFile(const TQString& f) {
+ mSoundFile = f;
+}
+
+void NotifyWidget::setSoundName(const TQString& n) {
+ mSoundName = n;
+}
+
+void NotifyWidget::setSuppressSound(bool s) {
+ mSuppressSound = s;
+}
+
+void NotifyWidget::setTransient(bool t) {
+ mTransient = t;
+}
+
+void NotifyWidget::setUrgency(TQ_UINT16 l) {
+ mUrgency = l;
+}
+
+
+void NotifyWidget::setSenderPid(TQ_UINT64 p) {
+ mSenderPid = p;
}
void NotifyWidget::setTimeout(TQ_INT32 t) {
- TDEApplication::kApplication()->setTopWidget(this);
- TQTimer::singleShot(t, this, TQ_SLOT(timeout()));
+ if(t == -1)
+ {
+ t = EXPTIMEOUT;
+ }
+ if (t > 0) {
+ mTimer->start( t, TRUE );
+ }
+}
+
+void NotifyWidget::mousePressEvent( TQMouseEvent *e )
+{
+ if (e->button() == TQMouseEvent::LeftButton)
+ {
+ if(mTimer->isActive())
+ mTimer->stop();
+ notificationService->closeNotifyWidget(mId, 2); // The notification was dismissed by the user (2).
+ }
+}
+
+void NotifyWidget::slotTimeout()
+{
+ notificationService->closeNotifyWidget(mId, 1); // The notification expired (1).
+}
+
+void NotifyWidget::slotFadeAway()
+{
+ TQPoint p = pos();
+ p.setY(p.y()-1);
+ move(p);
+ TQTimer::singleShot(FADE_SPEED, this, TQ_SLOT(fadeAway()));
}
#include "NotifyWidget.moc"