summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 73aa733..a330414 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -4069,11 +4069,33 @@ void CalendarView::resetFocus()
void CalendarView::showNextAlarms()
{
QString message;
- if ( mNextAlarmDateTime > QDateTime::currentDateTime() ) {
+ QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
+ if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
QString sum = mCalendar->nextSummary();
QDateTime nextA = mNextAlarmDateTime;
- QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
- message = i18n("The next alarm is on:\n%1\nat: %2\n\n%3\n(%4)").arg( KGlobal::locale()->formatDate(nextA.date() , false)).arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
+ QDateTime cur = QDateTime::currentDateTime();
+ int secs = cur.secsTo( nextA );
+ int min = secs /60;
+ int hours = min /60;
+ min = min % 60;
+ int days = hours /24;
+ hours = hours % 24;
+
+ message = i18n("The next alarm is in:\n");
+ if ( days > 1 )
+ message += i18n("%1 days\n").arg( days );
+ else if ( days == 1 )
+ message += i18n("1 day\n");
+ if ( hours > 1 )
+ message += i18n("%1 hours\n").arg( hours );
+ else if ( hours == 1 )
+ message += i18n("1 hour\n");
+ if ( min > 1 )
+ message += i18n("%1 minutes\n").arg( min );
+ else if ( min == 1 )
+ message += i18n("1 minute\n");
+
+ message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
} else {
message = i18n("There is no next alarm.");