Commit f05642e2faa8a0bdef1f7d6f0cc004e825abba8a

Added first version of notification library. Can
be used to show banner notifications.
  
1#ifndef QHILDONNOTIFICATIONS_GLOBAL_H
2#define QHILDONNOTIFICATIONS_GLOBAL_H
3
4#include <QtCore/qglobal.h>
5
6#if defined(QHILDONNOTIFICATIONS_LIBRARY)
7# define QHILDONNOFICATIONS_SHARED_EXPORT Q_DECL_EXPORT
8#else
9# define QHILDONNOTIFICATIONS_SHARED_EXPORT Q_DECL_IMPORT
10#endif
11
12//PRIVATE IMPLEMENTATION
13#define MAEMO_DECLARE_PRIVATE(Class) \
14 private: \
15 inline Class##Private* priv_func() { return reinterpret_cast<Class##Private *>(priv_ptr); } \
16 inline const Class##Private* priv_func() const { return reinterpret_cast<const Class##Private *>(priv_ptr); } \
17 friend class Class##Private; \
18 void* priv_ptr;
19
20#define MAEMO_DECLARE_PUBLIC(Class) \
21 public: \
22 inline Class* pub_func() { return static_cast<Class *>(pub_ptr); } \
23 inline const Class* pub_func() const { return static_cast<const Class *>(pub_ptr); } \
24 private: \
25 friend class Class; \
26 void* pub_ptr;
27
28#define MAEMO_PRIVATE(Class) Class##Private * const priv = priv_func();
29#define MAEMO_PRIVATE_CONST(Class) const Class##Private * const priv = priv_func();
30#define MAEMO_PUBLIC(Class) Class * const pub = pub_func();
31
32#define MAEMO_INITIALIZE(Class) \
33 priv_ptr = new Class##Private(); \
34 MAEMO_PRIVATE(Class); \
35 priv->pub_ptr = this;
36
37#define MAEMO_UNINITIALIZE(Class) do { MAEMO_PRIVATE(Class); delete priv; } while(0)
38
39#define compilation_assert(const_expr) do {switch(0){case 0: case const_expr: ; }} while(0)
40
41#endif // QHILDONNOTIFICATIONS_GLOBAL_H
  
1QT -= gui
2
3TEMPLATE = lib
4TARGET = QHildon-Notifications
5
6DEFINES += QHILDONNOTIFICATIONS_LIBRARY
7
8SOURCES += qnotification.cpp
9HEADERS += qnotification.h qnotification_p.h
10
11CONFIG += link_pkgconfig
12PKGCONFIG += hildon-1
  
1#include "qnotification.h"
2#include "qnotification_p.h"
3#include "moc_qnotification.cpp"
4
5namespace Maemo {
6
7QNotifications::QNotifications(QObject *parent) :
8 QObject(parent)
9{
10 MAEMO_INITIALIZE(QNotifications);
11}
12
13QNotifications::~QNotifications()
14{
15 MAEMO_UNINITIALIZE(QNotifications);
16}
17
18void QNotifications::showBanner(const QString &text)
19{
20 MAEMO_PRIVATE(QNotifications);
21 priv->showBanner(text);
22}
23
24} //namespace
  
1#ifndef QNOTIFICATIONS_H
2#define QNOTIFICATIONS_H
3
4#include "global.h"
5
6#include <QtCore/QObject>
7
8namespace Maemo {
9
10class QNotificationsPrivate;
11
12class QHILDONNOFICATIONS_SHARED_EXPORT QNotifications : public QObject
13{
14 Q_OBJECT
15
16 MAEMO_DECLARE_PRIVATE(QNotifications);
17
18public:
19 QNotifications(QObject *parent = 0);
20 ~QNotifications();
21
22public Q_SLOTS:
23 void showBanner(const QString &text);
24};
25
26} //namespace
27
28#endif
  
1#ifndef QNOTIFICATIONS_P_H
2#define QNOTIFICATIONS_P_H
3
4#define __GTK_BINDINGS_H__ //gtkbindings.h:79 has colliding symbol "signal"
5extern "C" {
6#include <hildon/hildon-banner.h>
7}
8#undef __GTK_BINDINGS_H__
9
10namespace Maemo {
11
12class QNotifications;
13
14class QNotificationsPrivate
15{
16 MAEMO_DECLARE_PUBLIC(QNotifications);
17
18public:
19 QNotificationsPrivate();
20 ~QNotificationsPrivate();
21 void showBanner(const QString &text);
22};
23
24/* begin private implementation */
25
26QNotificationsPrivate::QNotificationsPrivate()
27{
28
29}
30
31QNotificationsPrivate::~QNotificationsPrivate()
32{
33
34}
35
36void QNotificationsPrivate::showBanner(const QString &text)
37{
38 hildon_banner_show_information(0, "", text.toLatin1());
39}
40
41} // namespace
42
43#endif