Go Back   maemo.org - Talk > OS / Platform > Development
 
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
  #1  
Old 2010-06-01, 16:52
Venemo's Avatar
Venemo Venemo is offline
 
Join Date: Aug 2009
Location: Budapest, Hungary
Posts: 1,296
Thanks!: 3,355
Thanked 1,773 Times in 552 Posts
Default Guide: E-mail/SMS-style notifications in Qt apps

Hey Everyone,

Today I got envious of all the apps that create those shiny notifications, so I decided to put together an app in Qt to see how to do it.

Unfortunately the QMaemo5InformationBox doesn't display the style of notifications I needed.

So, I went to IRC and asked the good people in #qt-maemo, and they said that Qt doesn't have an abstraction of this particular UI element. They pointed me to this guide on Forum Nokia, which almost did it. Unfortunately it doesn't work with MADDE.

After hours of suffering and pain I successfully overcame the limitations of MADDE (again, thanks to the good people at #qt-maemo), and I put together a small example in the repo of my project.

Here it goes:
  • Check out this SVN repo or download the sources
  • Copy-paste my QMaemo5Notification class (header and cpp file)
  • Make sure you have added all the necessary libraries to your .pro file's INCLUDEPATH and LIBS. (See the example .pro file)
  • it is necessary to put "CONFIG += no_keywords" into the .pro file because the headers required contain keywords that are otherwise reserved by Qt.
    If you would use them in your own code, I recommend you to put QMaemo5Notification into its own project file (or .pri file)

That's it.
Now you can just do this:

Code:
#include "qmaemo5notification.hpp"
...

QMaemo5Notification::information("Hey, this is a note!");
Of course it has some tasty overloads to exploit libnotify's functionality.

I hope I could spare some people the pain I went through, so I decided to share this with the community.

Last edited by Venemo; 2010-06-01 at 16:59.
Reply With Quote
The Following 10 Users Say Thank You to Venemo For This Useful Post:
  #2  
Old 2010-06-01, 17:07
gri gri is offline
 
Join Date: Mar 2010
Location: Bavaria, Germany
Posts: 190
Thanks!: 24
Thanked 129 Times in 72 Posts
Send a message via Skype™ to gri
Default Re: Guide: E-mail/SMS-style notifications in Qt apps

Already thought of implementing this, but you were faster

It would be nice if you could ask the libQxt developers if they want to integrate this into their library (or another common library).
So someone could package libQxt for maemo and everyone could use those features
Reply With Quote
  #3  
Old 2010-06-01, 20:24
Venemo's Avatar
Venemo Venemo is offline
 
Join Date: Aug 2009
Location: Budapest, Hungary
Posts: 1,296
Thanks!: 3,355
Thanked 1,773 Times in 552 Posts
Default Re: Guide: E-mail/SMS-style notifications in Qt apps

Quote:
Originally Posted by gri View Post
Already thought of implementing this, but you were faster

It would be nice if you could ask the libQxt developers if they want to integrate this into their library (or another common library).
So someone could package libQxt for maemo and everyone could use those features
Everyone can use these features, just download my source code.
BTW, you can ask them yourself on freenode.
Reply With Quote
  #4  
Old 2010-06-06, 04:32
HeartJ HeartJ is offline
 
Join Date: Apr 2010
Posts: 26
Thanks!: 0
Thanked 0 Times in 0 Posts
Default Re: Guide: E-mail/SMS-style notifications in Qt apps

Thx for your thread and sources and I'am starting to develop with Qt.
Reply With Quote
  #5  
Old 2010-06-13, 13:43
Venemo's Avatar
Venemo Venemo is offline
 
Join Date: Aug 2009
Location: Budapest, Hungary
Posts: 1,296
Thanks!: 3,355
Thanked 1,773 Times in 552 Posts
Default Re: Guide: E-mail/SMS-style notifications in Qt apps

Bump.

Okay, I successfully added some new functionality to this stuff, namely this: when the user clicks on the notification, you can now add a D-Bus call that is executed.

(Very much like when you hit the SMS notification, the SMS app appears.)
It is now also possible to set "hints" for the notifications.

A big thanks for the great people who made nowplayingd (I got the idea of how to do this from their code), and also another big thanks to w00t and Frals who helped me very much with troubleshooting and advices on IRC.

To exploit this functionality, you'll need a D-Bus method to call or to expose your app to D-Bus as described here.
(I also found out that adding X-Osso-Service to the .desktop file and creating a .service file is not required for basic usage.)

Head over to the repo (header file, source file), and grab your copy!

You can find a pretty good example on how to use it in my app, namely in this file.

Good luck!

EDIT:
If you are cunning enough, you may also find out from my sources how to blink the notification LED when these notifications appear!

Last edited by Venemo; 2010-06-13 at 13:59.
Reply With Quote
The Following 3 Users Say Thank You to Venemo For This Useful Post:
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 17:07.