diff --git a/src/daemon/NotificationsService.cpp b/src/daemon/NotificationsService.cpp index 411c546..ec480be 100644 --- a/src/daemon/NotificationsService.cpp +++ b/src/daemon/NotificationsService.cpp @@ -109,10 +109,9 @@ void NotificationsService::NotifyAsync( const TQMap& hints, TQ_INT32 timeout) { - TQ_UINT32 nId=id; + TQ_UINT32 nId = id; // if (nId != 0 && !mNotificationMap.contains(nId)) // tqDebug("Requested id %i is not valid", nId); - bool found = mNotificationMap.contains(nId); if (nId == 0 || !mNotificationMap.contains(nId)) // new notification { nId = ++mNotificationId; @@ -124,69 +123,69 @@ void NotificationsService::NotifyAsync( this, TQ_SLOT(closeNotifyWidget(TQ_UINT32, TQ_UINT32))); } + if (!icon.isEmpty()) { + if (!mNotificationMap[nId]->setIcon(icon)) + tqDebug("There was an error setting the icon"); + } + if(!hints.empty()) { TQString errStr; TQMap::const_iterator it; for ( it = hints.begin(); it != hints.end(); ++it ) { bool ok = true; - if(it.key().latin1()=="category") +// tqDebug("Processing hint %s", it.key().latin1()); + if(it.key()=="category") { mNotificationMap[nId]->setCategory(it.data().value.toString(&ok)); if(!ok) errStr += " category"; } - else if (it.key().latin1()=="image-path" || it.key().latin1()=="image_path") + else if (it.key()=="image-path" || it.key()=="image_path") { mNotificationMap[nId]->setImage(it.data().value.toString(&ok)); if(!ok) errStr += " image-path"; } - else if (it.key().latin1()=="image-data" || it.key().latin1()=="image_data" || it.key().latin1()=="icon_data") + else if (it.key()=="image-data" || it.key()=="image_data" || it.key()=="icon_data") { - mNotificationMap[nId]->setImageData(it.data().value.toTQValueList(&ok)); + mNotificationMap[nId]->setImageData(it.data().value.toStruct(&ok)); if(!ok) errStr += " image-data"; } - else if (it.key().latin1()=="sound-file") + else if (it.key()=="sound-file") { mNotificationMap[nId]->setSoundFile(it.data().value.toString(&ok)); if(!ok) errStr += " sound-file"; } - else if (it.key().latin1()=="sound-name") + else if (it.key()=="sound-name") { mNotificationMap[nId]->setSoundName(it.data().value.toString(&ok)); if(!ok) errStr += " sound-name"; } - else if (it.key().latin1()=="suppress-sound") + else if (it.key()=="suppress-sound") { mNotificationMap[nId]->setSuppressSound(it.data().value.toBool(&ok)); if(!ok) errStr += " suppress-sound"; } - else if (it.key().latin1()=="transient") + else if (it.key()=="transient") { mNotificationMap[nId]->setTransient(it.data().value.toBool(&ok)); if(!ok) errStr += " transient"; } - else if (it.key().latin1()=="urgency") + else if (it.key()=="urgency") { - mNotificationMap[nId]->setUrgency(it.data().value.toUInt16(&ok)); + mNotificationMap[nId]->setUrgency(it.data().value.toByte(&ok)); if(!ok) errStr += " urgency"; } - else if (it.key().latin1()=="sender-pid") + else if (it.key()=="sender-pid") { mNotificationMap[nId]->setSenderPid(it.data().value.toUInt64(&ok)); if(!ok) errStr += " sender-pid"; } } if(! errStr.isNull() ) - tqDebug("There was an error converting some of the hint values:" + errStr); - } - - if (icon.isEmpty()) { - tqDebug("There was no icon provided"); - } else { - if (! mNotificationMap[nId]->setIcon(icon)) { - tqDebug("There was an error setting the icon"); - } + tqDebug("There was an error converting some of the hint values: " + errStr); } + else + tqDebug("hints is empty "); mNotificationMap[nId]->setText("" + app_name + ": " + summary + "

" + body + "

"); mNotificationMap[nId]->setActions(actions); diff --git a/src/daemon/NotifyWidget.cpp b/src/daemon/NotifyWidget.cpp index 4c1ba83..ff8ade5 100644 --- a/src/daemon/NotifyWidget.cpp +++ b/src/daemon/NotifyWidget.cpp @@ -47,10 +47,12 @@ NotifyWidget::NotifyWidget(TQWidget *parent, const char *name, TQ_INT32 id ) // 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())); + mIconLabel = new TQLabel(this); + mIconLabel->setFrameStyle( TQFrame::NoFrame ); mImageLabel = new TQLabel(this); + mImageLabel->setFrameStyle( TQFrame::NoFrame ); mTextLabel = new TQLabel(this); mTextLabel->setTextFormat(TQt::RichText); - mImageLabel->setFrameStyle( TQFrame::NoFrame ); mTextLabel->setFrameStyle( TQFrame::NoFrame ); // TODO: give the user an option to configure the background // mImageLabel[nId]->setPaletteBackgroundColor(TQt::black); @@ -58,11 +60,16 @@ NotifyWidget::NotifyWidget(TQWidget *parent, const char *name, TQ_INT32 id ) // mTextLabel[nId]->setPaletteBackgroundColor(TQt::black); // mTextLabel[nId]->setPaletteForegroundColor(TQt::white); - TQBoxLayout* wLayout = new TQHBoxLayout(this); - wLayout->addWidget(mImageLabel); - wLayout->addWidget(mTextLabel); - wLayout->setAlignment(TQt::AlignTop); -// wLayout->setSpacing(5); + TQBoxLayout* hLayout = new TQHBoxLayout(this); + TQBoxLayout* vLayout = new TQVBoxLayout(); + vLayout->addWidget(mIconLabel); + vLayout->addWidget(mImageLabel); + vLayout->setAlignment(TQt::AlignTop); + vLayout->setAlignment(TQt::AlignCenter); + hLayout->addLayout(vLayout); + hLayout->addWidget(mTextLabel); + hLayout->setAlignment(TQt::AlignTop); +// hLayout->setSpacing(5); mTimer = new TQTimer( this ); connect( mTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotTimeout()) ); @@ -92,7 +99,9 @@ void NotifyWidget::setAutoMask(bool b) bool NotifyWidget::setIcon(const TQString& icon) { TQPixmap pixmap; if ( pixmap.load(icon) ) { - mImageLabel->setPixmap(pixmap); + mIconLabel->setPixmap(pixmap); + mIconLabel->setAlignment(TQLabel::AlignTop); + mIconLabel->setMargin(3); } else { return false; } @@ -131,27 +140,41 @@ void NotifyWidget::setPersistence(bool p) { void NotifyWidget::setImage(const TQString& i) { TQPixmap myImage(i); // Load the image mImageLabel->setPixmap(myImage); - mImageLabel->setAlignment(TQt::AlignCenter); // Use TQt namespace for alignment +// mImageLabel->setAlignment(TQt::AlignCenter); // Use TQt namespace for alignment + mImageLabel->setAlignment(TQLabel::AlignTop); + mImageLabel->setMargin(3); } void NotifyWidget::setImageData(const TQValueList& 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 +// tqDebug("Processing ImageData"); + TQ_UINT32 x = data[0].toUInt32(); // width + TQ_UINT32 y = data[1].toUInt32(); // height + TQ_UINT32 r = data[2].toUInt32(); // rowstride + bool a = data[3].toBool(); // has alpha + TQ_UINT32 b = data[4].toUInt32(); // bits per sample + TQ_UINT32 c = data[5].toUInt32(); // channels TQValueList v = data[6].toTQValueList(); // image bytes -// int w, int h, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian - mImageData = TQPixmap(x,y); - TQByteArray byteArr; + +// tqDebug(" Width : %i", x); +// tqDebug(" Height: %i", y); +// tqDebug(" Rowstride: %i", r); +// tqDebug(" Has alpha: %i", a); +// tqDebug("Bits per sample: %i", b); +// tqDebug(" Channels: %i", c); +// tqDebug(" data size: %li", v.size()); + + TQ_UINT32 i = 0; + TQMemArray cList(v.size()); TQValueList::Iterator it; - TQ_UINT32 count; for ( it = v.begin(); it != v.end(); ++it ) - byteArr[count++]=(*it).toByte(); - mImageData.loadFromData(byteArr); - mImageLabel->setPixmap(mImageData); + cList[i++] = (*it).toByte(); + mImageData = TQImage( x, y, b, c); + mImageData.loadFromData(cList); + mImageData.setAlphaBuffer(a); + mImageLabel->setPixmap(TQPixmap(mImageData)); + mImageLabel->setAlignment(TQLabel::AlignTop); + mImageLabel->setMargin(3); } void NotifyWidget::setSoundFile(const TQString& f) { @@ -170,7 +193,7 @@ void NotifyWidget::setTransient(bool t) { mTransient = t; } -void NotifyWidget::setUrgency(TQ_UINT16 l) { +void NotifyWidget::setUrgency(TQ_UINT8 l) { mUrgency = l; } @@ -192,6 +215,7 @@ void NotifyWidget::setTimeout(TQ_INT32 t) { void NotifyWidget::setText(TQString t) { mTextLabel->setText(t); + mTextLabel->setAlignment(TQLabel::AlignTop); } void NotifyWidget::mousePressEvent( TQMouseEvent *e ) diff --git a/src/daemon/NotifyWidget.h b/src/daemon/NotifyWidget.h index 2bf25bd..0e8cb6e 100644 --- a/src/daemon/NotifyWidget.h +++ b/src/daemon/NotifyWidget.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include //class NotificationsService; @@ -88,7 +88,7 @@ Categories are in class.specific form. class specifies the generic type of notif void setSoundName(const TQString&); void setSuppressSound(bool); void setTransient(bool); - void setUrgency(TQ_UINT16); + void setUrgency(TQ_UINT8); void setSenderPid(TQ_UINT64); /** @@ -139,7 +139,7 @@ private: TQString mCategory; // not implemented TQTimer *mTimer; TQ_UINT16 mUrgency; - TQPixmap mImageData; + TQImage mImageData; TQString mSoundFile; TQString mSoundName; bool mPersistence;