some improvments

display icon instead of text if supplied

Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
Emanoil Kotsev 3 years ago
parent ab4ba660b8
commit 0ba15dc41a
Signed by: deloptes
GPG Key ID: F1EEB8CD9FB16A50

@ -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"

@ -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);

@ -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) {

@ -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);

Loading…
Cancel
Save