some improvments

display icon instead of text if supplied

Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
feat/with_dbus-1-tqt
Emanoil Kotsev 4 years ago
parent 202ee25cb1
commit 89b1302ca5

@ -70,3 +70,19 @@ gdbus call \
"[]" \ "[]" \
"{}" \ "{}" \
"2000" "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"

@ -69,7 +69,7 @@ TQString NotificationsService::objectPath() const {
bool NotificationsService::GetCapabilities(TQStringList& return_caps, TQT_DBusError& error) { bool NotificationsService::GetCapabilities(TQStringList& return_caps, TQT_DBusError& error) {
return_caps.clear(); 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; return true;
} }
@ -103,17 +103,20 @@ void NotificationsService::NotifyAsync(
{ {
notificationMap[id] = new NotifyWidget(0, app_name.ascii(), this, id ); notificationMap[id] = new NotifyWidget(0, app_name.ascii(), this, id );
notificationMap[id]->setFrameStyle( TQFrame::NoFrame ); notificationMap[id]->setFrameStyle( TQFrame::NoFrame );
notificationMap[id]->setIcon(icon);
notificationMap[id]->setPaletteBackgroundColor(TQt::black); notificationMap[id]->setPaletteBackgroundColor(TQt::black);
notificationMap[id]->setPaletteForegroundColor(TQt::white); 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]->setActions(actions);
notificationMap[id]->setHints(hints); notificationMap[id]->setHints(hints);
notificationMap[id]->setTimeout(timeout); notificationMap[id]->setTimeout(timeout);
notificationMap[id]->show();
notificationMap[id]->raise(); notificationMap[id]->raise();
notificationMap[id]->show();
notificationMap[id]->setActiveWindow(); notificationMap[id]->setActiveWindow();
NotifyAsyncReply(asyncCallId, id); NotifyAsyncReply(asyncCallId, id);

@ -20,7 +20,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <kdebug.h>
#include <tqtimer.h> #include <tqtimer.h>
#include <tqpixmap.h>
#include "NotifyWidget.h" #include "NotifyWidget.h"
#include "NotificationsService.h" #include "NotificationsService.h"
@ -30,13 +32,11 @@ NotifyWidget::NotifyWidget(TQWidget *parent, const char *name, NotificationsServ
mName(TQString(name)), notificationService(ns), mId(id) mName(TQString(name)), notificationService(ns), mId(id)
{ {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
NotifyWidget::~NotifyWidget() NotifyWidget::~NotifyWidget()
{ {
// TODO Auto-generated destructor stub // TODO Auto-generated destructor stub
} }
void NotifyWidget::mousePressEvent( TQMouseEvent *e ) void NotifyWidget::mousePressEvent( TQMouseEvent *e )
@ -62,9 +62,16 @@ void NotifyWidget::setAutoMask(bool b)
TQWidget::setAutoMask(b); TQWidget::setAutoMask(b);
} }
void NotifyWidget::setIcon(const TQString& icon) { bool NotifyWidget::setIcon(const TQString& icon) {
mIcon = 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) { void NotifyWidget::setActions(const TQStringList& actions) {

@ -24,6 +24,7 @@
#define SRC_DAEMON_NOTIFYWIDGET_H_ #define SRC_DAEMON_NOTIFYWIDGET_H_
#include <tqlabel.h> #include <tqlabel.h>
#include <tqtextedit.h>
#include <tqdbusvariant.h> #include <tqdbusvariant.h>
class NotificationsService; class NotificationsService;
@ -38,7 +39,7 @@ public:
void setAutoMask(bool b); void setAutoMask(bool b);
void setIcon(const TQString& icon); bool setIcon(const TQString& icon);
void setActions(const TQStringList& actions); void setActions(const TQStringList& actions);
void setHints(const TQMap< TQString, TQT_DBusVariant >& hints); void setHints(const TQMap< TQString, TQT_DBusVariant >& hints);
void setTimeout(TQ_INT32 t); void setTimeout(TQ_INT32 t);

Loading…
Cancel
Save