-rw-r--r-- | korganizer/calendarview.cpp | 28 |
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 @@ -4040,43 +4040,65 @@ void CalendarView::undo_delete() updateView(); } } void CalendarView::slotViewerClosed() { QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); } void CalendarView::resetFocus() { if ( mViewerCallerIsSearchDialog ) { if ( mDialogManager->getSearchDialog()->isVisible() ){ mDialogManager->getSearchDialog()->raise(); mDialogManager->getSearchDialog()->setActiveWindow(); mDialogManager->getSearchDialog()->listview()->resetFocus(); } else mViewerCallerIsSearchDialog = false; } if ( !mViewerCallerIsSearchDialog ) { //mViewManager->currentView()->setFocus(); //qDebug("sssssssssssssssset focus "); topLevelWidget()->raise(); setActiveWindow(); //setFocus(); } mViewerCallerIsSearchDialog = false; } 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."); } KMessageBox::information( this, message); } |