From cf5d24b94d96b722c6d76c2225293a56a50d3c2b Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 25 Sep 2011 04:53:46 +0200 Subject: watchlets working! --- libsowatch/notification.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'libsowatch/notification.cpp') diff --git a/libsowatch/notification.cpp b/libsowatch/notification.cpp index b4c97b2..e321b58 100644 --- a/libsowatch/notification.cpp +++ b/libsowatch/notification.cpp @@ -11,6 +11,25 @@ Notification::~Notification() { } +QString Notification::displayTime() const +{ + QDateTime dt = dateTime(); + int secsDiff = dt.secsTo(QDateTime::currentDateTime()); + if (secsDiff < 1) { + return ""; + } else if (secsDiff < 60) { + return tr("%n second(s) ago", "", secsDiff); + } else if (secsDiff < 60*60) { + int n = secsDiff / 60; + return tr("%n minute(s) ago", "", n); + } else if (secsDiff < 60*60*24) { + int n = secsDiff / 3600; + return tr("%n hour(s) ago", "", n); + } else { + return dt.toString(Qt::SystemLocaleShortDate); + } +} + QImage Notification::image() const { return QImage(); -- cgit v1.2.3