diff options
author | Emanoil Kotsev <deloptes@gmail.com> | 2021-06-05 12:35:10 +0200 |
---|---|---|
committer | Emanoil Kotsev <deloptes@gmail.com> | 2024-11-09 18:49:26 +0000 |
commit | 89b1302ca54bc14b96d620d1efa79ebf08fe93a1 (patch) | |
tree | ea50604b4d7fc35b7ce624ee734a1c00237c48ef | |
parent | 202ee25cb1c784abf9f13b74bfd2a27104e1e0e9 (diff) | |
download | kdbusnotification-89b1302ca54bc14b96d620d1efa79ebf08fe93a1.tar.gz kdbusnotification-89b1302ca54bc14b96d620d1efa79ebf08fe93a1.zip |
some improvments
display icon instead of text if supplied
Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
-rw-r--r-- | README | 16 | ||||
-rw-r--r-- | src/daemon/NotificationsService.cpp | 13 | ||||
-rw-r--r-- | src/daemon/NotifyWidget.cpp | 15 | ||||
-rw-r--r-- | src/daemon/NotifyWidget.h | 3 |
4 files changed, 37 insertions, 10 deletions
@@ -70,3 +70,19 @@ gdbus call \ "[]" \ "{}" \ "2000" + +To test hypertext + +gdbus call \ + --session \ + --dest org.freedesktop.Notifications \ + --object-path /org/freedesktop/Notifications \ + --method org.freedesktop.Notifications.Notify \ + "<b>Identifier</b>" \ + "5" \ + "/usr/share/icons/hicolor/72x72/mimetypes/virtualbox-vbox.png" \ + "<b>Notification title</b>" \ + "<b>Notification:</b><br/>Some Text here" \ + "[]" \ + "{}" \ + "2000" diff --git a/src/daemon/NotificationsService.cpp b/src/daemon/NotificationsService.cpp index 77e0962..cf3c8a4 100644 --- a/src/daemon/NotificationsService.cpp +++ b/src/daemon/NotificationsService.cpp @@ -69,7 +69,7 @@ TQString NotificationsService::objectPath() const { bool NotificationsService::GetCapabilities(TQStringList& return_caps, TQT_DBusError& error) { return_caps.clear(); - return_caps << "actions" << "body" << "body-hyperlinks" << "body-markup" << "icon-static"; + return_caps << "action-icons" << "actions" << "body" << "body-hyperlinks" << "body-markup" << "icon-static"; return true; } @@ -103,17 +103,20 @@ void NotificationsService::NotifyAsync( { notificationMap[id] = new NotifyWidget(0, app_name.ascii(), this, id ); + notificationMap[id]->setFrameStyle( TQFrame::NoFrame ); - notificationMap[id]->setIcon(icon); notificationMap[id]->setPaletteBackgroundColor(TQt::black); notificationMap[id]->setPaletteForegroundColor(TQt::white); - // TODO: handle hypertext in the body - notificationMap[id]->setText(app_name + ": " + summary + "\n" + body); + + if (icon.isEmpty() || ! notificationMap[id]->setIcon(icon)) { + notificationMap[id]->setTextFormat(TQt::RichText); + notificationMap[id]->setText(app_name + ":\n" + summary + "\n" + body); + } notificationMap[id]->setActions(actions); notificationMap[id]->setHints(hints); notificationMap[id]->setTimeout(timeout); - notificationMap[id]->show(); notificationMap[id]->raise(); + notificationMap[id]->show(); notificationMap[id]->setActiveWindow(); NotifyAsyncReply(asyncCallId, id); diff --git a/src/daemon/NotifyWidget.cpp b/src/daemon/NotifyWidget.cpp index a91768b..02b40dc 100644 --- a/src/daemon/NotifyWidget.cpp +++ b/src/daemon/NotifyWidget.cpp @@ -20,7 +20,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <kdebug.h> #include <tqtimer.h> +#include <tqpixmap.h> #include "NotifyWidget.h" #include "NotificationsService.h" @@ -30,13 +32,11 @@ NotifyWidget::NotifyWidget(TQWidget *parent, const char *name, NotificationsServ mName(TQString(name)), notificationService(ns), mId(id) { // TODO Auto-generated constructor stub - } NotifyWidget::~NotifyWidget() { // TODO Auto-generated destructor stub - } void NotifyWidget::mousePressEvent( TQMouseEvent *e ) @@ -62,9 +62,16 @@ void NotifyWidget::setAutoMask(bool b) TQWidget::setAutoMask(b); } -void NotifyWidget::setIcon(const TQString& icon) { +bool NotifyWidget::setIcon(const TQString& icon) { mIcon = icon; - // TODO handle icon + TQPixmap pixmap; + if ( pixmap.load(mIcon) ) { + this->setPixmap(pixmap); + } else { + tqDebug("Could not load notification icon"); + return false; + } + return true; } void NotifyWidget::setActions(const TQStringList& actions) { diff --git a/src/daemon/NotifyWidget.h b/src/daemon/NotifyWidget.h index 891d5aa..cee8d2e 100644 --- a/src/daemon/NotifyWidget.h +++ b/src/daemon/NotifyWidget.h @@ -24,6 +24,7 @@ #define SRC_DAEMON_NOTIFYWIDGET_H_ #include <tqlabel.h> +#include <tqtextedit.h> #include <tqdbusvariant.h> class NotificationsService; @@ -38,7 +39,7 @@ public: void setAutoMask(bool b); - void setIcon(const TQString& icon); + bool setIcon(const TQString& icon); void setActions(const TQStringList& actions); void setHints(const TQMap< TQString, TQT_DBusVariant >& hints); void setTimeout(TQ_INT32 t); |