Commit f05642e2faa8a0bdef1f7d6f0cc004e825abba8a
Added first version of notification library. Can
be used to show banner notifications.
| |   |
| #ifndef QHILDONNOTIFICATIONS_GLOBAL_H |
| #define QHILDONNOTIFICATIONS_GLOBAL_H |
|
| #include <QtCore/qglobal.h> |
|
| #if defined(QHILDONNOTIFICATIONS_LIBRARY) |
| # define QHILDONNOFICATIONS_SHARED_EXPORT Q_DECL_EXPORT |
| #else |
| # define QHILDONNOTIFICATIONS_SHARED_EXPORT Q_DECL_IMPORT |
| #endif |
|
| //PRIVATE IMPLEMENTATION |
| #define MAEMO_DECLARE_PRIVATE(Class) \ |
| private: \ |
| inline Class##Private* priv_func() { return reinterpret_cast<Class##Private *>(priv_ptr); } \ |
| inline const Class##Private* priv_func() const { return reinterpret_cast<const Class##Private *>(priv_ptr); } \ |
| friend class Class##Private; \ |
| void* priv_ptr; |
|
| #define MAEMO_DECLARE_PUBLIC(Class) \ |
| public: \ |
| inline Class* pub_func() { return static_cast<Class *>(pub_ptr); } \ |
| inline const Class* pub_func() const { return static_cast<const Class *>(pub_ptr); } \ |
| private: \ |
| friend class Class; \ |
| void* pub_ptr; |
|
| #define MAEMO_PRIVATE(Class) Class##Private * const priv = priv_func(); |
| #define MAEMO_PRIVATE_CONST(Class) const Class##Private * const priv = priv_func(); |
| #define MAEMO_PUBLIC(Class) Class * const pub = pub_func(); |
|
| #define MAEMO_INITIALIZE(Class) \ |
| priv_ptr = new Class##Private(); \ |
| MAEMO_PRIVATE(Class); \ |
| priv->pub_ptr = this; |
|
| #define MAEMO_UNINITIALIZE(Class) do { MAEMO_PRIVATE(Class); delete priv; } while(0) |
|
| #define compilation_assert(const_expr) do {switch(0){case 0: case const_expr: ; }} while(0) |
|
| #endif // QHILDONNOTIFICATIONS_GLOBAL_H |
| |   |
| QT -= gui |
|
| TEMPLATE = lib |
| TARGET = QHildon-Notifications |
|
| DEFINES += QHILDONNOTIFICATIONS_LIBRARY |
|
| SOURCES += qnotification.cpp |
| HEADERS += qnotification.h qnotification_p.h |
|
| CONFIG += link_pkgconfig |
| PKGCONFIG += hildon-1 |
| |   |
| #include "qnotification.h" |
| #include "qnotification_p.h" |
| #include "moc_qnotification.cpp" |
|
| namespace Maemo { |
|
| QNotifications::QNotifications(QObject *parent) : |
| QObject(parent) |
| { |
| MAEMO_INITIALIZE(QNotifications); |
| } |
|
| QNotifications::~QNotifications() |
| { |
| MAEMO_UNINITIALIZE(QNotifications); |
| } |
|
| void QNotifications::showBanner(const QString &text) |
| { |
| MAEMO_PRIVATE(QNotifications); |
| priv->showBanner(text); |
| } |
|
| } //namespace |
| |   |
| #ifndef QNOTIFICATIONS_H |
| #define QNOTIFICATIONS_H |
|
| #include "global.h" |
|
| #include <QtCore/QObject> |
|
| namespace Maemo { |
|
| class QNotificationsPrivate; |
|
| class QHILDONNOFICATIONS_SHARED_EXPORT QNotifications : public QObject |
| { |
| Q_OBJECT |
|
| MAEMO_DECLARE_PRIVATE(QNotifications); |
|
| public: |
| QNotifications(QObject *parent = 0); |
| ~QNotifications(); |
|
| public Q_SLOTS: |
| void showBanner(const QString &text); |
| }; |
|
| } //namespace |
|
| #endif |
| |   |
| #ifndef QNOTIFICATIONS_P_H |
| #define QNOTIFICATIONS_P_H |
|
| #define __GTK_BINDINGS_H__ //gtkbindings.h:79 has colliding symbol "signal" |
| extern "C" { |
| #include <hildon/hildon-banner.h> |
| } |
| #undef __GTK_BINDINGS_H__ |
|
| namespace Maemo { |
|
| class QNotifications; |
|
| class QNotificationsPrivate |
| { |
| MAEMO_DECLARE_PUBLIC(QNotifications); |
|
| public: |
| QNotificationsPrivate(); |
| ~QNotificationsPrivate(); |
| void showBanner(const QString &text); |
| }; |
|
| /* begin private implementation */ |
|
| QNotificationsPrivate::QNotificationsPrivate() |
| { |
|
| } |
|
| QNotificationsPrivate::~QNotificationsPrivate() |
| { |
|
| } |
|
| void QNotificationsPrivate::showBanner(const QString &text) |
| { |
| hildon_banner_show_information(0, "", text.toLatin1()); |
| } |
|
| } // namespace |
|
| #endif |