00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "kshowmail.h"
00019
00020 KShowmail::KShowmail() : KXmlGuiWindow()
00021 {
00022
00023 forceExit = false;
00024
00025
00026 accounts = new AccountList( this );
00027 connect( accounts, SIGNAL( sigMessageWindowOpened() ), this, SLOT( slotNormalCursor() ) );
00028 connect( accounts, SIGNAL( sigAllMessageWindowsClosed() ), this, SLOT( slotWaitingCursor() ) );
00029 connect( accounts, SIGNAL( sigRefreshReady() ), this, SLOT( slotRefreshReady() ) );
00030 connect( accounts, SIGNAL( sigDeleteReady() ), this, SLOT( slotDeletionReady() ) );
00031 connect( accounts, SIGNAL( sigShowBodiesReady() ), this, SLOT( slotShowMessageReady() ) );
00032
00033
00034
00035 accountModel = new AccountViewModel( accounts, this );
00036 connect( accountModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( slotConfChanged() ) );
00037 mailModel = new MailViewModel( accounts, this );
00038
00039
00040 mailSelectModel = new QItemSelectionModel( mailModel );
00041 accountSelectModel = new QItemSelectionModel( accountModel );
00042
00043
00044 view = new KShowmailView( accountModel, mailModel, mailSelectModel, accountSelectModel, this );
00045 setCentralWidget( view );
00046
00047
00048 initStatusBar();
00049
00050
00051 initActions();
00052
00053
00054 view->addActionToAccountList( actionRefresh );
00055 view->addActionToAccountList( actionSetupAccount );
00056 view->addActionToMailList( actionShowHeader );
00057 view->addActionToMailList( actionShowMessage );
00058 view->addActionToMailList( actionDelete );
00059 view->addActionToMailList( actionAddWhitelist );
00060 view->addActionToMailList( actionAddBlacklist );
00061
00062
00063 connect( view, SIGNAL( sigMailDoubleClicked() ), this, SLOT( slotMailDoubleClicked() ) );
00064
00065
00066
00067
00068
00069
00070
00071 setupGUI();
00072
00073
00074 config = KGlobal::config();
00075 configGeneral = new KConfigGroup( config, CONFIG_GROUP_GENERAL );
00076
00077
00078 trayIcon = new SystemTrayIcon( this, QIcon( KStandardDirs::locate( "data", "kshowmail/pics/trayIcon.png" ) ), actionRefresh );
00079 trayIcon->show();
00080
00081
00082 accounts->loadSetup();
00083 view->loadSetup();
00084
00085
00086 if( configGeneral->readEntry( CONFIG_ENTRY_STORE_HEADERS, DEFAULT_STORE_HEADERS ) ) {
00087 accounts->readStoredMails();
00088 }
00089
00090
00091 view->refreshViews( mailSelectModel );
00092
00093
00094 mediaObject = new Phonon::MediaObject( this );
00095 audioOutput = new Phonon::AudioOutput( Phonon::MusicCategory, this );
00096 Phonon::createPath( mediaObject, audioOutput );
00097
00098
00099 newMailDlg = new NewMailDialog( this );
00100 connect( newMailDlg, SIGNAL( cancelClicked() ), this, SLOT( slotShowMainWindow() ) );
00101
00102
00103 refreshTimer = new QTimer( this );
00104 connect( refreshTimer, SIGNAL( timeout() ), this, SLOT( slotRefreshTimer() ) );
00105
00106
00107 state = idle;
00108
00109
00110 startAutomaticRefresh( true );
00111
00112
00113 }
00114
00115 KShowmail::~KShowmail()
00116 {
00117 }
00118
00119 void KShowmail::initActions()
00120 {
00121
00122 KStandardAction::quit( this, SLOT( slotFileQuit() ), actionCollection() );
00123
00124
00125 actionRefresh = actionCollection()->addAction( "refresh" );
00126 actionRefresh->setText( i18nc( "@action:inmenu look for new messages", "Refresh messages" ) );
00127 actionRefresh->setIcon( KIcon( "view-refresh" ) );
00128 actionRefresh->setShortcut( Qt::Key_F5 );
00129 connect( actionRefresh, SIGNAL( triggered() ), this, SLOT( slotRefresh() ) );
00130
00131 actionShowHeader = actionCollection()->addAction( "show_header" );
00132 actionShowHeader->setText( i18nc( "@action:inmenu show the headers of the selected mails", "Show header of highlighted messages" ) );
00133 actionShowHeader->setIcon( KIcon( "mail-mark-unread" ) );
00134 actionShowHeader->setShortcut( Qt::Key_F2 );
00135 connect( actionShowHeader, SIGNAL( triggered() ), this, SLOT( slotShowHeader() ) );
00136
00137 actionShowMessage = actionCollection()->addAction( "show_complete" );
00138 actionShowMessage->setText( i18nc( "@action:inmenu show the body of the selected mails", "Show complete highlighted messages" ) );
00139 actionShowMessage->setIcon( KIcon( "mail-mark-read" ) );
00140 actionShowMessage->setShortcut( Qt::Key_F3 );
00141 connect( actionShowMessage, SIGNAL( triggered() ), this, SLOT( slotShowMessage() ) );
00142
00143 actionDelete = actionCollection()->addAction( "delete" );
00144 actionDelete->setText( i18nc( "@action:inmenu delete selected mails", "Delete highlighted messages" ) );
00145 actionDelete->setIcon( KIcon( "draw-eraser" ) );
00146 actionDelete->setShortcut( Qt::Key_Delete );
00147 connect( actionDelete, SIGNAL( triggered() ), this, SLOT( slotDelete() ) );
00148
00149 actionStop = actionCollection()->addAction( "stop" );
00150 actionStop->setText( i18nc( "@action:inmenu cancle the current running task", "Stop current transfer" ) );
00151 actionStop->setIcon( KIcon( "dialog-cancel" ) );
00152 connect( actionStop, SIGNAL( triggered() ), this, SLOT( slotStop() ) );
00153
00154 actionShowFilterLog = actionCollection()->addAction( "show_filterlog" );
00155 actionShowFilterLog->setText( i18nc( "@action:inmenu open the filter log", "Show Filter Log" ) );
00156 actionShowFilterLog->setIcon( KIcon( "text-x-log" ) );
00157 actionShowFilterLog->setShortcut( Qt::Key_F4 );
00158 connect( actionShowFilterLog, SIGNAL( triggered() ), this, SLOT( slotShowFilterLog() ) );
00159
00160 actionAddWhitelist = actionCollection()->addAction( "addWhitelist" );
00161 actionAddWhitelist->setText( i18nc( "@action:inmenu add the senders of selected mails to the whitelist", "Add sender to whitelist" ) );
00162 actionAddWhitelist->setIcon( KIcon( "list-add-user" ) );
00163 connect( actionAddWhitelist, SIGNAL( triggered() ), this, SLOT( slotAddToWhitelist() ) );
00164
00165 actionAddBlacklist = actionCollection()->addAction( "addBlacklist" );
00166 actionAddBlacklist->setText( i18nc( "@action:inmenu add the senders of selected mails to the blacklist", "Add sender to blacklist" ) );
00167 actionAddBlacklist->setIcon( KIcon( "list-remove-user" ) );
00168 connect( actionAddBlacklist, SIGNAL( triggered() ), this, SLOT( slotAddToBlacklist() ) );
00169
00170
00171
00172 KStandardAction::preferences( this, SLOT( slotSetup() ), actionCollection() );
00173
00174
00175 KAction* actionSendFeedback = actionCollection()->addAction( "sendFeedback" );
00176 actionSendFeedback->setText( i18nc( "@action:inmenu open a dialog to send a feedback", "Send Feedback Mail" ) );
00177 actionSendFeedback->setIcon( KIcon( "mail-flag" ) );
00178 connect( actionSendFeedback, SIGNAL( triggered() ), this, SLOT( slotSendFeedbackMail() ) );
00179
00180
00181 actionSetupAccount = actionCollection()->addAction( "setupAccount" );
00182 actionSetupAccount->setText( i18nc( "@action:inmenu setup the selected account", "Setup this account") );
00183 actionSetupAccount->setIcon( KIcon( "configure") );
00184 connect( actionSetupAccount, SIGNAL( triggered() ), this, SLOT( slotSetupAccount() ) );
00185
00186
00187
00188 }
00189
00190 void KShowmail::slotRefresh() {
00191
00192
00193 if ( state != idle )
00194 {
00195 return;
00196 }
00197
00198
00199 refreshTimer->stop();
00200
00201
00202 state = refreshing;
00203
00204
00205 showStatusMessage( i18nc( "@info:status application is getting mails from the servers", "Refreshing ..." ) );
00206
00207
00208 trayIcon->showLooking();
00209
00210
00211 QApplication::setOverrideCursor( Qt::WaitCursor );
00212
00213
00214 accounts->refreshMailLists( &fLog );
00215 }
00216
00217 void KShowmail::slotShowHeader() {
00218
00219
00220 if( state != idle )
00221 {
00222 kapp->beep ();
00223 return;
00224 }
00225
00226
00227 QList<Mail> mailList = mailModel->getSelectedMails( mailSelectModel );
00228
00229
00230 QListIterator<Mail> itMails( mailList );
00231 int dialogReturnValue = KDialog::Accepted;
00232 while( itMails.hasNext() && dialogReturnValue == KDialog::Accepted )
00233 {
00234 Mail mail = itMails.next();
00235
00236
00237 QString account( mail.getAccountName() );
00238 QString subject( mail.getSubject() );
00239 QPointer<ShowHeaderDialog> dlg = new ShowHeaderDialog( this->centralWidget(), account , subject, mail.getHeader() );
00240 dialogReturnValue = dlg->exec();
00241
00242 delete dlg;
00243 }
00244 }
00245
00246 void KShowmail::slotShowMessage() {
00247
00248
00249 if( state != idle )
00250 {
00251 kapp->beep ();
00252 return;
00253 }
00254
00255
00256 if( !mailSelectModel->hasSelection() )
00257 return;
00258
00259
00260 state = showing;
00261
00262
00263 showStatusMessage( i18nc( "@info:status application is downloading mails to show", "Downloading ..." ) );
00264
00265
00266 QApplication::setOverrideCursor( Qt::WaitCursor );
00267
00268
00269 QList<Mail> mailsToShow = mailModel->getSelectedMails( mailSelectModel );
00270
00271
00272 QListIterator<Mail> itShow( mailsToShow );
00273 while( itShow.hasNext() ) {
00274
00275 Mail mail = itShow.next();
00276 mail.getAccount()->addMailToShow( mail.getNumber() );
00277 }
00278
00279 accounts->showMails();
00280
00281
00282 }
00283
00284 void KShowmail::slotDelete() {
00285
00286
00287 if( state != idle )
00288 {
00289 kapp->beep();
00290 return;
00291 }
00292
00293
00294 if( !mailSelectModel->hasSelection() )
00295 return;
00296
00297
00298 bool confirmDeletion = configGeneral->readEntry( CONFIG_ENTRY_CONFIRM_DELETE, DEFAULT_CONFIRM_DELETE );
00299
00300
00301
00302 if( confirmDeletion )
00303 {
00304
00305
00306 QStringList subjects = mailModel->getSelectedSubjects( mailSelectModel );
00307
00308
00309 int answer = KMessageBox::questionYesNoList( this, i18nc( "@info ask for delete the mails", "Do you want to delete these mails?"), subjects, i18nc( "@title:window ask for delete the mails", "Delete?" ) );
00310
00311 if( answer == KMessageBox::No )
00312 return;
00313 }
00314
00315
00316
00317 state = deleting;
00318
00319
00320 showStatusMessage( i18nc( "@info:status application is removing mails from server", "Deleting Mail(s) ..." ) );
00321
00322
00323 QApplication::setOverrideCursor( Qt::WaitCursor );
00324
00325
00326 QList<Mail> mailsToDelete = mailModel->getSelectedMails( mailSelectModel );
00327
00328
00329 QListIterator<Mail> itDel( mailsToDelete );
00330 while( itDel.hasNext() ) {
00331
00332 Mail mail = itDel.next();
00333
00334 QPointer<Account> acc = mail.getAccount();
00335
00336 int mailNumber = mail.getNumber();
00337
00338 acc->addMailToDelete( mailNumber );
00339
00340 }
00341
00342 accounts->deleteMails();
00343
00344 }
00345
00346 void KShowmail::slotStop() {
00347 accounts->cancelTasks();
00348 }
00349
00350 void KShowmail::slotShowFilterLog() {
00351
00352
00353 QPointer<FilterLogView> view = new FilterLogView( this, &fLog );
00354 view->exec();
00355
00356 delete view;
00357
00358 refreshFilterStatusBar();
00359 }
00360
00361 void KShowmail::slotAddToBlacklist() {
00362
00363
00364 QStringList senders = mailModel->getSelectedSenders( mailSelectModel );
00365
00366
00367 KConfigGroup* config = new KConfigGroup( KGlobal::config(), CONFIG_GROUP_FILTER );
00368 QStringList blackList = config->readEntry( CONFIG_ENTRY_FILTER_BLACKLIST, QStringList() );
00369
00370
00371 blackList.append( senders );
00372
00373
00374 config->writeEntry( CONFIG_ENTRY_FILTER_BLACKLIST, blackList );
00375 config->sync();
00376
00377 delete config;
00378
00379
00380 accounts->refreshFilterSetup();
00381 view->loadSetup();
00382
00383 }
00384
00385 void KShowmail::slotAddToWhitelist() {
00386
00387
00388 QStringList senders = mailModel->getSelectedSenders( mailSelectModel );
00389
00390
00391 KConfigGroup* config = new KConfigGroup( KGlobal::config(), CONFIG_GROUP_FILTER );
00392 QStringList whiteList = config->readEntry( CONFIG_ENTRY_FILTER_WHITELIST, QStringList() );
00393
00394
00395 whiteList.append( senders );
00396
00397
00398 config->writeEntry( CONFIG_ENTRY_FILTER_WHITELIST, whiteList );
00399 config->sync();
00400
00401 delete config;
00402
00403
00404 accounts->refreshFilterSetup();
00405 view->loadSetup();
00406 }
00407
00408 void KShowmail::slotSetup() {
00409
00410
00411 view->saveSetup();
00412
00413
00414 setupDialog = new KCMultiDialog( this );
00415 setupDialog->addModule( "kshowmailconfiggeneral.desktop" );
00416 setupDialog->addModule( "kshowmailconfigaccounts.desktop" );
00417 setupDialog->addModule( "kshowmailconfigactions.desktop" );
00418 setupDialog->addModule( "kshowmailconfigdisplay.desktop" );
00419 setupDialog->addModule( "kshowmailconfigfilter.desktop" );
00420 setupDialog->addModule( "kshowmailconfigspamcheck.desktop" );
00421 setupDialog->addModule( "kshowmailconfiglog.desktop" );
00422
00423 setupDialog->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
00424
00425
00426 connect( setupDialog, SIGNAL( configCommitted() ), this, SLOT( slotConfChanged() ) );
00427
00428
00429 setupDialog->exec();
00430
00431
00432 delete setupDialog;
00433
00434
00435 }
00436
00437 void KShowmail::slotSendFeedbackMail() {
00438 kDebug() << "slotSendFeedbackMail" << endl;
00439 }
00440
00441 void KShowmail::slotFileQuit() {
00442
00443
00444 if( configGeneral->readEntry( CONFIG_ENTRY_CONFIRM_CLOSE, DEFAULT_CONFIRM_CLOSE ) ) {
00445
00446 if( askCloseConfirmation() == false )
00447 return;
00448 }
00449
00450
00451 forceExit = true;
00452
00453
00454 kapp->closeAllWindows();
00455 }
00456
00457 bool KShowmail::queryClose() {
00458
00459
00460 KConfigGroup* confGeneral = new KConfigGroup( KGlobal::config(), CONFIG_GROUP_GENERAL );
00461
00462
00463 fLog.save();
00464 config->sync();
00465
00466 if( confGeneral->readEntry( CONFIG_ENTRY_STORE_HEADERS, DEFAULT_STORE_HEADERS ) ) {
00467 accounts->saveMails();
00468 }
00469
00470 view->saveSetup();
00471
00472
00473 if( forceExit ) {
00474 return true;
00475 }
00476
00477
00478 if( configGeneral->readEntry( CONFIG_ENTRY_CLOSE_TO_TRAY, DEFAULT_CLOSE_TO_TRAY ) ) {
00479
00480 hide();
00481 return false;
00482 }
00483
00484
00485 if( configGeneral->readEntry( CONFIG_ENTRY_CONFIRM_CLOSE, DEFAULT_CONFIRM_CLOSE ) ) {
00486
00487 if( askCloseConfirmation() == true )
00488 return true;
00489 }
00490
00491 return true;
00492 }
00493
00494 void KShowmail::slotConfChanged() {
00495
00496 accounts->loadSetup();
00497 fLog.loadSetup();
00498 view->loadSetup();
00499
00500
00501 view->refreshViews( mailSelectModel );
00502
00503
00504 startAutomaticRefresh();
00505
00506
00507 }
00508
00509 void KShowmail::showStatusMessage( const QString& text)
00510 {
00511
00512 statusBar()->changeItem( text, STATUSBAR_FIELD_STATE );
00513 }
00514
00515 void KShowmail::initStatusBar()
00516 {
00517 statusBar()->insertPermanentItem( i18nc( "@info:status application is idle", "Ready" ), STATUSBAR_FIELD_STATE );
00518 statusBar()->insertPermanentItem( "", STATUSBAR_FIELD_FILTER, 1 );
00519 statusBar()->setItemAlignment( STATUSBAR_FIELD_FILTER, Qt::AlignLeft | Qt::AlignVCenter );
00520 statusBar()->insertPermanentItem( "", STATUSBAR_FIELD_NEXT_REFRESH );
00521 statusBar()->insertPermanentItem( "", STATUSBAR_FIELD_LAST_REFRESH );
00522
00523 statusBar()->setSizeGripEnabled( true );
00524
00525 statusBar()->setToolTip( i18nc( "@info:tooltip", "Shows the number of deleted, moved or ignored mails by the filter.\nThe positions denotes:\nby last refresh / since application start / listed by the log" ) );
00526 statusBar()->show();
00527
00528 refreshFilterStatusBar();
00529
00530 }
00531
00532 void KShowmail::slotRefreshReady()
00533 {
00534
00535 state = idle;
00536
00537
00538 while( QApplication::overrideCursor() )
00539 QApplication::restoreOverrideCursor();
00540
00541
00542 showStatusMessage( i18nc( "@info:status application is idle", "Ready" ) );
00543
00544
00545 view->refreshViews( mailSelectModel );
00546
00547
00548 refreshFilterStatusBar();
00549
00550
00551 trayIcon->drawNumber( accounts->getNumberMails(), accounts->getNumberNewMails() != 0 ? Qt::red : Qt::black );
00552
00553
00554 QString sTime = QTime::currentTime().toString ();
00555 statusBar()->changeItem( i18nc( "@info:status time of the last refresh", "Last Refresh: %1", sTime ), STATUSBAR_FIELD_LAST_REFRESH );
00556
00557
00558 if( accounts->getNumberNewMails() > 0 ) {
00559
00560 handleNewMails();
00561
00562 } else {
00563
00564 handleNoNewMails();
00565 }
00566
00567
00568 KConfigGroup* confGeneral = new KConfigGroup( KGlobal::config(), CONFIG_GROUP_GENERAL );
00569
00570 if( confGeneral->readEntry( CONFIG_ENTRY_STORE_HEADERS, DEFAULT_STORE_HEADERS ) ) {
00571 accounts->saveMails();
00572 }
00573
00574
00575
00576 startAutomaticRefresh();
00577
00578 }
00579
00580 void KShowmail::slotNormalCursor( )
00581 {
00582
00583 while( QApplication::overrideCursor() )
00584 QApplication::restoreOverrideCursor();
00585
00586 }
00587
00588 void KShowmail::slotWaitingCursor( )
00589 {
00590
00591 if( state != idle )
00592 QApplication::setOverrideCursor( Qt::WaitCursor );
00593 }
00594
00595 void KShowmail::slotDeletionReady( )
00596 {
00597
00598 state = idle;
00599
00600
00601 while( QApplication::overrideCursor() )
00602 QApplication::restoreOverrideCursor();
00603
00604
00605 showStatusMessage( i18nc( "@info:status application is idle", "Ready." ) );
00606
00607
00608 slotRefresh();
00609 }
00610
00611 void KShowmail::refreshFilterStatusBar( )
00612 {
00613 int numberDeletedLastRefresh = accounts->numberDeletedMailsLastRefresh();
00614 int numberDeletedSinceStart = accounts->numberDeletedMailsStart();
00615 int numberDeletedLog = fLog.numberFilterDeletedMails();
00616
00617 int numberMovedLastRefresh = accounts->numberMovedMailsLastRefresh();
00618 int numberMovedSinceStart = accounts->numberMovedMailsStart();
00619 int numberMovedLog = fLog.numberMovedMails();
00620
00621 int numberIgnored = accounts->numberIgnoredMails();
00622
00623 statusBar()->changeItem( i18nc( "@info:status numbers of filtered mails", "Filter: Deleted: %1/%2/%3; Moved: %4/%5/%6; Ignored: %7", numberDeletedLastRefresh, numberDeletedSinceStart, numberDeletedLog, numberMovedLastRefresh, numberMovedSinceStart, numberMovedLog, numberIgnored ), STATUSBAR_FIELD_FILTER );
00624 }
00625
00626 void KShowmail::slotShowMessageReady( )
00627 {
00628
00629 state = idle;
00630
00631
00632 while( QApplication::overrideCursor() )
00633 QApplication::restoreOverrideCursor();
00634
00635
00636 showStatusMessage( i18nc( "@info:status application is idle", "Ready." ) );
00637
00638
00639 }
00640
00641 void KShowmail::startAutomaticRefresh( bool initiate ) {
00642
00643
00644 if( configGeneral->readEntry( CONFIG_ENTRY_AUTO_REFRESH, DEFAULT_AUTO_REFRESH ) ) {
00645
00646
00647 if( initiate ) {
00648
00649 timeToRefresh = configGeneral->readEntry( CONFIG_ENTRY_INITIAL_TIME, DEFAULT_INITIAL_TIME );
00650
00651 } else {
00652
00653 timeToRefresh = configGeneral->readEntry( CONFIG_ENTRY_INTERVAL_TIME, DEFAULT_INTERVAL_TIME ) * 60;
00654 }
00655
00656
00657 refreshTimer->start( 1000 );
00658
00659 } else {
00660
00661 refreshTimer->stop();
00662 }
00663
00664
00665 }
00666
00667 void KShowmail::slotRefreshTimer() {
00668
00669
00670 timeToRefresh--;
00671
00672
00673 QTime time;
00674 time = time.addSecs( timeToRefresh );
00675
00676 statusBar()->changeItem( i18nc( "@info:status time to next refresh", "Next Refresh: %1", time.toString() ), STATUSBAR_FIELD_NEXT_REFRESH );
00677
00678
00679 if( timeToRefresh == 0 ) {
00680
00681 stopAutomaticRefresh();
00682 slotRefresh();
00683 }
00684
00685 }
00686
00687 void KShowmail::stopAutomaticRefresh() {
00688
00689 refreshTimer->stop();
00690 timeToRefresh = 0;
00691
00692 }
00693
00694 void KShowmail::slotSetupAccount() {
00695
00696 if( !accountSelectModel->hasSelection() ) return;
00697
00698
00699
00700 QModelIndex selIndex = accountSelectModel->selectedRows().first();
00701 Account* acc = accountModel->getAccount( selIndex );
00702
00703
00704 QPointer<AccountSetupDialogContext> dlg = new AccountSetupDialogContext( this, acc->getName() );
00705 int res = dlg->exec();
00706
00707
00708 if( res == KDialog::Accepted )
00709 slotConfChanged();
00710
00711
00712 delete dlg;
00713
00714 }
00715
00716 void KShowmail::handleNewMails()
00717 {
00718
00719 KConfigGroup* conf = new KConfigGroup( KGlobal::config(), CONFIG_GROUP_ACTIONS );
00720
00721
00722 if( conf->readEntry( CONFIG_ENTRY_NEW_MAIL_SOUND, DEFAULT_ACTION_NEW_MAIL_SOUND ) ) {
00723
00724
00725 QString file = conf->readEntry( CONFIG_ENTRY_NEW_MAIL_SOUNDPATH, "" );
00726 if( file.length() != 0 )
00727 {
00728 mediaObject->setCurrentSource( Phonon::MediaSource( file ) );
00729 mediaObject->play();
00730
00731 }
00732
00733 }
00734
00735 if( conf->readEntry( CONFIG_ENTRY_NEW_MAIL_ALERTWINDOW, DEFAULT_ACTION_NEW_MAIL_ALERTWINDOW) ) {
00736
00737 newMailDlg->show();
00738 }
00739
00740 if( conf->readEntry( CONFIG_ENTRY_NEW_MAIL_MAINWINDOW, DEFAULT_ACTION_NEW_MAIL_MAINWINDOW ) ) {
00741
00742 slotShowMainWindow();
00743 }
00744
00745 if( conf->readEntry( CONFIG_ENTRY_NEW_MAIL_BEEP, DEFAULT_ACTION_NEW_MAIL_BEEP ) ) {
00746
00747 kapp->beep();
00748 }
00749
00750 if( conf->readEntry( CONFIG_ENTRY_NEW_MAIL_COMMAND, DEFAULT_ACTION_NEW_MAIL_COMMAND ) ) {
00751
00752
00753 QString command = conf->readEntry( CONFIG_ENTRY_NEW_MAIL_COMMANDPATH, "" );
00754
00755
00756 if( command.length() > 0 ) {
00757
00758 QStringList parts = command.split( ' ', QString::SkipEmptyParts );
00759
00760 if( !command.isEmpty() )
00761 {
00762 KProcess::execute( parts );
00763 }
00764
00765 }
00766
00767 }
00768
00769 delete conf;
00770
00771 }
00772
00773 void KShowmail::slotShowMainWindow()
00774 {
00775 show();
00776 setWindowState( windowState() & ~Qt::WindowMinimized );
00777 }
00778
00779 void KShowmail::handleNoNewMails()
00780 {
00781
00782
00783 KConfigGroup* conf = new KConfigGroup( KGlobal::config(), CONFIG_GROUP_ACTIONS );
00784
00785 if( conf->readEntry( CONFIG_ENTRY_NO_NEW_MAIL_MINIMIZE, DEFAULT_ACTION_NO_NEW_MAIL_MINIMIZE ) ) {
00786
00787 hide();
00788 }
00789
00790 if( conf->readEntry( CONFIG_ENTRY_NO_NEW_MAIL_TERMINATE, DEFAULT_ACTION_NO_NEW_MAIL_TERMINATE ) ) {
00791
00792 forceExit = true;
00793 kapp->closeAllWindows();
00794 }
00795 }
00796
00797 bool KShowmail::askCloseConfirmation()
00798 {
00799 return KMessageBox::questionYesNo( this, i18nc( "@info ask for closing the application", "KShowmail will be closed.\nAre you sure?") ) == KMessageBox::Yes;
00800
00801 }
00802
00803 void KShowmail::slotMailDoubleClicked()
00804 {
00805
00806
00807 KConfigGroup* conf = new KConfigGroup( KGlobal::config(), CONFIG_GROUP_GENERAL );
00808
00809 if( conf->readEntry( CONFIG_ENTRY_MAIL_DOUBLE_CLICK_ACTION, DEFAULT_MAIL_DOUBLE_CLICK_ACTION) == CONFIG_VALUE_MAIL_DOUBLE_CLICK_ACTION_BODY ) {
00810
00811 slotShowMessage();
00812
00813 } else if( conf->readEntry( CONFIG_ENTRY_MAIL_DOUBLE_CLICK_ACTION, DEFAULT_MAIL_DOUBLE_CLICK_ACTION) == CONFIG_VALUE_MAIL_DOUBLE_CLICK_ACTION_HEADER ) {
00814
00815 slotShowHeader();
00816 }
00817
00818 delete conf;
00819 }
00820
00821
00822 #include "kshowmail.moc"