summaryrefslogtreecommitdiff
path: root/libsowatch/declarativewatchlet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsowatch/declarativewatchlet.cpp')
-rw-r--r--libsowatch/declarativewatchlet.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp
index bc979b0..6508ce5 100644
--- a/libsowatch/declarativewatchlet.cpp
+++ b/libsowatch/declarativewatchlet.cpp
@@ -23,12 +23,15 @@ DeclarativeWatchlet::DeclarativeWatchlet(Watch* watch, const QString& id) :
if (!_registered) {
qRegisterMetaType<Notification::Type>("Notification::Type");
+ qRegisterMetaType<WeatherNotification::WeatherType>("WeatherNotification::WeatherType");
qmlRegisterUncreatableType<DeclarativeWatchWrapper>("com.javispedro.sowatch", 1, 0,
"Watch", "Watch is only available via the 'watch' context property");
qmlRegisterUncreatableType<NotificationsModel>("com.javispedro.sowatch", 1, 0,
"NotificationsModel", "NotificationsModel is only available via the 'notifications' context property");
qmlRegisterUncreatableType<Notification>("com.javispedro.sowatch", 1, 0,
"Notification", "Notification is an abstract class");
+ qmlRegisterUncreatableType<WeatherNotification>("com.javispedro.sowatch", 1, 0,
+ "WeatherNotification", "WeatherNotification is an abstract class");
qmlRegisterType<ConfigKey>();
qmlRegisterType<GConfKey>("com.javispedro.sowatch", 1, 0, "GConfKey");
_registered = true;
@@ -139,6 +142,34 @@ void DeclarativeWatchlet::setRootObject(QDeclarativeItem *item)
scene()->addItem(_item);
}
+bool DeclarativeWatchlet::handlesNotification(Notification *notification) const
+{
+ if (_item) {
+ QVariant arg = QVariant::fromValue(notification);
+ QVariant result;
+ if (QMetaObject::invokeMethod(_item, "handlesNotification",
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, arg))) {
+ return result.toBool();
+ }
+ }
+
+ return false;
+}
+
+void DeclarativeWatchlet::openNotification(Notification *notification)
+{
+ if (_item) {
+ QVariant arg = QVariant::fromValue(notification);
+ QVariant result;
+ if (!QMetaObject::invokeMethod(_item, "openNotification",
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, arg))) {
+ qWarning() << "No openNotification method in QML root object";
+ }
+ }
+}
+
void DeclarativeWatchlet::handleComponentStatus(QDeclarativeComponent::Status status)
{
QObject *obj;