summaryrefslogtreecommitdiff
path: root/libsowatch/notification.cpp
blob: 8f346c02d8464cd65c2c7abd8a32e21dc232661c (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
37
38
39
40
41
#include "notification.h"

using namespace sowatch;

Notification::Notification(QObject *parent)
	: QObject(parent)
{
}

Notification::~Notification()
{
}

Notification::Priority Notification::priority() const
{
	return Normal;
}

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();
}