blob: 62a9b7de11ee4940edc803f12ae6b1868f565282 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "notification.h"
using namespace sowatch;
Notification::Notification(QObject *parent)
: QObject(parent)
{
}
Notification::~Notification()
{
}
QString Notification::displayTime() const
{
QDateTime dt = dateTime();
int secsDiff = dt.secsTo(QDateTime::currentDateTime());
if (secsDiff < 20) {
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();
}
|