-rw-r--r-- | korganizer/calendarview.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index beb19d9..76cce26 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -469,128 +469,133 @@ void CalendarView::init() connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); mEventEditor = mDialogManager->getEventEditor(); mTodoEditor = mDialogManager->getTodoEditor(); mFlagEditDescription = false; mSuspendTimer = new QTimer( this ); mAlarmTimer = new QTimer( this ); mRecheckAlarmTimer = new QTimer( this ); connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); mAlarmDialog = new AlarmDialog( this ); connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); mAlarmDialog->setServerNotification( false ); mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); #ifndef DESKTOP_VERSION //US listen for arriving address resultsets connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); #endif mDateNavigator->setCalendar( mCalendar ); } CalendarView::~CalendarView() { // kdDebug() << "~CalendarView()" << endl; //qDebug("CalendarView::~CalendarView() "); delete mDialogManager; delete mViewManager; delete mStorage; delete mDateFrame ; delete beamDialog; delete mEventViewerDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::showDay( QDate d ) { dateNavigator()->blockSignals( true ); dateNavigator()->selectDate( d ); dateNavigator()->blockSignals( false ); mViewManager->showDayView(); //dateNavigator()->selectDate( d ); } void CalendarView::timerAlarm() { //qDebug("CalendarView::timerAlarm() "); computeAlarm(mAlarmNotification ); } void CalendarView::suspendAlarm() { //qDebug(" CalendarView::suspendAlarm() "); computeAlarm(mSuspendAlarmNotification ); } void CalendarView::startAlarm( QString mess , QString filename) { + + topLevelWidget()->showNormal(); + topLevelWidget()->setActiveWindow(); + topLevelWidget()->raise(); + mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); } void CalendarView::checkNextTimerAlarm() { mCalendar->checkAlarmForIncidence( 0, true ); } void CalendarView::computeAlarm( QString msg ) { QString mess = msg; QString mAlarmMessage = mess.mid( 9 ); QString filename = MainWindow::resourcePath(); filename += "koalarm.wav"; QString tempfilename; if ( mess.left( 13 ) == "suspend_alarm") { bool error = false; int len = mess.mid( 13 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 13, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 13+len+3 ); //qDebug("suspend file %s ",tempfilename.latin1() ); startAlarm( mAlarmMessage, filename); return; } if ( mess.left( 11 ) == "timer_alarm") { //mTimerTime = 0; startAlarm( mess.mid( 11 ), filename ); return; } if ( mess.left( 10 ) == "proc_alarm") { bool error = false; int len = mess.mid( 10 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 10, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( error ) { mAlarmMessage = "Procedure Alarm\nError - File not found\n"; mAlarmMessage += mess.mid( 10+len+3+9 ); } else { //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); //qDebug("-----system command %s ",tempfilename.latin1() ); #ifndef _WIN32_ if ( vfork () == 0 ) { execl ( tempfilename.latin1(), 0 ); return; } #else QProcess* p = new QProcess(); @@ -4033,85 +4038,95 @@ void CalendarView::setSyncManager(KSyncManager* manager) void CalendarView::removeSyncInfo( QString syncProfile) { qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); mCalendar->removeSyncInfo( syncProfile ); } void CalendarView::undo_delete() { //qDebug("undo_delete() "); Incidence* undo = mCalendar->undoIncidence(); if ( !undo ) { KMessageBox::sorry(this,i18n("There is nothing to undo!"), i18n("KO/Pi")); return; } if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + i18n("\nAre you sure you want\nto restore this?"), i18n("KO/Pi Confirmation"),i18n("Restore"))) { mCalendar->undoDeleteIncidence(); 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; QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { QString sum = mCalendar->nextSummary(); QDateTime nextA = mNextAlarmDateTime; 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"); + //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"); - + if ( message.isEmpty() ) + message = i18n("The next alarm is in\nless than one minute!"); + else + message = i18n("The next alarm is in:\n") + message; 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."); } +#ifdef DESKTOP_VERSION + if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { + message += i18n("\nThe internal alarm notification is disabled!\n"); + message += i18n("Enable it in the settings menu, TAB alarm."); + } + +#endif KMessageBox::information( this, message); } |