summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qml/watch/icons/notification-email.pngbin0 -> 261 bytes
-rw-r--r--qml/watch/icons/notification-facebook.pngbin0 -> 165 bytes
-rw-r--r--qml/watch/icons/notification-sms.pngbin0 -> 308 bytes
-rw-r--r--qml/watch/icons/notification-twitter.pngbin0 -> 220 bytes
-rw-r--r--salmeta.pro1
-rw-r--r--src/controller.cpp8
-rw-r--r--src/notificationmonitor.cpp49
7 files changed, 56 insertions, 2 deletions
diff --git a/qml/watch/icons/notification-email.png b/qml/watch/icons/notification-email.png
new file mode 100644
index 0000000..f7cacae
--- /dev/null
+++ b/qml/watch/icons/notification-email.png
Binary files differ
diff --git a/qml/watch/icons/notification-facebook.png b/qml/watch/icons/notification-facebook.png
new file mode 100644
index 0000000..93bfccd
--- /dev/null
+++ b/qml/watch/icons/notification-facebook.png
Binary files differ
diff --git a/qml/watch/icons/notification-sms.png b/qml/watch/icons/notification-sms.png
new file mode 100644
index 0000000..d54a3da
--- /dev/null
+++ b/qml/watch/icons/notification-sms.png
Binary files differ
diff --git a/qml/watch/icons/notification-twitter.png b/qml/watch/icons/notification-twitter.png
new file mode 100644
index 0000000..d6c6bd3
--- /dev/null
+++ b/qml/watch/icons/notification-twitter.png
Binary files differ
diff --git a/salmeta.pro b/salmeta.pro
index 04fc868..550925f 100644
--- a/salmeta.pro
+++ b/salmeta.pro
@@ -47,6 +47,7 @@ OTHER_FILES += qml/salmeta.qml \
qml/watch/WatchView.qml qml/watch/add_widget.png \
qml/watch/faces/builtinface3.qml qml/watch/faces/builtinface3.png \
qml/watch/faces/builtinface4.qml qml/watch/faces/builtinface4.png \
+ qml/watch/icons/*.png \
qml/pages/AddWidget.qml \
qml/watch/notification.png
diff --git a/src/controller.cpp b/src/controller.cpp
index 0a502da..35d6dae 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -239,8 +239,11 @@ void Controller::handleIncomingNotification(const QString &sender, const QIcon &
QFont large("MetaWatch Large 16pt");
large.setPixelSize(16);
+ // Render notification background
p.drawImage(0, 0, QImage(SailfishApp::pathTo("qml/watch/notification.png").toLocalFile()));
- icon.paint(&p, 0, 96 - 24, 24, 24, Qt::AlignLeft | Qt::AlignBottom);
+
+ // Render the associated icon on the bottom left corner
+ icon.paint(&p, 0, 96 - 24, 28, 24, Qt::AlignLeft | Qt::AlignBottom);
QString title = summary;
bool title_drawn_fully = false;
@@ -248,6 +251,7 @@ void Controller::handleIncomingNotification(const QString &sender, const QIcon &
title = QString("%1 %2").arg(count).arg(summary);
}
+ // Render title area
p.setFont(large);
if (!title.isEmpty()) {
QRect area(2, 2, 96 - 18, 18);
@@ -264,6 +268,8 @@ void Controller::handleIncomingNotification(const QString &sender, const QIcon &
const int max_y = 96 - 24;
int y = 26;
+ // Now render the contents
+ // If the title did not fit in the title area, also draw it fully here.
p.setFont(small);
if (!title_drawn_fully && !title.isEmpty()) {
QRect r;
diff --git a/src/notificationmonitor.cpp b/src/notificationmonitor.cpp
index 2001b25..dfc32f3 100644
--- a/src/notificationmonitor.cpp
+++ b/src/notificationmonitor.cpp
@@ -2,11 +2,52 @@
#include <QtGui/QIcon>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusConnectionInterface>
+
+#include <sailfishapp.h>
+
#include "notificationmonitor.h"
#include "notifications_adaptor.h"
static NotificationMonitor *global_monitor = 0;
+namespace
+{
+
+QHash<QString, QString> icons_for_categories;
+
+QIcon get_builtin_icon(const QString &iconName)
+{
+ QIcon icon;
+
+ QString filePath = SailfishApp::pathTo("qml/watch/icons/" + iconName + ".png").toLocalFile();
+ icon.addFile(filePath);
+
+ return icon;
+}
+
+QIcon icon_for_category(const QString &category)
+{
+ if (icons_for_categories.isEmpty()) {
+ icons_for_categories.insert("x-nemo.email", "notification-email");
+ icons_for_categories.insert("x-nemo.messaging.im", "notification-sms");
+ icons_for_categories.insert("x-nemo.messaging.sms", "notification-sms");
+ icons_for_categories.insert("x-nemo.messaging.mms", "notification-sms");
+ icons_for_categories.insert("x-nemo.social.twitter.mention", "notification-twitter");
+ icons_for_categories.insert("x-nemo.social.twitter.tweet", "notification-twitter");
+ icons_for_categories.insert("x-nemo.social.facebook.notification", "notification-facebook");
+ icons_for_categories.insert("x-nemo.social.facebook.statuspost", "notification-facebook");
+ }
+
+ QString iconName = icons_for_categories.value(category, QString());
+ if (!iconName.isEmpty()) {
+ return get_builtin_icon(iconName);
+ } else {
+ return QIcon();
+ }
+}
+
+}
+
NotificationMonitor::NotificationMonitor(QObject *parent) :
QObject(parent)
{
@@ -46,13 +87,19 @@ uint NotificationMonitor::Notify(const QString &app_name, uint replaces_id, cons
Q_ASSERT(calledFromDBus());
setDelayedReply(true);
+ // If the notification mentions a specific icon, then use it.
+ // But otherwise let's prefer our builtin icons.
if (app_icon.startsWith("/")) {
icon = QIcon(app_icon);
} else if (app_icon.startsWith("file:")) {
QUrl url(app_icon);
icon = QIcon(url.toLocalFile());
} else {
- icon = QIcon::fromTheme(app_icon);
+ QString category = hints.value("category").toString();
+ // Let's hardcode a few categories for now..
+ if (!category.isEmpty()) {
+ icon = icon_for_category(category);
+ }
}
int count = hints.value("x-nemo-item-count").toInt();