00001
00002
00003
00004
00005 #ifdef HAVE_CONFIG_H
00006 #include <config.h>
00007 #endif
00008
00009 #include <kwin.h>
00010
00011 #ifdef MALLOC_DEBUG
00012 #include <malloc.h>
00013 #endif
00014
00015 #undef Unsorted // X headers...
00016 #include <qaccel.h>
00017 #include <qlayout.h>
00018 #include <qhbox.h>
00019 #include <qvbox.h>
00020 #include <qpopupmenu.h>
00021 #include <qptrlist.h>
00022
00023 #include <kopenwith.h>
00024
00025 #include <kmessagebox.h>
00026
00027 #include <kpopupmenu.h>
00028 #include <kaccelmanager.h>
00029 #include <kglobalsettings.h>
00030 #include <kstdaccel.h>
00031 #include <kkeydialog.h>
00032 #include <kcharsets.h>
00033 #include <knotifyclient.h>
00034 #include <kdebug.h>
00035 #include <kapplication.h>
00036 #include <kfiledialog.h>
00037 #include <ktip.h>
00038 #include <knotifydialog.h>
00039 #include <kstandarddirs.h>
00040 #include <dcopclient.h>
00041 #include <kaddrbook.h>
00042 #include <kaccel.h>
00043 #include <kstringhandler.h>
00044
00045 #include <qvaluevector.h>
00046
00047 #include "globalsettings.h"
00048 #include "kcursorsaver.h"
00049 #include "broadcaststatus.h"
00050 using KPIM::BroadcastStatus;
00051 #include "kmfoldermgr.h"
00052 #include "kmfolderdia.h"
00053 #include "accountmanager.h"
00054 using KMail::AccountManager;
00055 #include "kmfilter.h"
00056 #include "kmfoldertree.h"
00057 #include "kmreadermainwin.h"
00058 #include "kmfoldercachedimap.h"
00059 #include "kmfolderimap.h"
00060 #include "kmacctcachedimap.h"
00061 #include "composer.h"
00062 #include "kmfolderseldlg.h"
00063 #include "kmfiltermgr.h"
00064 #include "messagesender.h"
00065 #include "kmaddrbook.h"
00066 #include "kmversion.h"
00067 #include "searchwindow.h"
00068 using KMail::SearchWindow;
00069 #include "kmacctfolder.h"
00070 #include "undostack.h"
00071 #include "kmcommands.h"
00072 #include "kmmainwin.h"
00073 #include "kmsystemtray.h"
00074 #include "imapaccountbase.h"
00075 #include "transportmanager.h"
00076 using KMail::ImapAccountBase;
00077 #include "vacation.h"
00078 using KMail::Vacation;
00079 #include "favoritefolderview.h"
00080
00081 #include <qsignalmapper.h>
00082
00083 #include "subscriptiondialog.h"
00084 using KMail::SubscriptionDialog;
00085 #include "localsubscriptiondialog.h"
00086 using KMail::LocalSubscriptionDialog;
00087 #include "attachmentstrategy.h"
00088 using KMail::AttachmentStrategy;
00089 #include "headerstrategy.h"
00090 using KMail::HeaderStrategy;
00091 #include "headerstyle.h"
00092 using KMail::HeaderStyle;
00093 #include "folderjob.h"
00094 using KMail::FolderJob;
00095 #include "mailinglist-magic.h"
00096 #include "antispamwizard.h"
00097 using KMail::AntiSpamWizard;
00098 #include "filterlogdlg.h"
00099 using KMail::FilterLogDialog;
00100 #include <headerlistquicksearch.h>
00101 #include "klistviewindexedsearchline.h"
00102 using KMail::HeaderListQuickSearch;
00103 #include "kmheaders.h"
00104 #include "mailinglistpropertiesdialog.h"
00105 #include "templateparser.h"
00106
00107 #if !defined(NDEBUG)
00108 #include "sievedebugdialog.h"
00109 using KMail::SieveDebugDialog;
00110 #endif
00111
00112 #include <libkpimidentities/identity.h>
00113 #include <libkpimidentities/identitymanager.h>
00114
00115 #include <assert.h>
00116 #include <kstatusbar.h>
00117 #include <kstaticdeleter.h>
00118 #include <kaction.h>
00119
00120 #include <kmime_mdn.h>
00121 #include <kmime_header_parsing.h>
00122 using namespace KMime;
00123 using KMime::Types::AddrSpecList;
00124
00125 #include "progressmanager.h"
00126 using KPIM::ProgressManager;
00127
00128 #include "managesievescriptsdialog.h"
00129 #include <qstylesheet.h>
00130
00131 #include "customtemplates.h"
00132 #include "customtemplates_kfg.h"
00133
00134 #include "kmmainwidget.moc"
00135
00136 QValueList<KMMainWidget*>* KMMainWidget::s_mainWidgetList = 0;
00137 static KStaticDeleter<QValueList<KMMainWidget*> > mwlsd;
00138
00139
00140 KMMainWidget::KMMainWidget(QWidget *parent, const char *name,
00141 KXMLGUIClient *aGUIClient,
00142 KActionCollection *actionCollection, KConfig* config ) :
00143 QWidget(parent, name),
00144 mFavoritesCheckMailAction( 0 ),
00145 mFavoriteFolderView( 0 ),
00146 mFolderView( 0 ),
00147 mFolderViewParent( 0 ),
00148 mFolderViewSplitter( 0 ),
00149 mQuickSearchLine( 0 ),
00150 mShowBusySplashTimer( 0 ),
00151 mShowingOfflineScreen( false ),
00152 mMsgActions( 0 ),
00153 mVacationIndicatorActive( false )
00154 {
00155
00156 mStartupDone = false;
00157 mSearchWin = 0;
00158 mIntegrated = true;
00159 mFolder = 0;
00160 mTemplateFolder = 0;
00161 mFolderThreadPref = false;
00162 mFolderThreadSubjPref = true;
00163 mReaderWindowActive = true;
00164 mReaderWindowBelow = true;
00165 mFolderHtmlPref = false;
00166 mFolderHtmlLoadExtPref = false;
00167 mSystemTray = 0;
00168 mDestructed = false;
00169 mActionCollection = actionCollection;
00170 mTopLayout = new QVBoxLayout(this);
00171 mFilterMenuActions.setAutoDelete(true);
00172 mFilterTBarActions.setAutoDelete(false);
00173 mFilterCommands.setAutoDelete(true);
00174 mFolderShortcutCommands.setAutoDelete(true);
00175 mJob = 0;
00176 mConfig = config;
00177 mGUIClient = aGUIClient;
00178
00179 mCustomReplyActionMenu = 0;
00180 mCustomReplyAllActionMenu = 0;
00181 mCustomForwardActionMenu = 0;
00182 mCustomReplyMapper = 0;
00183 mCustomReplyAllMapper = 0;
00184 mCustomForwardMapper = 0;
00185
00186
00187
00188 mToolbarActionSeparator = new KActionSeparator( actionCollection );
00189
00190 if( !s_mainWidgetList )
00191 mwlsd.setObject( s_mainWidgetList, new QValueList<KMMainWidget*>() );
00192 s_mainWidgetList->append( this );
00193
00194 mPanner1Sep << 1 << 1;
00195 mPanner2Sep << 1 << 1;
00196
00197 setMinimumSize(400, 300);
00198
00199 readPreConfig();
00200 createWidgets();
00201
00202 setupActions();
00203
00204 readConfig();
00205
00206 activatePanners();
00207
00208 QTimer::singleShot( 0, this, SLOT( slotShowStartupFolder() ));
00209
00210 connect( kmkernel->acctMgr(), SIGNAL( checkedMail( bool, bool, const QMap<QString, int> & ) ),
00211 this, SLOT( slotMailChecked( bool, bool, const QMap<QString, int> & ) ) );
00212
00213 connect( kmkernel->acctMgr(), SIGNAL( accountAdded( KMAccount* ) ),
00214 this, SLOT( initializeIMAPActions() ) );
00215 connect( kmkernel->acctMgr(), SIGNAL( accountRemoved( KMAccount* ) ),
00216 this, SLOT( initializeIMAPActions() ) );
00217
00218 connect(kmkernel, SIGNAL( configChanged() ),
00219 this, SLOT( slotConfigChanged() ));
00220
00221
00222 connect(mFolderTree, SIGNAL(currentChanged(QListViewItem*)),
00223 this, SLOT(slotChangeCaption(QListViewItem*)));
00224 connect(mFolderTree, SIGNAL(selectionChanged()),
00225 SLOT(updateFolderMenu()) );
00226
00227 connect(kmkernel->folderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00228 this, SLOT(slotFolderRemoved(KMFolder*)));
00229
00230 connect(kmkernel->imapFolderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00231 this, SLOT(slotFolderRemoved(KMFolder*)));
00232
00233 connect(kmkernel->dimapFolderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00234 this, SLOT(slotFolderRemoved(KMFolder*)));
00235
00236 connect(kmkernel->searchFolderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00237 this, SLOT(slotFolderRemoved(KMFolder*)));
00238
00239 connect( kmkernel, SIGNAL( onlineStatusChanged( GlobalSettings::EnumNetworkState::type ) ),
00240 this, SLOT( slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type ) ) );
00241
00242 toggleSystemTray();
00243
00244
00245 mStartupDone = true;
00246
00247
00248 KMainWindow *mainWin = dynamic_cast<KMainWindow*>(topLevelWidget());
00249 KStatusBar *sb = mainWin ? mainWin->statusBar() : 0;
00250 mVacationScriptIndicator = new KStatusBarLabel( QString(), 0, sb );
00251 mVacationScriptIndicator->hide();
00252 connect( mVacationScriptIndicator, SIGNAL(itemReleased(int)), SLOT(slotEditVacation()) );
00253 if ( GlobalSettings::checkOutOfOfficeOnStartup() )
00254 QTimer::singleShot( 0, this, SLOT(slotCheckVacation()) );
00255 }
00256
00257
00258
00259
00260
00261 KMMainWidget::~KMMainWidget()
00262 {
00263 s_mainWidgetList->remove( this );
00264 destruct();
00265 }
00266
00267
00268
00269
00270 void KMMainWidget::destruct()
00271 {
00272 if (mDestructed)
00273 return;
00274 if (mSearchWin)
00275 mSearchWin->close();
00276 writeConfig();
00277 writeFolderConfig();
00278 delete mHeaders;
00279 delete mFolderTree;
00280 delete mSystemTray;
00281 delete mMsgView;
00282 mDestructed = true;
00283 }
00284
00285
00286
00287 void KMMainWidget::readPreConfig(void)
00288 {
00289 const KConfigGroup geometry( KMKernel::config(), "Geometry" );
00290 const KConfigGroup reader( KMKernel::config(), "Reader" );
00291
00292 mLongFolderList = geometry.readEntry( "FolderList", "long" ) != "short";
00293 mReaderWindowActive = geometry.readEntry( "readerWindowMode", "below" ) != "hide";
00294 mReaderWindowBelow = geometry.readEntry( "readerWindowMode", "below" ) == "below";
00295 mThreadPref = geometry.readBoolEntry( "nestedMessages", false );
00296
00297 mHtmlPref = reader.readBoolEntry( "htmlMail", false );
00298 mHtmlLoadExtPref = reader.readBoolEntry( "htmlLoadExternal", false );
00299 mEnableFavoriteFolderView = GlobalSettings::self()->enableFavoriteFolderView();
00300 }
00301
00302
00303
00304 void KMMainWidget::readFolderConfig(void)
00305 {
00306 if (!mFolder)
00307 return;
00308
00309 KConfig *config = KMKernel::config();
00310 KConfigGroupSaver saver(config, "Folder-" + mFolder->idString());
00311 mFolderThreadPref = config->readBoolEntry( "threadMessagesOverride", false );
00312 mFolderThreadSubjPref = config->readBoolEntry( "threadMessagesBySubject", true );
00313 mFolderHtmlPref = config->readBoolEntry( "htmlMailOverride", false );
00314 mFolderHtmlLoadExtPref = config->readBoolEntry( "htmlLoadExternalOverride", false );
00315 }
00316
00317
00318
00319 void KMMainWidget::writeFolderConfig(void)
00320 {
00321 if (!mFolder)
00322 return;
00323
00324 KConfig *config = KMKernel::config();
00325 KConfigGroupSaver saver(config, "Folder-" + mFolder->idString());
00326 config->writeEntry( "threadMessagesOverride", mFolderThreadPref );
00327 config->writeEntry( "threadMessagesBySubject", mFolderThreadSubjPref );
00328 config->writeEntry( "htmlMailOverride", mFolderHtmlPref );
00329 config->writeEntry( "htmlLoadExternalOverride", mFolderHtmlLoadExtPref );
00330 }
00331
00332
00333
00334 void KMMainWidget::readConfig(void)
00335 {
00336 KConfig *config = KMKernel::config();
00337
00338 bool oldLongFolderList = mLongFolderList;
00339 bool oldReaderWindowActive = mReaderWindowActive;
00340 bool oldReaderWindowBelow = mReaderWindowBelow;
00341 bool oldFavoriteFolderView = mEnableFavoriteFolderView;
00342
00343 QString str;
00344 QSize siz;
00345
00346 if (mStartupDone)
00347 {
00348 writeConfig();
00349
00350 readPreConfig();
00351 mHeaders->refreshNestedState();
00352
00353 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
00354 || ( oldReaderWindowActive != mReaderWindowActive )
00355 || ( oldReaderWindowBelow != mReaderWindowBelow )
00356 || ( oldFavoriteFolderView != mEnableFavoriteFolderView );
00357
00358
00359 if( layoutChanged ) {
00360 hide();
00361
00362 delete mPanner1;
00363 createWidgets();
00364 }
00365
00366 }
00367
00368 {
00369 KConfigGroupSaver saver(config, "Geometry");
00370
00371 QSize defaultSize(750,560);
00372 siz = config->readSizeEntry("MainWin", &defaultSize);
00373 if (!siz.isEmpty())
00374 resize(siz);
00375
00376 static const int folderpanewidth = 250;
00377
00378 const int folderW = config->readNumEntry( "FolderPaneWidth", folderpanewidth );
00379 const int headerW = config->readNumEntry( "HeaderPaneWidth", width()-folderpanewidth );
00380 const int headerH = config->readNumEntry( "HeaderPaneHeight", 180 );
00381 const int readerH = config->readNumEntry( "ReaderPaneHeight", 280 );
00382
00383 mPanner1Sep.clear();
00384 mPanner2Sep.clear();
00385 QValueList<int> & widths = mLongFolderList ? mPanner1Sep : mPanner2Sep ;
00386 QValueList<int> & heights = mLongFolderList ? mPanner2Sep : mPanner1Sep ;
00387
00388 widths << folderW << headerW;
00389 heights << headerH << readerH;
00390
00391 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
00392 || ( oldReaderWindowActive != mReaderWindowActive )
00393 || ( oldReaderWindowBelow != mReaderWindowBelow );
00394
00395 if (!mStartupDone || layoutChanged )
00396 {
00400
00401
00402 const int unreadColumn = config->readNumEntry("UnreadColumn", 1);
00403 const int totalColumn = config->readNumEntry("TotalColumn", 2);
00404 const int sizeColumn = config->readNumEntry("SizeColumn", 3);
00405
00406
00407
00408
00409
00410 if (unreadColumn == 1)
00411 mFolderTree->addUnreadColumn( i18n("Unread"), 70 );
00412 else if (totalColumn == 1)
00413 mFolderTree->addTotalColumn( i18n("Total"), 70 );
00414 else if (sizeColumn == 1)
00415 mFolderTree->addSizeColumn( i18n("Size"), 70 );
00416
00417 if (unreadColumn == 2)
00418 mFolderTree->addUnreadColumn( i18n("Unread"), 70 );
00419 else if (totalColumn == 2)
00420 mFolderTree->addTotalColumn( i18n("Total"), 70 );
00421 else if (sizeColumn == 2)
00422 mFolderTree->addSizeColumn( i18n("Size"), 70 );
00423
00424 if (unreadColumn == 3)
00425 mFolderTree->addUnreadColumn( i18n("Unread"), 70 );
00426 else if (totalColumn == 3)
00427 mFolderTree->addTotalColumn( i18n("Total"), 70 );
00428 else if (sizeColumn == 3)
00429 mFolderTree->addSizeColumn( i18n("Size"), 70 );
00430
00431 mUnreadColumnToggle->setChecked( mFolderTree->isUnreadActive() );
00432 mUnreadTextToggle->setChecked( !mFolderTree->isUnreadActive() );
00433 mTotalColumnToggle->setChecked( mFolderTree->isTotalActive() );
00434 mSizeColumnToggle->setChecked( mFolderTree->isSizeActive() );
00435
00436 mFolderTree->updatePopup();
00437 }
00438 }
00439
00440 if (mMsgView)
00441 mMsgView->readConfig();
00442
00443 mHeaders->readConfig();
00444 mHeaders->restoreLayout(KMKernel::config(), "Header-Geometry");
00445
00446 if ( mFolderViewSplitter && !GlobalSettings::self()->folderViewSplitterPosition().isEmpty() ) {
00447 mFolderViewSplitter->setSizes( GlobalSettings::self()->folderViewSplitterPosition() );
00448 } else {
00449 QValueList<int> defaults;
00450 defaults << (int)(height() * 0.2) << (int)(height() * 0.8);
00451 mFolderViewSplitter->setSizes( defaults );
00452 }
00453
00454 mFolderTree->readConfig();
00455 if ( mFavoriteFolderView )
00456 mFavoriteFolderView->readConfig();
00457 mFavoritesCheckMailAction->setEnabled( GlobalSettings::self()->enableFavoriteFolderView() );
00458
00459 {
00460 KConfigGroupSaver saver(config, "General");
00461 mBeepOnNew = config->readBoolEntry("beep-on-mail", false);
00462 mConfirmEmpty = config->readBoolEntry("confirm-before-empty", true);
00463
00464 mStartupFolder = config->readEntry("startupFolder", kmkernel->inboxFolder()->idString());
00465 if (!mStartupDone)
00466 {
00467
00468 bool check = config->readBoolEntry("checkmail-startup", false);
00469 if (check)
00470
00471 QTimer::singleShot( 0, this, SLOT( slotCheckMail() ) );
00472 }
00473 }
00474
00475
00476 mFolderTree->reload();
00477
00478
00479 if (mStartupDone)
00480 {
00481
00482 toggleSystemTray();
00483
00484 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
00485 || ( oldReaderWindowActive != mReaderWindowActive )
00486 || ( oldReaderWindowBelow != mReaderWindowBelow )
00487 || ( oldFavoriteFolderView != mEnableFavoriteFolderView );
00488 if ( layoutChanged ) {
00489 activatePanners();
00490 }
00491
00492 mFolderTree->showFolder( mFolder );
00493
00494
00495 mHeaders->setFolder(mFolder);
00496 if (mMsgView) {
00497 int aIdx = mHeaders->currentItemIndex();
00498 if (aIdx != -1)
00499 mMsgView->setMsg( mFolder->getMsg(aIdx), true );
00500 else
00501 mMsgView->clear( true );
00502 }
00503 updateMessageActions();
00504 show();
00505
00506
00507 }
00508 updateMessageMenu();
00509 updateFileMenu();
00510 }
00511
00512
00513
00514 void KMMainWidget::writeConfig(void)
00515 {
00516 QString s;
00517 KConfig *config = KMKernel::config();
00518 KConfigGroup geometry( config, "Geometry" );
00519
00520 if (mMsgView)
00521 mMsgView->writeConfig();
00522
00523 if ( mFolderViewSplitter )
00524 GlobalSettings::setFolderViewSplitterPosition( mFolderViewSplitter->sizes() );
00525 mFolderTree->writeConfig();
00526 if ( mFavoriteFolderView )
00527 mFavoriteFolderView->writeConfig();
00528
00529 geometry.writeEntry( "MainWin", this->geometry().size() );
00530
00531 const QValueList<int> widths = ( mLongFolderList ? mPanner1 : mPanner2 )->sizes();
00532 const QValueList<int> heights = ( mLongFolderList ? mPanner2 : mPanner1 )->sizes();
00533
00534 geometry.writeEntry( "FolderPaneWidth", widths[0] );
00535 geometry.writeEntry( "HeaderPaneWidth", widths[1] );
00536
00537
00538 if ( mSearchAndHeaders && mSearchAndHeaders->isShown() ) {
00539 geometry.writeEntry( "HeaderPaneHeight", heights[0] );
00540 geometry.writeEntry( "ReaderPaneHeight", heights[1] );
00541 }
00542
00543
00544 geometry.writeEntry( "UnreadColumn", mFolderTree->unreadIndex() );
00545 geometry.writeEntry( "TotalColumn", mFolderTree->totalIndex() );
00546 geometry.writeEntry( "SizeColumn", mFolderTree->sizeIndex() );
00547 }
00548
00549
00550
00551 void KMMainWidget::createWidgets(void)
00552 {
00553
00554 QWidget *headerParent = 0,
00555 *mimeParent = 0, *messageParent = 0;
00556
00557 const bool opaqueResize = KGlobalSettings::opaqueResize();
00558 if ( mLongFolderList ) {
00559
00560
00561 mPanner1 = new QSplitter( Qt::Horizontal, this, "panner 1" );
00562 mPanner1->setOpaqueResize( opaqueResize );
00563 Qt::Orientation orientation = mReaderWindowBelow ? Qt::Vertical : Qt::Horizontal;
00564 mPanner2 = new QSplitter( orientation, mPanner1, "panner 2" );
00565 mPanner2->setOpaqueResize( opaqueResize );
00566 mPanner2->setChildrenCollapsible( false );
00567 mFolderViewParent = mPanner1;
00568 headerParent = mimeParent = messageParent = mPanner2;
00569 } else {
00570
00571
00572 mPanner1 = new QSplitter( Qt::Vertical, this, "panner 1" );
00573 mPanner1->setOpaqueResize( opaqueResize );
00574 mPanner1->setChildrenCollapsible( false );
00575 mPanner2 = new QSplitter( Qt::Horizontal, mPanner1, "panner 2" );
00576 mPanner2->setOpaqueResize( opaqueResize );
00577 headerParent = mFolderViewParent = mPanner2;
00578 mimeParent = messageParent = mPanner1;
00579 }
00580
00581 #ifndef NDEBUG
00582 if( mPanner1 ) mPanner1->dumpObjectTree();
00583 if( mPanner2 ) mPanner2->dumpObjectTree();
00584 #endif
00585
00586 mTopLayout->add( mPanner1 );
00587
00588
00589
00590
00591
00592
00593 #ifndef NDEBUG
00594 headerParent->dumpObjectTree();
00595 #endif
00596 mSearchAndHeaders = new QVBox( headerParent );
00597 mSearchToolBar = new KToolBar( mSearchAndHeaders, "search toolbar");
00598 mSearchToolBar->setMovingEnabled(false);
00599 mSearchToolBar->boxLayout()->setSpacing( KDialog::spacingHint() );
00600 QLabel *label = new QLabel( i18n("S&earch:"), mSearchToolBar, "kde toolbar widget" );
00601
00602
00603 mHeaders = new KMHeaders(this, mSearchAndHeaders, "headers");
00604 #ifdef HAVE_INDEXLIB
00605 mQuickSearchLine = new KListViewIndexedSearchLine( mSearchToolBar, mHeaders,
00606 actionCollection(), "headers quick search line" );
00607 #else
00608 mQuickSearchLine = new HeaderListQuickSearch( mSearchToolBar, mHeaders,
00609 actionCollection(), "headers quick search line" );
00610 #endif
00611 label->setBuddy( mQuickSearchLine );
00612 connect( mQuickSearchLine, SIGNAL( requestFullSearch() ),
00613 this, SLOT( slotRequestFullSearchFromQuickSearch() ) );
00614 mSearchToolBar->setStretchableWidget( mQuickSearchLine );
00615 connect( mHeaders, SIGNAL( messageListUpdated() ),
00616 mQuickSearchLine, SLOT( updateSearch() ) );
00617 if ( !GlobalSettings::self()->quickSearchActive() ) mSearchToolBar->hide();
00618
00619 if (mReaderWindowActive) {
00620 connect(mHeaders, SIGNAL(selected(KMMessage*)),
00621 this, SLOT(slotMsgSelected(KMMessage*)));
00622 }
00623 connect(mHeaders, SIGNAL(activated(KMMessage*)),
00624 this, SLOT(slotMsgActivated(KMMessage*)));
00625 connect( mHeaders, SIGNAL( selectionChanged() ),
00626 SLOT( startUpdateMessageActionsTimer() ) );
00627 QAccel *accel = actionCollection()->kaccel();
00628 accel->connectItem(accel->insertItem(SHIFT+Key_Left),
00629 mHeaders, SLOT(selectPrevMessage()));
00630 accel->connectItem(accel->insertItem(SHIFT+Key_Right),
00631 mHeaders, SLOT(selectNextMessage()));
00632
00633 if (mReaderWindowActive) {
00634 mMsgView = new KMReaderWin(messageParent, this, actionCollection(), 0 );
00635 if ( mMsgActions ) {
00636 mMsgActions->setMessageView( mMsgView );
00637 }
00638
00639 connect(mMsgView, SIGNAL(replaceMsgByUnencryptedVersion()),
00640 this, SLOT(slotReplaceMsgByUnencryptedVersion()));
00641 connect(mMsgView, SIGNAL(popupMenu(KMMessage&,const KURL&,const QPoint&)),
00642 this, SLOT(slotMsgPopup(KMMessage&,const KURL&,const QPoint&)));
00643 connect(mMsgView, SIGNAL(urlClicked(const KURL&,int)),
00644 mMsgView, SLOT(slotUrlClicked()));
00645 connect(mHeaders, SIGNAL(maybeDeleting()),
00646 mMsgView, SLOT(clearCache()));
00647 connect(mMsgView, SIGNAL(noDrag()),
00648 mHeaders, SLOT(slotNoDrag()));
00649 accel->connectItem(accel->insertItem(Key_Up),
00650 mMsgView, SLOT(slotScrollUp()));
00651 accel->connectItem(accel->insertItem(Key_Down),
00652 mMsgView, SLOT(slotScrollDown()));
00653 accel->connectItem(accel->insertItem(Key_Prior),
00654 mMsgView, SLOT(slotScrollPrior()));
00655 accel->connectItem(accel->insertItem(Key_Next),
00656 mMsgView, SLOT(slotScrollNext()));
00657 } else {
00658 mMsgView = NULL;
00659 }
00660
00661 KAction *action;
00662
00663 mMoveMsgToFolderAction = new KAction( i18n("Move Message to Folder"), Key_M, this,
00664 SLOT(slotMoveMsg()), actionCollection(),
00665 "move_message_to_folder" );
00666 mMoveMsgToFolderAction->plugAccel( actionCollection()->kaccel() );
00667
00668 action = new KAction( i18n("Copy Message to Folder"), Key_C, this,
00669 SLOT(slotCopyMsg()), actionCollection(),
00670 "copy_message_to_folder" );
00671 action->plugAccel( actionCollection()->kaccel() );
00672
00673 action = new KAction( i18n("Jump to Folder"), Key_J, this,
00674 SLOT(slotJumpToFolder()), actionCollection(),
00675 "jump_to_folder" );
00676 action->plugAccel( actionCollection()->kaccel() );
00677
00678
00679 mFolderViewSplitter = new QSplitter( Qt::Vertical, mFolderViewParent );
00680 mFolderViewSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() );
00681 mFavoriteFolderView = new KMail::FavoriteFolderView( this, mFolderViewSplitter );
00682 if ( mFavoritesCheckMailAction )
00683 connect( mFavoritesCheckMailAction, SIGNAL(activated()), mFavoriteFolderView, SLOT(checkMail()) );
00684 QWidget *folderTreeParent = mFolderViewParent;
00685 if ( GlobalSettings::enableFavoriteFolderView() ) {
00686 folderTreeParent = mFolderViewSplitter;
00687 mFolderView = mFolderViewSplitter;
00688 }
00689 mFolderTree = new KMFolderTree(this, folderTreeParent, "folderTree");
00690 if ( !GlobalSettings::enableFavoriteFolderView() ) {
00691 mFolderView = mFolderTree;
00692 }
00693 connect( mFolderTree, SIGNAL(folderSelected(KMFolder*)),
00694 mFavoriteFolderView, SLOT(folderTreeSelectionChanged(KMFolder*)) );
00695
00696 connect(mFolderTree, SIGNAL(folderSelected(KMFolder*)),
00697 this, SLOT(folderSelected(KMFolder*)));
00698 connect( mFolderTree, SIGNAL( folderSelected( KMFolder* ) ),
00699 mQuickSearchLine, SLOT( reset() ) );
00700 connect(mFolderTree, SIGNAL(folderSelectedUnread(KMFolder*)),
00701 this, SLOT(folderSelectedUnread(KMFolder*)));
00702 connect(mFolderTree, SIGNAL(folderDrop(KMFolder*)),
00703 this, SLOT(slotMoveMsgToFolder(KMFolder*)));
00704 connect(mFolderTree, SIGNAL(folderDropCopy(KMFolder*)),
00705 this, SLOT(slotCopyMsgToFolder(KMFolder*)));
00706 connect(mFolderTree, SIGNAL(columnsChanged()),
00707 this, SLOT(slotFolderTreeColumnsChanged()));
00708
00709 if ( mFavoriteFolderView ) {
00710 connect( mFavoriteFolderView, SIGNAL(folderDrop(KMFolder*)), SLOT(slotMoveMsgToFolder(KMFolder*)) );
00711 connect( mFavoriteFolderView, SIGNAL(folderDropCopy(KMFolder*)), SLOT(slotCopyMsgToFolder(KMFolder*)) );
00712 }
00713
00714
00715 mRemoveDuplicatesAction = new KAction(
00716 i18n("Remove Duplicate Messages"), CTRL+Key_Asterisk, this,
00717 SLOT(removeDuplicates()), actionCollection(), "remove_duplicate_messages");
00718 action->plugAccel( actionCollection()->kaccel() );
00719
00720 action = new KAction(
00721 i18n("Abort Current Operation"), Key_Escape, ProgressManager::instance(),
00722 SLOT(slotAbortAll()), actionCollection(), "cancel" );
00723 action->plugAccel( actionCollection()->kaccel() );
00724
00725 action = new KAction(
00726 i18n("Focus on Next Folder"), CTRL+Key_Right, mFolderTree,
00727 SLOT(incCurrentFolder()), actionCollection(), "inc_current_folder");
00728 action->plugAccel( actionCollection()->kaccel() );
00729
00730 action = new KAction(
00731 i18n("Focus on Previous Folder"), CTRL+Key_Left, mFolderTree,
00732 SLOT(decCurrentFolder()), actionCollection(), "dec_current_folder");
00733 action->plugAccel( actionCollection()->kaccel() );
00734
00735 action = new KAction(
00736 i18n("Select Folder with Focus"), CTRL+Key_Space, mFolderTree,
00737 SLOT(selectCurrentFolder()), actionCollection(), "select_current_folder");
00738 action->plugAccel( actionCollection()->kaccel() );
00739
00740 action = new KAction(
00741 i18n("Focus on Next Message"), ALT+Key_Right, mHeaders,
00742 SLOT(incCurrentMessage()), actionCollection(), "inc_current_message");
00743 action->plugAccel( actionCollection()->kaccel() );
00744
00745 action = new KAction(
00746 i18n("Focus on Previous Message"), ALT+Key_Left, mHeaders,
00747 SLOT(decCurrentMessage()), actionCollection(), "dec_current_message");
00748 action->plugAccel( actionCollection()->kaccel() );
00749
00750 action = new KAction(
00751 i18n("Select Message with Focus"), ALT+Key_Space, mHeaders,
00752 SLOT( selectCurrentMessage() ), actionCollection(), "select_current_message");
00753 action->plugAccel( actionCollection()->kaccel() );
00754
00755 connect( kmkernel->outboxFolder(), SIGNAL( msgRemoved(int, QString) ),
00756 SLOT( startUpdateMessageActionsTimer() ) );
00757 connect( kmkernel->outboxFolder(), SIGNAL( msgAdded(int) ),
00758 SLOT( startUpdateMessageActionsTimer() ) );
00759 }
00760
00761
00762
00763 void KMMainWidget::activatePanners(void)
00764 {
00765 if (mMsgView) {
00766 QObject::disconnect( mMsgView->copyAction(),
00767 SIGNAL( activated() ),
00768 mMsgView, SLOT( slotCopySelectedText() ));
00769 }
00770
00771 setupFolderView();
00772 if ( mLongFolderList ) {
00773 mSearchAndHeaders->reparent( mPanner2, 0, QPoint( 0, 0 ) );
00774 if (mMsgView) {
00775 mMsgView->reparent( mPanner2, 0, QPoint( 0, 0 ) );
00776 mPanner2->moveToLast( mMsgView );
00777 }
00778 mFolderViewParent = mPanner1;
00779 mFolderView->reparent( mFolderViewParent, 0, QPoint( 0, 0 ) );
00780 mPanner1->moveToLast( mPanner2 );
00781 mPanner1->setSizes( mPanner1Sep );
00782 mPanner1->setResizeMode( mFolderView, QSplitter::KeepSize );
00783 mPanner2->setSizes( mPanner2Sep );
00784 mPanner2->setResizeMode( mSearchAndHeaders, QSplitter::KeepSize );
00785 } else {
00786 mFolderViewParent = mPanner2;
00787 mFolderView->reparent( mFolderViewParent, 0, QPoint( 0, 0 ) );
00788 mSearchAndHeaders->reparent( mPanner2, 0, QPoint( 0, 0 ) );
00789 mPanner2->moveToLast( mSearchAndHeaders );
00790 mPanner1->moveToFirst( mPanner2 );
00791 if (mMsgView) {
00792 mMsgView->reparent( mPanner1, 0, QPoint( 0, 0 ) );
00793 mPanner1->moveToLast( mMsgView );
00794 }
00795 mPanner1->setSizes( mPanner1Sep );
00796 mPanner2->setSizes( mPanner2Sep );
00797 mPanner1->setResizeMode( mPanner2, QSplitter::KeepSize );
00798 mPanner2->setResizeMode( mFolderView, QSplitter::KeepSize );
00799 }
00800
00801 if (mMsgView) {
00802 QObject::connect( mMsgView->copyAction(),
00803 SIGNAL( activated() ),
00804 mMsgView, SLOT( slotCopySelectedText() ));
00805 }
00806 }
00807
00808
00809
00810 void KMMainWidget::hide()
00811 {
00812 QWidget::hide();
00813 }
00814
00815
00816
00817 void KMMainWidget::show()
00818 {
00819 QWidget::show();
00820 }
00821
00822
00823 void KMMainWidget::slotSearch()
00824 {
00825 if(!mSearchWin)
00826 {
00827 mSearchWin = new SearchWindow(this, "Search", mFolder, false);
00828 connect(mSearchWin, SIGNAL(destroyed()),
00829 this, SLOT(slotSearchClosed()));
00830 }
00831 else
00832 {
00833 mSearchWin->activateFolder(mFolder);
00834 }
00835
00836 mSearchWin->show();
00837 KWin::activateWindow( mSearchWin->winId() );
00838 }
00839
00840
00841
00842 void KMMainWidget::slotSearchClosed()
00843 {
00844 mSearchWin = 0;
00845 }
00846
00847
00848
00849 void KMMainWidget::slotFind()
00850 {
00851 if( mMsgView )
00852 mMsgView->slotFind();
00853 }
00854
00855
00856
00857 void KMMainWidget::slotHelp()
00858 {
00859 kapp->invokeHelp();
00860 }
00861
00862
00863
00864 void KMMainWidget::slotFilter()
00865 {
00866 kmkernel->filterMgr()->openDialog( this );
00867 }
00868
00869
00870
00871 void KMMainWidget::slotPopFilter()
00872 {
00873 kmkernel->popFilterMgr()->openDialog( this );
00874 }
00875
00876 void KMMainWidget::slotManageSieveScripts()
00877 {
00878 if ( !kmkernel->askToGoOnline() ) {
00879 return;
00880 }
00881 KMail::ManageSieveScriptsDialog * dlg = new KMail::ManageSieveScriptsDialog( this );
00882 dlg->show();
00883 }
00884
00885
00886
00887 void KMMainWidget::slotAddrBook()
00888 {
00889 KAddrBookExternal::openAddressBook(this);
00890 }
00891
00892
00893
00894 void KMMainWidget::slotImport()
00895 {
00896 KRun::runCommand("kmailcvt");
00897 }
00898
00899
00900 void KMMainWidget::slotCheckMail()
00901 {
00902 if ( !kmkernel->askToGoOnline() ) {
00903 return;
00904 }
00905 kmkernel->acctMgr()->checkMail(true);
00906 }
00907
00908
00909 void KMMainWidget::slotCheckOneAccount(int item)
00910 {
00911 if ( !kmkernel->askToGoOnline() ) {
00912 return;
00913 }
00914 kmkernel->acctMgr()->intCheckMail(item);
00915 }
00916
00917
00918 void KMMainWidget::slotMailChecked( bool newMail, bool sendOnCheck,
00919 const QMap<QString, int> & newInFolder )
00920 {
00921 const bool sendOnAll =
00922 GlobalSettings::self()->sendOnCheck() == GlobalSettings::EnumSendOnCheck::SendOnAllChecks;
00923 const bool sendOnManual =
00924 GlobalSettings::self()->sendOnCheck() == GlobalSettings::EnumSendOnCheck::SendOnManualChecks;
00925 if( !kmkernel->isOffline() && ( sendOnAll || (sendOnManual && sendOnCheck ) ) )
00926 slotSendQueued();
00927
00928 if ( !newMail || newInFolder.isEmpty() )
00929 return;
00930
00931 kapp->dcopClient()->emitDCOPSignal( "unreadCountChanged()", QByteArray() );
00932
00933
00934 bool showNotification = false;
00935 QString summary;
00936 QStringList keys( newInFolder.keys() );
00937 keys.sort();
00938 for ( QStringList::const_iterator it = keys.begin();
00939 it != keys.end();
00940 ++it ) {
00941 kdDebug(5006) << newInFolder.find( *it ).data() << " new message(s) in "
00942 << *it << endl;
00943
00944 KMFolder *folder = kmkernel->findFolderById( *it );
00945
00946 if ( folder && !folder->ignoreNewMail() ) {
00947 showNotification = true;
00948 if ( GlobalSettings::self()->verboseNewMailNotification() ) {
00949 summary += "<br>" + i18n( "1 new message in %1",
00950 "%n new messages in %1",
00951 newInFolder.find( *it ).data() )
00952 .arg( folder->prettyURL() );
00953 }
00954 }
00955 }
00956
00957
00958
00959 updateFolderMenu();
00960
00961 if ( !showNotification )
00962 return;
00963
00964 if ( GlobalSettings::self()->verboseNewMailNotification() ) {
00965 summary = i18n( "%1 is a list of the number of new messages per folder",
00966 "<b>New mail arrived</b><br>%1" )
00967 .arg( summary );
00968 }
00969 else {
00970 summary = i18n( "New mail arrived" );
00971 }
00972
00973 if(kmkernel->xmlGuiInstance()) {
00974 KNotifyClient::Instance instance(kmkernel->xmlGuiInstance());
00975 KNotifyClient::event( topLevelWidget()->winId(), "new-mail-arrived",
00976 summary );
00977 }
00978 else
00979 KNotifyClient::event( topLevelWidget()->winId(), "new-mail-arrived",
00980 summary );
00981
00982 if (mBeepOnNew) {
00983 KNotifyClient::beep();
00984 }
00985 }
00986
00987
00988
00989 void KMMainWidget::slotCompose()
00990 {
00991 KMail::Composer * win;
00992 KMMessage* msg = new KMMessage;
00993
00994 if ( mFolder ) {
00995 msg->initHeader( mFolder->identity() );
00996 TemplateParser parser( msg, TemplateParser::NewMessage,
00997 "", false, false, false, false );
00998 parser.process( NULL, mFolder );
00999 win = KMail::makeComposer( msg, mFolder->identity() );
01000 } else {
01001 msg->initHeader();
01002 TemplateParser parser( msg, TemplateParser::NewMessage,
01003 "", false, false, false, false );
01004 parser.process( NULL, NULL );
01005 win = KMail::makeComposer( msg );
01006 }
01007
01008 win->show();
01009
01010 }
01011
01012
01013
01014 void KMMainWidget::slotShowNewFromTemplate()
01015 {
01016 if ( mFolder ) {
01017 const KPIM::Identity & ident =
01018 kmkernel->identityManager()->identityForUoidOrDefault( mFolder->identity() );
01019 mTemplateFolder = kmkernel->folderMgr()->findIdString( ident.templates() );
01020 }
01021 else mTemplateFolder = kmkernel->templatesFolder();
01022 if ( !mTemplateFolder )
01023 return;
01024
01025 mTemplateMenu->popupMenu()->clear();
01026 for ( int idx = 0; idx<mTemplateFolder->count(); ++idx ) {
01027 KMMsgBase *mb = mTemplateFolder->getMsgBase( idx );
01028
01029 QString subj = mb->subject();
01030 if ( subj.isEmpty() ) subj = i18n("No Subject");
01031 mTemplateMenu->popupMenu()->insertItem(
01032 KStringHandler::rsqueeze( subj.replace( "&", "&&" ) ), idx );
01033 }
01034 }
01035
01036
01037 void KMMainWidget::slotNewFromTemplate( int id )
01038 {
01039 if ( !mTemplateFolder )
01040 return;
01041 newFromTemplate(mTemplateFolder->getMsg( id ) );
01042 }
01043
01044
01045 void KMMainWidget::newFromTemplate( KMMessage *msg )
01046 {
01047 if ( !msg )
01048 return;
01049 KMCommand *command = new KMUseTemplateCommand( this, msg );
01050 command->start();
01051 }
01052
01053
01054 void KMMainWidget::slotPostToML()
01055 {
01056 if ( mFolder && mFolder->isMailingListEnabled() ) {
01057 KMCommand *command = new KMMailingListPostCommand( this, mFolder );
01058 command->start();
01059 }
01060 else
01061 slotCompose();
01062 }
01063
01064
01065 void KMMainWidget::slotFolderMailingListProperties()
01066 {
01067 if (!mFolderTree) return;
01068 KMFolderTreeItem *item = static_cast<KMFolderTreeItem*>( mFolderTree->currentItem() );
01069 if ( !item ) return;
01070 KMFolder* folder = item->folder();
01071 if ( folder ) {
01072 ( new KMail::MailingListFolderPropertiesDialog( this, folder ) )->show();
01073 }
01074 }
01075
01076
01077 void KMMainWidget::slotFolderShortcutCommand()
01078 {
01079 if (!mFolderTree) return;
01080 KMFolderTreeItem *item = static_cast<KMFolderTreeItem*>( mFolderTree->currentItem() );
01081 if ( item )
01082 item->assignShortcut();
01083 }
01084
01085
01086
01087 void KMMainWidget::slotModifyFolder()
01088 {
01089 if (!mFolderTree) return;
01090 KMFolderTreeItem *item = static_cast<KMFolderTreeItem*>( mFolderTree->currentItem() );
01091 if ( item )
01092 modifyFolder( item );
01093 }
01094
01095
01096 void KMMainWidget::modifyFolder( KMFolderTreeItem* folderItem )
01097 {
01098 KMFolder* folder = folderItem->folder();
01099 KMFolderTree* folderTree = static_cast<KMFolderTree *>( folderItem->listView() );
01100 KMFolderDialog props( folder, folder->parent(), folderTree,
01101 i18n("Properties of Folder %1").arg( folder->label() ) );
01102 props.exec();
01103 updateFolderMenu();
01104 }
01105
01106
01107 void KMMainWidget::slotExpireFolder()
01108 {
01109 QString str;
01110 bool canBeExpired = true;
01111
01112 if (!mFolder) return;
01113
01114 if (!mFolder->isAutoExpire()) {
01115 canBeExpired = false;
01116 } else if (mFolder->getUnreadExpireUnits()==expireNever &&
01117 mFolder->getReadExpireUnits()==expireNever) {
01118 canBeExpired = false;
01119 }
01120
01121 if (!canBeExpired) {
01122 str = i18n("This folder does not have any expiry options set");
01123 KMessageBox::information(this, str);
01124 return;
01125 }
01126 KConfig *config = KMKernel::config();
01127 KConfigGroupSaver saver(config, "General");
01128
01129 if (config->readBoolEntry("warn-before-expire", true)) {
01130 str = i18n("<qt>Are you sure you want to expire the folder <b>%1</b>?</qt>").arg(QStyleSheet::escape( mFolder->label() ));
01131 if (KMessageBox::warningContinueCancel(this, str, i18n("Expire Folder"),
01132 i18n("&Expire"))
01133 != KMessageBox::Continue) return;
01134 }
01135
01136 mFolder->expireOldMessages( true );
01137 }
01138
01139
01140 void KMMainWidget::slotEmptyFolder()
01141 {
01142 QString str;
01143
01144 if (!mFolder) return;
01145 bool isTrash = kmkernel->folderIsTrash(mFolder);
01146
01147 if (mConfirmEmpty)
01148 {
01149 QString title = (isTrash) ? i18n("Empty Trash") : i18n("Move to Trash");
01150 QString text = (isTrash) ?
01151 i18n("Are you sure you want to empty the trash folder?") :
01152 i18n("<qt>Are you sure you want to move all messages from "
01153 "folder <b>%1</b> to the trash?</qt>").arg( QStyleSheet::escape( mFolder->label() ) );
01154
01155 if (KMessageBox::warningContinueCancel(this, text, title, KGuiItem( title, "edittrash"))
01156 != KMessageBox::Continue) return;
01157 }
01158 KCursorSaver busy(KBusyPtr::busy());
01159 slotMarkAll();
01160 if (isTrash) {
01161
01162
01163 slotDeleteMsg( false );
01164 }
01165 else
01166 slotTrashMsg();
01167
01168 if (mMsgView) mMsgView->clearCache();
01169
01170 if ( !isTrash )
01171 BroadcastStatus::instance()->setStatusMsg(i18n("Moved all messages to the trash"));
01172
01173 updateMessageActions();
01174
01175
01176
01177 mEmptyFolderAction->setEnabled( false );
01178 }
01179
01180
01181
01182 void KMMainWidget::slotRemoveFolder()
01183 {
01184 QString str;
01185 QDir dir;
01186
01187 if ( !mFolder ) return;
01188 if ( mFolder->isSystemFolder() ) return;
01189 if ( mFolder->isReadOnly() ) return;
01190
01191 QString title;
01192 if ( mFolder->folderType() == KMFolderTypeSearch ) {
01193 title = i18n("Delete Search");
01194 str = i18n("<qt>Are you sure you want to delete the search <b>%1</b>?<br>"
01195 "Any messages it shows will still be available in their original folder.</qt>")
01196 .arg( QStyleSheet::escape( mFolder->label() ) );
01197 } else {
01198 title = i18n("Delete Folder");
01199 if ( mFolder->count() == 0 ) {
01200 if ( !mFolder->child() || mFolder->child()->isEmpty() ) {
01201 str = i18n("<qt>Are you sure you want to delete the empty folder "
01202 "<b>%1</b>?</qt>")
01203 .arg( QStyleSheet::escape( mFolder->label() ) );
01204 }
01205 else {
01206 str = i18n("<qt>Are you sure you want to delete the empty folder "
01207 "<b>%1</b> and all its subfolders? Those subfolders might "
01208 "not be empty and their contents will be discarded as well. "
01209 "<p><b>Beware</b> that discarded messages are not saved "
01210 "into your Trash folder and are permanently deleted.</qt>")
01211 .arg( QStyleSheet::escape( mFolder->label() ) );
01212 }
01213 } else {
01214 if ( !mFolder->child() || mFolder->child()->isEmpty() ) {
01215 str = i18n("<qt>Are you sure you want to delete the folder "
01216 "<b>%1</b>, discarding its contents? "
01217 "<p><b>Beware</b> that discarded messages are not saved "
01218 "into your Trash folder and are permanently deleted.</qt>")
01219 .arg( QStyleSheet::escape( mFolder->label() ) );
01220 }
01221 else {
01222 str = i18n("<qt>Are you sure you want to delete the folder <b>%1</b> "
01223 "and all its subfolders, discarding their contents? "
01224 "<p><b>Beware</b> that discarded messages are not saved "
01225 "into your Trash folder and are permanently deleted.</qt>")
01226 .arg( QStyleSheet::escape( mFolder->label() ) );
01227 }
01228 }
01229 }
01230
01231 if (KMessageBox::warningContinueCancel(this, str, title,
01232 KGuiItem( i18n("&Delete"), "editdelete"))
01233 == KMessageBox::Continue)
01234 {
01235 if ( mFolder->hasAccounts() ) {
01236
01237 for ( AccountList::Iterator it (mFolder->acctList()->begin() ),
01238 end( mFolder->acctList()->end() ); it != end; ++it ) {
01239 (*it)->setFolder( kmkernel->inboxFolder() );
01240 KMessageBox::information(this,
01241 i18n("<qt>The folder you deleted was associated with the account "
01242 "<b>%1</b> which delivered mail into it. The folder the account "
01243 "delivers new mail into was reset to the main Inbox folder.</qt>").arg( (*it)->name()));
01244 }
01245 }
01246 if (mFolder->folderType() == KMFolderTypeImap)
01247 kmkernel->imapFolderMgr()->remove(mFolder);
01248 else if (mFolder->folderType() == KMFolderTypeCachedImap) {
01249
01250 KMFolderCachedImap* storage = static_cast<KMFolderCachedImap*>( mFolder->storage() );
01251 KMAcctCachedImap* acct = storage->account();
01252 if ( acct )
01253 acct->addDeletedFolder( mFolder );
01254
01255 kmkernel->dimapFolderMgr()->remove(mFolder);
01256 }
01257 else if (mFolder->folderType() == KMFolderTypeSearch)
01258 kmkernel->searchFolderMgr()->remove(mFolder);
01259 else
01260 kmkernel->folderMgr()->remove(mFolder);
01261 }
01262 }
01263
01264
01265 void KMMainWidget::slotMarkAllAsRead()
01266 {
01267 if (!mFolder)
01268 return;
01269 mFolder->markUnreadAsRead();
01270 }
01271
01272
01273 void KMMainWidget::slotCompactFolder()
01274 {
01275 if (mFolder) {
01276 int idx = mHeaders->currentItemIndex();
01277 KCursorSaver busy(KBusyPtr::busy());
01278 mFolder->compact( KMFolder::CompactNow );
01279
01280 QString statusMsg = BroadcastStatus::instance()->statusMsg();
01281 mHeaders->setCurrentItemByIndex(idx);
01282 BroadcastStatus::instance()->setStatusMsg( statusMsg );
01283 }
01284 }
01285
01286
01287
01288 void KMMainWidget::slotRefreshFolder()
01289 {
01290 if (mFolder)
01291 {
01292 if ( mFolder->folderType() == KMFolderTypeImap || mFolder->folderType() == KMFolderTypeCachedImap ) {
01293 if ( !kmkernel->askToGoOnline() ) {
01294 return;
01295 }
01296 }
01297
01298 if (mFolder->folderType() == KMFolderTypeImap)
01299 {
01300 KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage());
01301 imap->getAndCheckFolder();
01302 } else if ( mFolder->folderType() == KMFolderTypeCachedImap ) {
01303 KMFolderCachedImap* f = static_cast<KMFolderCachedImap*>( mFolder->storage() );
01304 f->account()->processNewMailSingleFolder( mFolder );
01305 }
01306 }
01307 }
01308
01309 void KMMainWidget::slotTroubleshootFolder()
01310 {
01311 if (mFolder)
01312 {
01313 if ( mFolder->folderType() == KMFolderTypeCachedImap ) {
01314 KMFolderCachedImap* f = static_cast<KMFolderCachedImap*>( mFolder->storage() );
01315 f->slotTroubleshoot();
01316 }
01317 }
01318 }
01319
01320 void KMMainWidget::slotInvalidateIMAPFolders() {
01321 if ( KMessageBox::warningContinueCancel( this,
01322 i18n("Are you sure you want to refresh the IMAP cache?\n"
01323 "This will remove all changes that you have done "
01324 "locally to your IMAP folders."),
01325 i18n("Refresh IMAP Cache"), i18n("&Refresh") ) == KMessageBox::Continue )
01326 kmkernel->acctMgr()->invalidateIMAPFolders();
01327 }
01328
01329
01330 void KMMainWidget::slotExpireAll() {
01331 KConfig *config = KMKernel::config();
01332 int ret = 0;
01333
01334 KConfigGroupSaver saver(config, "General");
01335
01336 if (config->readBoolEntry("warn-before-expire", true)) {
01337 ret = KMessageBox::warningContinueCancel(KMainWindow::memberList->first(),
01338 i18n("Are you sure you want to expire all old messages?"),
01339 i18n("Expire Old Messages?"), i18n("Expire"));
01340 if (ret != KMessageBox::Continue) {
01341 return;
01342 }
01343 }
01344
01345 kmkernel->expireAllFoldersNow();
01346 }
01347
01348
01349 void KMMainWidget::slotCompactAll()
01350 {
01351 KCursorSaver busy(KBusyPtr::busy());
01352 kmkernel->compactAllFolders();
01353 }
01354
01355
01356
01357 void KMMainWidget::slotOverrideHtml()
01358 {
01359 if( mHtmlPref == mFolderHtmlPref ) {
01360 int result = KMessageBox::warningContinueCancel( this,
01361
01362 i18n( "Use of HTML in mail will make you more vulnerable to "
01363 "\"spam\" and may increase the likelihood that your system will be "
01364 "compromised by other present and anticipated security exploits." ),
01365 i18n( "Security Warning" ),
01366 i18n( "Use HTML" ),
01367 "OverrideHtmlWarning", false);
01368 if( result == KMessageBox::Cancel ) {
01369 mPreferHtmlAction->setChecked( false );
01370 return;
01371 }
01372 }
01373 mFolderHtmlPref = !mFolderHtmlPref;
01374 if (mMsgView) {
01375 mMsgView->setHtmlOverride(mFolderHtmlPref);
01376 mMsgView->update( true );
01377 }
01378 }
01379
01380
01381 void KMMainWidget::slotOverrideHtmlLoadExt()
01382 {
01383 if( mHtmlLoadExtPref == mFolderHtmlLoadExtPref ) {
01384 int result = KMessageBox::warningContinueCancel( this,
01385
01386 i18n( "Loading external references in html mail will make you more vulnerable to "
01387 "\"spam\" and may increase the likelihood that your system will be "
01388 "compromised by other present and anticipated security exploits." ),
01389 i18n( "Security Warning" ),
01390 i18n( "Load External References" ),
01391 "OverrideHtmlLoadExtWarning", false);
01392 if( result == KMessageBox::Cancel ) {
01393 mPreferHtmlLoadExtAction->setChecked( false );
01394 return;
01395 }
01396 }
01397 mFolderHtmlLoadExtPref = !mFolderHtmlLoadExtPref;
01398 if (mMsgView) {
01399 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
01400 mMsgView->update( true );
01401 }
01402 }
01403
01404
01405 void KMMainWidget::slotOverrideThread()
01406 {
01407 mFolderThreadPref = !mFolderThreadPref;
01408 mHeaders->setNestedOverride(mFolderThreadPref);
01409 mThreadBySubjectAction->setEnabled(mThreadMessagesAction->isChecked());
01410 }
01411
01412
01413 void KMMainWidget::slotToggleSubjectThreading()
01414 {
01415 mFolderThreadSubjPref = !mFolderThreadSubjPref;
01416 mHeaders->setSubjectThreading(mFolderThreadSubjPref);
01417 }
01418
01419
01420 void KMMainWidget::slotToggleShowQuickSearch()
01421 {
01422 GlobalSettings::self()->setQuickSearchActive( !GlobalSettings::self()->quickSearchActive() );
01423 if ( GlobalSettings::self()->quickSearchActive() )
01424 mSearchToolBar->show();
01425 else {
01426 mQuickSearchLine->reset();
01427 mSearchToolBar->hide();
01428 }
01429 }
01430
01431
01432 void KMMainWidget::slotMessageQueuedOrDrafted()
01433 {
01434 if (!kmkernel->folderIsDraftOrOutbox(mFolder))
01435 return;
01436 if (mMsgView)
01437 mMsgView->update(true);
01438 }
01439
01440
01441
01442 void KMMainWidget::slotForwardInlineMsg()
01443 {
01444 KMMessageList* selected = mHeaders->selectedMsgs();
01445 KMCommand *command = 0L;
01446 if(selected && !selected->isEmpty()) {
01447 command = new KMForwardInlineCommand( this, *selected,
01448 mFolder->identity() );
01449 } else {
01450 command = new KMForwardInlineCommand( this, mHeaders->currentMsg(),
01451 mFolder->identity() );
01452 }
01453
01454 command->start();
01455 }
01456
01457
01458
01459 void KMMainWidget::slotForwardAttachedMsg()
01460 {
01461 KMMessageList* selected = mHeaders->selectedMsgs();
01462 KMCommand *command = 0L;
01463 if(selected && !selected->isEmpty()) {
01464 command = new KMForwardAttachedCommand( this, *selected, mFolder->identity() );
01465 } else {
01466 command = new KMForwardAttachedCommand( this, mHeaders->currentMsg(), mFolder->identity() );
01467 }
01468
01469 command->start();
01470 }
01471
01472
01473 void KMMainWidget::slotForwardDigestMsg()
01474 {
01475 KMMessageList* selected = mHeaders->selectedMsgs();
01476 KMCommand *command = 0L;
01477 if(selected && !selected->isEmpty()) {
01478 command = new KMForwardDigestCommand( this, *selected, mFolder->identity() );
01479 } else {
01480 command = new KMForwardDigestCommand( this, mHeaders->currentMsg(), mFolder->identity() );
01481 }
01482
01483 command->start();
01484 }
01485
01486
01487 void KMMainWidget::slotUseTemplate()
01488 {
01489 newFromTemplate( mHeaders->currentMsg() );
01490 }
01491
01492
01493 void KMMainWidget::slotResendMsg()
01494 {
01495 KMCommand *command = new KMResendMessageCommand( this, mHeaders->currentMsg() );
01496 command->start();
01497 }
01498
01499
01500
01501 void KMMainWidget::slotTrashMsg()
01502 {
01503 mHeaders->deleteMsg();
01504 }
01505
01506
01507 void KMMainWidget::slotDeleteMsg( bool confirmDelete )
01508 {
01509 mHeaders->moveMsgToFolder( 0, confirmDelete );
01510 }
01511
01512
01513 void KMMainWidget::slotTrashThread()
01514 {
01515 mHeaders->highlightCurrentThread();
01516 mHeaders->deleteMsg();
01517 }
01518
01519
01520 void KMMainWidget::slotDeleteThread( bool confirmDelete )
01521 {
01522 mHeaders->highlightCurrentThread();
01523 mHeaders->moveMsgToFolder( 0, confirmDelete );
01524 }
01525
01526
01527 void KMMainWidget::slotRedirectMsg()
01528 {
01529 KMCommand *command = new KMRedirectCommand( this, mHeaders->currentMsg() );
01530 command->start();
01531 }
01532
01533
01534
01535 void KMMainWidget::slotCustomReplyToMsg( int tid )
01536 {
01537 QString text = mMsgView? mMsgView->copyText() : "";
01538 QString tmpl = mCustomTemplates[ tid ];
01539 kdDebug() << "Reply with template: " << tmpl << " (" << tid << ")" << endl;
01540 KMCommand *command = new KMCustomReplyToCommand( this,
01541 mHeaders->currentMsg(),
01542 text,
01543 tmpl );
01544 command->start();
01545 }
01546
01547
01548
01549 void KMMainWidget::slotCustomReplyAllToMsg( int tid )
01550 {
01551 QString text = mMsgView? mMsgView->copyText() : "";
01552 QString tmpl = mCustomTemplates[ tid ];
01553 kdDebug() << "Reply to All with template: " << tmpl << " (" << tid << ")" << endl;
01554 KMCommand *command = new KMCustomReplyAllToCommand( this,
01555 mHeaders->currentMsg(),
01556 text,
01557 tmpl );
01558 command->start();
01559 }
01560
01561
01562
01563 void KMMainWidget::slotCustomForwardMsg( int tid )
01564 {
01565 QString tmpl = mCustomTemplates[ tid ];
01566 kdDebug() << "Forward with template: " << tmpl << " (" << tid << ")" << endl;
01567 KMMessageList* selected = mHeaders->selectedMsgs();
01568 KMCommand *command = 0L;
01569 if(selected && !selected->isEmpty()) {
01570 command = new KMCustomForwardCommand( this, *selected,
01571 mFolder->identity(), tmpl );
01572 } else {
01573 command = new KMCustomForwardCommand( this, mHeaders->currentMsg(),
01574 mFolder->identity(), tmpl );
01575 }
01576 command->start();
01577 }
01578
01579
01580
01581 void KMMainWidget::slotNoQuoteReplyToMsg()
01582 {
01583 KMCommand *command = new KMNoQuoteReplyToCommand( this, mHeaders->currentMsg() );
01584 command->start();
01585 }
01586
01587
01588 void KMMainWidget::slotSubjectFilter()
01589 {
01590 KMMessage *msg = mHeaders->currentMsg();
01591 if (!msg)
01592 return;
01593
01594 KMCommand *command = new KMFilterCommand( "Subject", msg->subject() );
01595 command->start();
01596 }
01597
01598
01599 void KMMainWidget::slotMailingListFilter()
01600 {
01601 KMMessage *msg = mHeaders->currentMsg();
01602 if (!msg)
01603 return;
01604
01605 KMCommand *command = new KMMailingListFilterCommand( this, msg );
01606 command->start();
01607 }
01608
01609
01610 void KMMainWidget::slotFromFilter()
01611 {
01612 KMMessage *msg = mHeaders->currentMsg();
01613 if (!msg)
01614 return;
01615
01616 AddrSpecList al = msg->extractAddrSpecs( "From" );
01617 KMCommand *command;
01618 if ( al.empty() )
01619 command = new KMFilterCommand( "From", msg->from() );
01620 else
01621 command = new KMFilterCommand( "From", al.front().asString() );
01622 command->start();
01623 }
01624
01625
01626 void KMMainWidget::slotToFilter()
01627 {
01628 KMMessage *msg = mHeaders->currentMsg();
01629 if (!msg)
01630 return;
01631
01632 KMCommand *command = new KMFilterCommand( "To", msg->to() );
01633 command->start();
01634 }
01635
01636
01637 void KMMainWidget::updateListFilterAction()
01638 {
01639
01640 QCString name;
01641 QString value;
01642 QString lname = MailingList::name( mHeaders->currentMsg(), name, value );
01643 mListFilterAction->setText( i18n("Filter on Mailing-List...") );
01644 if ( lname.isNull() )
01645 mListFilterAction->setEnabled( false );
01646 else {
01647 mListFilterAction->setEnabled( true );
01648 mListFilterAction->setText( i18n( "Filter on Mailing-List %1..." ).arg( lname ) );
01649 }
01650 }
01651
01652
01653
01654 void KMMainWidget::slotUndo()
01655 {
01656 mHeaders->undo();
01657 updateMessageActions();
01658 }
01659
01660
01661 void KMMainWidget::slotToggleUnread()
01662 {
01663 mFolderTree->toggleColumn(KMFolderTree::unread);
01664 }
01665
01666
01667 void KMMainWidget::slotToggleTotalColumn()
01668 {
01669 mFolderTree->toggleColumn(KMFolderTree::total, true);
01670 }
01671
01672
01673 void KMMainWidget::slotToggleSizeColumn()
01674 {
01675 mFolderTree->toggleColumn(KMFolderTree::foldersize);
01676 }
01677
01678
01679
01680 void KMMainWidget::slotJumpToFolder()
01681 {
01682 KMail::KMFolderSelDlg dlg( this, i18n("Jump to Folder"), true );
01683 KMFolder* dest;
01684
01685 if (!dlg.exec()) return;
01686 if (!(dest = dlg.folder())) return;
01687
01688 slotSelectFolder( dest );
01689 }
01690
01691
01692 void KMMainWidget::slotMoveMsg()
01693 {
01694 KMail::KMFolderSelDlg dlg( this, i18n("Move Message to Folder"), true );
01695 KMFolder* dest;
01696
01697 if (!dlg.exec()) return;
01698 if (!(dest = dlg.folder())) return;
01699
01700 mHeaders->moveMsgToFolder(dest);
01701 }
01702
01703
01704 void KMMainWidget::slotMoveMsgToFolder( KMFolder *dest)
01705 {
01706 mHeaders->moveMsgToFolder(dest);
01707 }
01708
01709
01710 void KMMainWidget::slotCopyMsgToFolder( KMFolder *dest)
01711 {
01712 mHeaders->copyMsgToFolder(dest);
01713 }
01714
01715
01716 void KMMainWidget::slotApplyFilters()
01717 {
01718 mHeaders->applyFiltersOnMsg();
01719 }
01720
01721
01722 void KMMainWidget::slotCheckVacation()
01723 {
01724 updateVactionScriptStatus( false );
01725 if ( !kmkernel->askToGoOnline() )
01726 return;
01727
01728 Vacation *vac = new Vacation( this, true );
01729 connect( vac, SIGNAL(scriptActive(bool)), SLOT(updateVactionScriptStatus(bool)) );
01730 }
01731
01732 void KMMainWidget::slotEditVacation()
01733 {
01734 if ( !kmkernel->askToGoOnline() ) {
01735 return;
01736 }
01737
01738 if ( mVacation )
01739 return;
01740
01741 mVacation = new Vacation( this );
01742 connect( mVacation, SIGNAL(scriptActive(bool)), SLOT(updateVactionScriptStatus(bool)) );
01743 if ( mVacation->isUsable() ) {
01744 connect( mVacation, SIGNAL(result(bool)), mVacation, SLOT(deleteLater()) );
01745 } else {
01746 QString msg = i18n("KMail's Out of Office Reply functionality relies on "
01747 "server-side filtering. You have not yet configured an "
01748 "IMAP server for this.\n"
01749 "You can do this on the \"Filtering\" tab of the IMAP "
01750 "account configuration.");
01751 KMessageBox::sorry( this, msg, i18n("No Server-Side Filtering Configured") );
01752
01753 delete mVacation;
01754 }
01755 }
01756
01757
01758 void KMMainWidget::slotDebugSieve()
01759 {
01760 #if !defined(NDEBUG)
01761 if ( mSieveDebugDialog )
01762 return;
01763
01764 mSieveDebugDialog = new SieveDebugDialog( this );
01765 mSieveDebugDialog->exec();
01766 delete mSieveDebugDialog;
01767 #endif
01768 }
01769
01770
01771 void KMMainWidget::slotStartCertManager()
01772 {
01773 KProcess certManagerProc;
01774
01775 certManagerProc << "kleopatra";
01776
01777 if( !certManagerProc.start( KProcess::DontCare ) )
01778 KMessageBox::error( this, i18n( "Could not start certificate manager; "
01779 "please check your installation." ),
01780 i18n( "KMail Error" ) );
01781 else
01782 kdDebug(5006) << "\nslotStartCertManager(): certificate manager started.\n" << endl;
01783
01784
01785
01786 }
01787
01788
01789 void KMMainWidget::slotStartWatchGnuPG()
01790 {
01791 KProcess certManagerProc;
01792 certManagerProc << "kwatchgnupg";
01793
01794 if( !certManagerProc.start( KProcess::DontCare ) )
01795 KMessageBox::error( this, i18n( "Could not start GnuPG LogViewer (kwatchgnupg); "
01796 "please check your installation." ),
01797 i18n( "KMail Error" ) );
01798 }
01799
01800
01801 void KMMainWidget::slotCopyMsg()
01802 {
01803 KMail::KMFolderSelDlg dlg( this, i18n("Copy Message to Folder"), true );
01804 KMFolder* dest;
01805
01806 if (!dlg.exec()) return;
01807 if (!(dest = dlg.folder())) return;
01808
01809 mHeaders->copyMsgToFolder(dest);
01810 }
01811
01812
01813 void KMMainWidget::slotPrintMsg()
01814 {
01815 bool htmlOverride = mMsgView ? mMsgView->htmlOverride() : false;
01816 bool htmlLoadExtOverride = mMsgView ? mMsgView->htmlLoadExtOverride() : false;
01817 KConfigGroup reader( KMKernel::config(), "Reader" );
01818 bool useFixedFont = mMsgView ? mMsgView->isFixedFont()
01819 : reader.readBoolEntry( "useFixedFont", false );
01820 KMCommand *command =
01821 new KMPrintCommand( this, mHeaders->currentMsg(),
01822 htmlOverride, htmlLoadExtOverride,
01823 useFixedFont, overrideEncoding() );
01824 command->start();
01825 }
01826
01827
01828 void KMMainWidget::setupForwardActions()
01829 {
01830 disconnect( mForwardActionMenu, SIGNAL( activated() ), 0, 0 );
01831 mForwardActionMenu->remove( mForwardInlineAction );
01832 mForwardActionMenu->remove( mForwardAttachedAction );
01833
01834 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
01835 mForwardActionMenu->insert( mForwardInlineAction, 0 );
01836 mForwardActionMenu->insert( mForwardAttachedAction, 1 );
01837 mForwardInlineAction->setShortcut( Key_F );
01838 mForwardAttachedAction->setShortcut( SHIFT+Key_F );
01839 connect( mForwardActionMenu, SIGNAL(activated()), this,
01840 SLOT(slotForwardInlineMsg()) );
01841
01842 } else {
01843 mForwardActionMenu->insert( mForwardAttachedAction, 0 );
01844 mForwardActionMenu->insert( mForwardInlineAction, 1 );
01845 mForwardInlineAction->setShortcut( SHIFT+Key_F );
01846 mForwardAttachedAction->setShortcut( Key_F );
01847 connect( mForwardActionMenu, SIGNAL(activated()), this,
01848 SLOT(slotForwardAttachedMsg()) );
01849 }
01850 }
01851
01852
01853 void KMMainWidget::slotConfigChanged()
01854 {
01855 readConfig();
01856 setupForwardActions();
01857 setupForwardingActionsList();
01858 }
01859
01860
01861 void KMMainWidget::slotSaveMsg()
01862 {
01863 KMMessage *msg = mHeaders->currentMsg();
01864 if (!msg)
01865 return;
01866 KMSaveMsgCommand *saveCommand = new KMSaveMsgCommand( this,
01867 *mHeaders->selectedMsgs() );
01868
01869 if (saveCommand->url().isEmpty())
01870 delete saveCommand;
01871 else
01872 saveCommand->start();
01873 }
01874
01875
01876 void KMMainWidget::slotOpenMsg()
01877 {
01878 KMOpenMsgCommand *openCommand = new KMOpenMsgCommand( this, 0, overrideEncoding() );
01879
01880 openCommand->start();
01881 }
01882
01883
01884 void KMMainWidget::slotSaveAttachments()
01885 {
01886 KMMessage *msg = mHeaders->currentMsg();
01887 if (!msg)
01888 return;
01889 KMSaveAttachmentsCommand *saveCommand = new KMSaveAttachmentsCommand( this,
01890 *mHeaders->selectedMsgs() );
01891 saveCommand->start();
01892 }
01893
01894 void KMMainWidget::slotOnlineStatus()
01895 {
01896
01897
01898 if ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Online ) {
01899
01900 kmkernel->stopNetworkJobs();
01901 } else {
01902 kmkernel->resumeNetworkJobs();
01903 }
01904 }
01905
01906 void KMMainWidget::slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type )
01907 {
01908 if ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Online )
01909 actionCollection()->action( "online_status" )->setText( i18n("Work Offline") );
01910 else
01911 actionCollection()->action( "online_status" )->setText( i18n("Work Online") );
01912 }
01913
01914
01915
01916 void KMMainWidget::slotSendQueued()
01917 {
01918 if ( !kmkernel->askToGoOnline() ) {
01919 return;
01920 }
01921
01922 kmkernel->msgSender()->sendQueued();
01923 }
01924
01925
01926 void KMMainWidget::slotSendQueuedVia( int item )
01927 {
01928 if ( !kmkernel->askToGoOnline() ) {
01929 return;
01930 }
01931
01932 QStringList availTransports= KMail::TransportManager::transportNames();
01933 QString customTransport = availTransports[ item ];
01934
01935 kmkernel->msgSender()->sendQueued( customTransport );
01936 }
01937
01938
01939 void KMMainWidget::slotViewChange()
01940 {
01941 if(mBodyPartsMenu->isItemChecked(mBodyPartsMenu->idAt(0)))
01942 {
01943 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(0),false);
01944 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(1),true);
01945 }
01946 else if(mBodyPartsMenu->isItemChecked(mBodyPartsMenu->idAt(1)))
01947 {
01948 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(1),false);
01949 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(0),true);
01950 }
01951
01952
01953 }
01954
01955
01956
01957 void KMMainWidget::folderSelectedUnread( KMFolder* aFolder )
01958 {
01959 folderSelected( aFolder, true );
01960 slotChangeCaption( mFolderTree->currentItem() );
01961 }
01962
01963
01964 void KMMainWidget::folderSelected()
01965 {
01966 folderSelected( mFolder );
01967 updateFolderMenu();
01968
01969 if ( mFolder && mFolder->folderType() == KMFolderTypeImap )
01970 mFolder->close("mainwidget");
01971 }
01972
01973
01974 void KMMainWidget::folderSelected( KMFolder* aFolder, bool forceJumpToUnread )
01975 {
01976 KCursorSaver busy(KBusyPtr::busy());
01977
01978 if (mMsgView)
01979 mMsgView->clear(true);
01980
01981 if ( mFolder && mFolder->folderType() == KMFolderTypeImap && !mFolder->noContent() )
01982 {
01983 KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage());
01984 if ( mFolder->needsCompacting() && imap->autoExpunge() )
01985 imap->expungeFolder(imap, true);
01986 }
01987
01988
01989
01990
01991
01992
01993
01994
01995 bool newFolder = ( (KMFolder*)mFolder != aFolder );
01996 bool isNewImapFolder = aFolder && aFolder->folderType() == KMFolderTypeImap && newFolder;
01997 if( !mFolder
01998 || ( !isNewImapFolder && mShowBusySplashTimer )
01999 || ( newFolder && mShowingOfflineScreen && !( isNewImapFolder && kmkernel->isOffline() ) ) ) {
02000 if ( mMsgView ) {
02001 mMsgView->enableMsgDisplay();
02002 mMsgView->clear( true );
02003 }
02004 if( mSearchAndHeaders && mHeaders )
02005 mSearchAndHeaders->show();
02006 mShowingOfflineScreen = false;
02007 }
02008
02009
02010 delete mShowBusySplashTimer;
02011 mShowBusySplashTimer = 0;
02012
02013 if ( newFolder )
02014 writeFolderConfig();
02015 if ( mFolder ) {
02016 disconnect( mFolder, SIGNAL( changed() ),
02017 this, SLOT( updateMarkAsReadAction() ) );
02018 disconnect( mFolder, SIGNAL( msgHeaderChanged( KMFolder*, int ) ),
02019 this, SLOT( updateMarkAsReadAction() ) );
02020 disconnect( mFolder, SIGNAL( msgAdded( int ) ),
02021 this, SLOT( updateMarkAsReadAction() ) );
02022 disconnect( mFolder, SIGNAL( msgRemoved( KMFolder * ) ),
02023 this, SLOT( updateMarkAsReadAction() ) );
02024 }
02025
02026 mFolder = aFolder;
02027
02028 if ( aFolder && aFolder->folderType() == KMFolderTypeImap )
02029 {
02030 if ( kmkernel->isOffline() ) {
02031 showOfflinePage();
02032 return;
02033 }
02034 KMFolderImap *imap = static_cast<KMFolderImap*>(aFolder->storage());
02035 if ( newFolder && !mFolder->noContent() )
02036 {
02037 imap->open("mainwidget");
02038
02039 imap->setSelected( true );
02040 connect( imap, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
02041 this, SLOT( folderSelected() ) );
02042 imap->getAndCheckFolder();
02043 mHeaders->setFolder( 0 );
02044 updateFolderMenu();
02045 mForceJumpToUnread = forceJumpToUnread;
02046
02047
02048
02049 mShowBusySplashTimer = new QTimer( this );
02050 connect( mShowBusySplashTimer, SIGNAL( timeout() ), this, SLOT( slotShowBusySplash() ) );
02051 mShowBusySplashTimer->start( GlobalSettings::self()->folderLoadingTimeout(), true );
02052 return;
02053 } else {
02054
02055 disconnect( imap, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
02056 this, SLOT( folderSelected() ) );
02057 forceJumpToUnread = mForceJumpToUnread;
02058 }
02059 }
02060
02061 if ( mFolder ) {
02062 connect( mFolder, SIGNAL( changed() ),
02063 this, SLOT( updateMarkAsReadAction() ) );
02064 connect( mFolder, SIGNAL( msgHeaderChanged( KMFolder*, int ) ),
02065 this, SLOT( updateMarkAsReadAction() ) );
02066 connect( mFolder, SIGNAL( msgAdded( int ) ),
02067 this, SLOT( updateMarkAsReadAction() ) );
02068 connect( mFolder, SIGNAL( msgRemoved(KMFolder *) ),
02069 this, SLOT( updateMarkAsReadAction() ) );
02070 }
02071 readFolderConfig();
02072 if (mMsgView)
02073 {
02074 mMsgView->setHtmlOverride(mFolderHtmlPref);
02075 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
02076 }
02077 mHeaders->setFolder( mFolder, forceJumpToUnread );
02078 updateMessageActions();
02079 updateFolderMenu();
02080 if (!aFolder)
02081 slotIntro();
02082 }
02083
02084
02085 void KMMainWidget::slotShowBusySplash()
02086 {
02087 if ( mReaderWindowActive )
02088 {
02089 mMsgView->displayBusyPage();
02090
02091 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
02092 mSearchAndHeaders->hide();
02093 }
02094 }
02095
02096 void KMMainWidget::showOfflinePage()
02097 {
02098 if ( !mReaderWindowActive ) return;
02099 mShowingOfflineScreen = true;
02100
02101 mMsgView->displayOfflinePage();
02102
02103 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
02104 mSearchAndHeaders->hide();
02105 }
02106
02107
02108 void KMMainWidget::slotMsgSelected(KMMessage *msg)
02109 {
02110 if ( msg && msg->parent() && !msg->isComplete() )
02111 {
02112 if ( msg->transferInProgress() )
02113 return;
02114 mMsgView->clear();
02115 mMsgView->setWaitingForSerNum( msg->getMsgSerNum() );
02116
02117 if ( mJob ) {
02118 disconnect( mJob, 0, mMsgView, 0 );
02119 delete mJob;
02120 }
02121 mJob = msg->parent()->createJob( msg, FolderJob::tGetMessage, 0,
02122 "STRUCTURE", mMsgView->attachmentStrategy() );
02123 connect(mJob, SIGNAL(messageRetrieved(KMMessage*)),
02124 mMsgView, SLOT(slotMessageArrived(KMMessage*)));
02125 mJob->start();
02126 } else {
02127 mMsgView->setMsg(msg);
02128 }
02129
02130 mMsgView->setHtmlOverride(mFolderHtmlPref);
02131 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
02132 mMsgView->setDecryptMessageOverwrite( false );
02133 mMsgView->setShowSignatureDetails( false );
02134 }
02135
02136
02137 void KMMainWidget::slotMsgChanged()
02138 {
02139 mHeaders->msgChanged();
02140 }
02141
02142
02143 void KMMainWidget::slotSelectFolder(KMFolder* folder)
02144 {
02145 QListViewItem* item = mFolderTree->indexOfFolder(folder);
02146 if ( item ) {
02147 mFolderTree->ensureItemVisible( item );
02148 mFolderTree->doFolderSelected( item );
02149 }
02150 }
02151
02152
02153 void KMMainWidget::slotSelectMessage(KMMessage* msg)
02154 {
02155 int idx = mFolder->find(msg);
02156 if (idx != -1) {
02157 mHeaders->setCurrentMsg(idx);
02158 if (mMsgView)
02159 mMsgView->setMsg(msg);
02160 else
02161 slotMsgActivated(msg);
02162 }
02163 }
02164
02165
02166 void KMMainWidget::slotReplaceMsgByUnencryptedVersion()
02167 {
02168 kdDebug(5006) << "KMMainWidget::slotReplaceMsgByUnencryptedVersion()" << endl;
02169 KMMessage* oldMsg = mHeaders->currentMsg();
02170 if( oldMsg ) {
02171 kdDebug(5006) << "KMMainWidget - old message found" << endl;
02172 if( oldMsg->hasUnencryptedMsg() ) {
02173 kdDebug(5006) << "KMMainWidget - extra unencrypted message found" << endl;
02174 KMMessage* newMsg = oldMsg->unencryptedMsg();
02175
02176 {
02177 QString msgId( oldMsg->msgId() );
02178 QString prefix("DecryptedMsg.");
02179 int oldIdx = msgId.find(prefix, 0, false);
02180 if( -1 == oldIdx ) {
02181 int leftAngle = msgId.findRev( '<' );
02182 msgId = msgId.insert( (-1 == leftAngle) ? 0 : ++leftAngle, prefix );
02183 }
02184 else {
02185
02186
02187 QCharRef c = msgId[ oldIdx+2 ];
02188 if( 'C' == c )
02189 c = 'c';
02190 else
02191 c = 'C';
02192 }
02193 newMsg->setMsgId( msgId );
02194 mMsgView->setIdOfLastViewedMessage( msgId );
02195 }
02196
02197 kdDebug(5006) << "KMMainWidget - adding unencrypted message to folder" << endl;
02198 mFolder->addMsg( newMsg );
02199
02200
02201 int newMsgIdx = mFolder->find( newMsg );
02202 Q_ASSERT( newMsgIdx != -1 );
02203
02204 mFolder->unGetMsg( newMsgIdx );
02205 int idx = mFolder->find( oldMsg );
02206 Q_ASSERT( idx != -1 );
02207
02208
02209 mHeaders->setCurrentItemByIndex( newMsgIdx );
02210
02211 if ( idx != -1 ) {
02212 kdDebug(5006) << "KMMainWidget - deleting encrypted message" << endl;
02213 mFolder->take( idx );
02214 }
02215
02216 kdDebug(5006) << "KMMainWidget - updating message actions" << endl;
02217 updateMessageActions();
02218
02219 kdDebug(5006) << "KMMainWidget - done." << endl;
02220 } else
02221 kdDebug(5006) << "KMMainWidget - NO EXTRA UNENCRYPTED MESSAGE FOUND" << endl;
02222 } else
02223 kdDebug(5006) << "KMMainWidget - PANIC: NO OLD MESSAGE FOUND" << endl;
02224 }
02225
02226
02227 void KMMainWidget::slotSetThreadStatusNew()
02228 {
02229 mHeaders->setThreadStatus(KMMsgStatusNew);
02230 }
02231
02232
02233 void KMMainWidget::slotSetThreadStatusUnread()
02234 {
02235 mHeaders->setThreadStatus(KMMsgStatusUnread);
02236 }
02237
02238
02239 void KMMainWidget::slotSetThreadStatusFlag()
02240 {
02241 mHeaders->setThreadStatus(KMMsgStatusFlag, true);
02242 }
02243
02244
02245 void KMMainWidget::slotSetThreadStatusRead()
02246 {
02247 mHeaders->setThreadStatus(KMMsgStatusRead);
02248 }
02249
02250
02251 void KMMainWidget::slotSetThreadStatusTodo()
02252 {
02253 mHeaders->setThreadStatus(KMMsgStatusTodo, true);
02254 }
02255
02256
02257 void KMMainWidget::slotSetThreadStatusWatched()
02258 {
02259 mHeaders->setThreadStatus(KMMsgStatusWatched, true);
02260 if (mWatchThreadAction->isChecked()) {
02261 mIgnoreThreadAction->setChecked(false);
02262 }
02263 }
02264
02265
02266 void KMMainWidget::slotSetThreadStatusIgnored()
02267 {
02268 mHeaders->setThreadStatus(KMMsgStatusIgnored, true);
02269 if (mIgnoreThreadAction->isChecked()) {
02270 mWatchThreadAction->setChecked(false);
02271 }
02272 }
02273
02274
02275 void KMMainWidget::slotNextMessage() { mHeaders->nextMessage(); }
02276 void KMMainWidget::slotNextUnreadMessage()
02277 {
02278 if ( !mHeaders->nextUnreadMessage() )
02279 if ( GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders )
02280 mFolderTree->nextUnreadFolder(true);
02281 }
02282 void KMMainWidget::slotNextImportantMessage() {
02283
02284 }
02285 void KMMainWidget::slotPrevMessage() { mHeaders->prevMessage(); }
02286 void KMMainWidget::slotPrevUnreadMessage()
02287 {
02288 if ( !mHeaders->prevUnreadMessage() )
02289 if ( GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders )
02290 mFolderTree->prevUnreadFolder();
02291 }
02292 void KMMainWidget::slotPrevImportantMessage() {
02293
02294 }
02295
02296 void KMMainWidget::slotDisplayCurrentMessage()
02297 {
02298 if ( mHeaders->currentMsg() )
02299 slotMsgActivated( mHeaders->currentMsg() );
02300 }
02301
02302
02303 void KMMainWidget::slotMsgActivated(KMMessage *msg)
02304 {
02305 if ( !msg ) return;
02306 if ( msg->parent() && !msg->isComplete() ) {
02307 FolderJob *job = msg->parent()->createJob( msg );
02308 connect( job, SIGNAL( messageRetrieved( KMMessage* ) ),
02309 SLOT( slotMsgActivated( KMMessage* ) ) );
02310 job->start();
02311 return;
02312 }
02313
02314 if (kmkernel->folderIsDraftOrOutbox( mFolder ) ) {
02315 mMsgActions->editCurrentMessage();
02316 return;
02317 }
02318 if ( kmkernel->folderIsTemplates( mFolder ) ) {
02319 slotUseTemplate();
02320 return;
02321 }
02322
02323 assert( msg != 0 );
02324 KMReaderMainWin *win = new KMReaderMainWin( mFolderHtmlPref, mFolderHtmlLoadExtPref );
02325 KConfigGroup reader( KMKernel::config(), "Reader" );
02326 bool useFixedFont = mMsgView ? mMsgView->isFixedFont()
02327 : reader.readBoolEntry( "useFixedFont", false );
02328 win->setUseFixedFont( useFixedFont );
02329 KMMessage *newMessage = new KMMessage(*msg);
02330 newMessage->setParent( msg->parent() );
02331 newMessage->setMsgSerNum( msg->getMsgSerNum() );
02332 newMessage->setReadyToShow( true );
02333 win->showMsg( overrideEncoding(), newMessage );
02334 win->show();
02335 }
02336
02337
02338 void KMMainWidget::slotMarkAll()
02339 {
02340 mHeaders->selectAll( true );
02341 }
02342
02343
02344 void KMMainWidget::slotMsgPopup(KMMessage&, const KURL &aUrl, const QPoint& aPoint)
02345 {
02346 KPopupMenu * menu = new KPopupMenu;
02347 updateMessageMenu();
02348 mUrlCurrent = aUrl;
02349
02350 bool urlMenuAdded = false;
02351
02352 if (!aUrl.isEmpty())
02353 {
02354 if (aUrl.protocol() == "mailto")
02355 {
02356
02357 mMsgView->mailToComposeAction()->plug( menu );
02358 mMsgView->mailToReplyAction()->plug( menu );
02359 mMsgView->mailToForwardAction()->plug( menu );
02360
02361 menu->insertSeparator();
02362 mMsgView->addAddrBookAction()->plug( menu );
02363 mMsgView->openAddrBookAction()->plug( menu );
02364 mMsgView->copyURLAction()->plug( menu );
02365 mMsgView->startImChatAction()->plug( menu );
02366
02367 mMsgView->startImChatAction()->setEnabled( kmkernel->imProxy()->initialize() );
02368
02369 } else {
02370
02371 mMsgView->urlOpenAction()->plug( menu );
02372 mMsgView->addBookmarksAction()->plug( menu );
02373 mMsgView->urlSaveAsAction()->plug( menu );
02374 mMsgView->copyURLAction()->plug( menu );
02375 }
02376 if ( aUrl.protocol() == "im" )
02377 {
02378
02379
02380
02381 mMsgView->startImChatAction()->plug( menu );
02382 }
02383
02384 urlMenuAdded=true;
02385 kdDebug( 0 ) << k_funcinfo << " URL is: " << aUrl << endl;
02386 }
02387
02388
02389 if(mMsgView && !mMsgView->copyText().isEmpty()) {
02390 if ( urlMenuAdded )
02391 menu->insertSeparator();
02392 mMsgActions->replyMenu()->plug(menu);
02393 menu->insertSeparator();
02394
02395 mMsgView->copyAction()->plug( menu );
02396 mMsgView->selectAllAction()->plug( menu );
02397 } else if ( !urlMenuAdded )
02398 {
02399
02400
02401 if (!mHeaders->currentMsg())
02402 {
02403 delete menu;
02404 return;
02405 }
02406
02407
02408 if ( mFolder->isTemplates() ) {
02409 mUseAction->plug( menu );
02410 } else {
02411
02412 if ( !mFolder->isSent() )
02413 mMsgActions->replyMenu()->plug( menu );
02414 mForwardActionMenu->plug( menu );
02415 }
02416 editAction()->plug(menu);
02417 menu->insertSeparator();
02418
02419 mCopyActionMenu->plug( menu );
02420 mMoveActionMenu->plug( menu );
02421
02422 menu->insertSeparator();
02423
02424 mMsgActions->messageStatusMenu()->plug( menu );
02425 menu->insertSeparator();
02426
02427 viewSourceAction()->plug(menu);
02428 if(mMsgView) {
02429 mMsgView->toggleFixFontAction()->plug(menu);
02430 }
02431 menu->insertSeparator();
02432 mPrintAction->plug( menu );
02433 mSaveAsAction->plug( menu );
02434 mSaveAttachmentsAction->plug( menu );
02435
02436 menu->insertSeparator();
02437 if( mFolder->isTrash() )
02438 mDeleteAction->plug( menu );
02439 else
02440 mTrashAction->plug( menu );
02441
02442 menu->insertSeparator();
02443 mMsgActions->createTodoAction()->plug( menu );
02444 }
02445 KAcceleratorManager::manage(menu);
02446 menu->exec(aPoint, 0);
02447 delete menu;
02448 }
02449
02450
02451 void KMMainWidget::getAccountMenu()
02452 {
02453 QStringList actList;
02454
02455 mActMenu->clear();
02456 actList = kmkernel->acctMgr()->getAccounts();
02457 QStringList::Iterator it;
02458 int id = 0;
02459 for(it = actList.begin(); it != actList.end() ; ++it, id++)
02460 mActMenu->insertItem((*it).replace("&", "&&"), id);
02461 }
02462
02463
02464 void KMMainWidget::getTransportMenu()
02465 {
02466 QStringList availTransports;
02467
02468 mSendMenu->clear();
02469 availTransports = KMail::TransportManager::transportNames();
02470 QStringList::Iterator it;
02471 int id = 0;
02472 for(it = availTransports.begin(); it != availTransports.end() ; ++it, id++)
02473 mSendMenu->insertItem((*it).replace("&", "&&"), id);
02474 }
02475
02476
02477 void KMMainWidget::updateCustomTemplateMenus()
02478 {
02479 if ( !mCustomTemplateActions.isEmpty() ) {
02480 QPtrList<KAction>::iterator ait = mCustomTemplateActions.begin();
02481 for ( ; ait != mCustomTemplateActions.end() ; ++ait ) {
02482 (*ait)->unplugAll();
02483 delete (*ait);
02484 }
02485 mCustomTemplateActions.clear();
02486 }
02487
02488 delete mCustomReplyActionMenu;
02489 delete mCustomReplyAllActionMenu;
02490 delete mCustomForwardActionMenu;
02491
02492 delete mCustomReplyMapper;
02493 delete mCustomReplyAllMapper;
02494 delete mCustomForwardMapper;
02495
02496 mCustomForwardActionMenu =
02497 new KActionMenu( i18n("Forward With Custom Template"),
02498 "mail_custom_forward",
02499 actionCollection(), "custom_forward" );
02500 QSignalMapper *mCustomForwardMapper = new QSignalMapper( this );
02501 connect( mCustomForwardMapper, SIGNAL( mapped( int ) ),
02502 this, SLOT( slotCustomForwardMsg( int ) ) );
02503 mForwardActionMenu->insert( mCustomForwardActionMenu );
02504
02505 mCustomReplyActionMenu =
02506 new KActionMenu( i18n("Reply With Custom Template"), "mail_custom_reply",
02507 actionCollection(), "custom_reply" );
02508 QSignalMapper *mCustomReplyMapper = new QSignalMapper( this );
02509 connect( mCustomReplyMapper, SIGNAL( mapped( int ) ),
02510 this, SLOT( slotCustomReplyToMsg( int ) ) );
02511 mMsgActions->replyMenu()->insert( mCustomReplyActionMenu );
02512
02513 mCustomReplyAllActionMenu =
02514 new KActionMenu( i18n("Reply to All With Custom Template"),
02515 "mail_custom_reply_all",
02516 actionCollection(), "custom_reply_all" );
02517 QSignalMapper *mCustomReplyAllMapper = new QSignalMapper( this );
02518 connect( mCustomReplyAllMapper, SIGNAL( mapped( int ) ),
02519 this, SLOT( slotCustomReplyAllToMsg( int ) ) );
02520 mMsgActions->replyMenu()->insert( mCustomReplyAllActionMenu );
02521
02522 mCustomTemplates.clear();
02523
02524 QStringList list = GlobalSettingsBase::self()->customTemplates();
02525 QStringList::iterator it = list.begin();
02526 int idx = 0;
02527 int replyc = 0;
02528 int replyallc = 0;
02529 int forwardc = 0;
02530 for ( ; it != list.end(); ++it ) {
02531 CTemplates t( *it );
02532 mCustomTemplates.append( *it );
02533
02534 KAction *action;
02535 switch ( t.type() ) {
02536 case CustomTemplates::TReply:
02537 action = new KAction( (*it).replace( "&", "&&" ),
02538 KShortcut( t.shortcut() ),
02539 mCustomReplyMapper,
02540 SLOT( map() ),
02541 actionCollection(),
02542 (*it).utf8() );
02543 mCustomReplyMapper->setMapping( action, idx );
02544 mCustomReplyActionMenu->insert( action, idx );
02545 mCustomTemplateActions.append( action );
02546 ++replyc;
02547 break;
02548 case CustomTemplates::TReplyAll:
02549 action = new KAction( (*it).replace( "&", "&&" ),
02550 KShortcut( t.shortcut() ),
02551 mCustomReplyAllMapper,
02552 SLOT( map() ),
02553 actionCollection(),
02554 (*it).utf8() );
02555 mCustomReplyAllMapper->setMapping( action, idx );
02556 mCustomReplyAllActionMenu->insert( action, idx );
02557 mCustomTemplateActions.append( action );
02558 ++replyallc;
02559 break;
02560 case CustomTemplates::TForward:
02561 action = new KAction( (*it).replace( "&", "&&" ),
02562 KShortcut( t.shortcut() ),
02563 mCustomForwardMapper,
02564 SLOT( map() ),
02565 actionCollection(),
02566 (*it).utf8() );
02567 mCustomForwardMapper->setMapping( action, idx );
02568 mCustomForwardActionMenu->insert( action, idx );
02569 mCustomTemplateActions.append( action );
02570 ++forwardc;
02571 break;
02572 case CustomTemplates::TUniversal:
02573 action = new KAction( (*it).replace( "&", "&&" ),
02574 KShortcut::null(),
02575 mCustomReplyMapper,
02576 SLOT( map() ),
02577 actionCollection(),
02578 (*it).utf8() );
02579 mCustomReplyMapper->setMapping( action, idx );
02580 mCustomReplyActionMenu->insert( action, idx );
02581 mCustomTemplateActions.append( action );
02582 ++replyc;
02583 action = new KAction( (*it).replace( "&", "&&" ),
02584 KShortcut::null(),
02585 mCustomReplyAllMapper,
02586 SLOT( map() ),
02587 actionCollection(),
02588 (*it).utf8() );
02589 mCustomReplyAllMapper->setMapping( action, idx );
02590 mCustomReplyAllActionMenu->insert( action, idx );
02591 mCustomTemplateActions.append( action );
02592 ++replyallc;
02593 action = new KAction( (*it).replace( "&", "&&" ),
02594 KShortcut::null(),
02595 mCustomForwardMapper,
02596 SLOT( map() ),
02597 actionCollection(),
02598 (*it).utf8() );
02599 mCustomForwardMapper->setMapping( action, idx );
02600 mCustomForwardActionMenu->insert( action, idx );
02601 mCustomTemplateActions.append( action );
02602 ++forwardc;
02603 break;
02604 }
02605
02606 ++idx;
02607 }
02608 if ( !replyc ) {
02609 mCustomReplyActionMenu->popupMenu()->insertItem( i18n( "(no custom templates)" ), 0 );
02610 mCustomReplyActionMenu->popupMenu()->setItemEnabled( 0, false );
02611 mCustomReplyActionMenu->setEnabled(false);
02612 }
02613 if ( !replyallc ) {
02614 mCustomReplyAllActionMenu->popupMenu()->insertItem( i18n( "(no custom templates)" ), 0 );
02615 mCustomReplyAllActionMenu->popupMenu()->setItemEnabled( 0, false );
02616 mCustomReplyAllActionMenu->setEnabled(false);
02617 }
02618 if ( !forwardc ) {
02619 mCustomForwardActionMenu->popupMenu()->insertItem( i18n( "(no custom templates)" ), 0 );
02620 mCustomForwardActionMenu->popupMenu()->setItemEnabled( 0, false );
02621 mCustomForwardActionMenu->setEnabled(false);
02622 }
02623
02624 }
02625
02626
02627
02628 void KMMainWidget::setupActions()
02629 {
02630 mMsgActions = new KMail::MessageActions( actionCollection(), this );
02631 mMsgActions->setMessageView( mMsgView );
02632
02633
02634 mSaveAsAction = new KAction( i18n("Save &As..."), "filesave",
02635 KStdAccel::shortcut(KStdAccel::Save),
02636 this, SLOT(slotSaveMsg()), actionCollection(), "file_save_as" );
02637
02638 mOpenAction = KStdAction::open( this, SLOT( slotOpenMsg() ),
02639 actionCollection() );
02640
02641 (void) new KAction( i18n("&Compact All Folders"), 0,
02642 this, SLOT(slotCompactAll()),
02643 actionCollection(), "compact_all_folders" );
02644
02645 (void) new KAction( i18n("&Expire All Folders"), 0,
02646 this, SLOT(slotExpireAll()),
02647 actionCollection(), "expire_all_folders" );
02648
02649 (void) new KAction( i18n("&Refresh Local IMAP Cache"), "refresh",
02650 this, SLOT(slotInvalidateIMAPFolders()),
02651 actionCollection(), "file_invalidate_imap_cache" );
02652
02653 (void) new KAction( i18n("Empty All &Trash Folders"), 0,
02654 KMKernel::self(), SLOT(slotEmptyTrash()),
02655 actionCollection(), "empty_trash" );
02656
02657 (void) new KAction( i18n("Check &Mail"), "mail_get", CTRL+Key_L,
02658 this, SLOT(slotCheckMail()),
02659 actionCollection(), "check_mail" );
02660
02661 mFavoritesCheckMailAction = new KAction( i18n("Check Mail in Favorite Folders"),
02662 "mail_get", CTRL+SHIFT+Key_L, 0, 0,
02663 actionCollection(), "favorite_check_mail" );
02664 if ( mFavoriteFolderView )
02665 connect( mFavoritesCheckMailAction, SIGNAL(activated()), mFavoriteFolderView, SLOT(checkMail()) );
02666
02667 KActionMenu *actActionMenu = new
02668 KActionMenu( i18n("Check Mail &In"), "mail_get", actionCollection(),
02669 "check_mail_in" );
02670 actActionMenu->setDelayed(true);
02671
02672 connect(actActionMenu,SIGNAL(activated()),this,SLOT(slotCheckMail()));
02673
02674 mActMenu = actActionMenu->popupMenu();
02675 connect(mActMenu,SIGNAL(activated(int)),this,SLOT(slotCheckOneAccount(int)));
02676 connect(mActMenu,SIGNAL(aboutToShow()),this,SLOT(getAccountMenu()));
02677
02678 (void) new KAction( i18n("&Send Queued Messages"), "mail_send", 0, this,
02679 SLOT(slotSendQueued()), actionCollection(), "send_queued");
02680
02681 (void) new KAction( i18n("Online Status (unknown)"), "online_status", 0, this,
02682 SLOT(slotOnlineStatus()), actionCollection(), "online_status");
02683
02684 KActionMenu *sendActionMenu = new
02685 KActionMenu( i18n("Send Queued Messages Via"), "mail_send_via", actionCollection(),
02686 "send_queued_via" );
02687 sendActionMenu->setDelayed(true);
02688
02689 mSendMenu = sendActionMenu->popupMenu();
02690 connect(mSendMenu,SIGNAL(activated(int)), this, SLOT(slotSendQueuedVia(int)));
02691 connect(mSendMenu,SIGNAL(aboutToShow()),this,SLOT(getTransportMenu()));
02692
02693 KAction *act;
02694
02695 if (parent()->inherits("KMMainWin")) {
02696 act = new KAction( i18n("&Address Book..."), "contents", 0, this,
02697 SLOT(slotAddrBook()), actionCollection(), "addressbook" );
02698 if (KStandardDirs::findExe("kaddressbook").isEmpty()) act->setEnabled(false);
02699 }
02700
02701 act = new KAction( i18n("Certificate Manager..."), "pgp-keys", 0, this,
02702 SLOT(slotStartCertManager()), actionCollection(), "tools_start_certman");
02703
02704 if (KStandardDirs::findExe("kleopatra").isEmpty()) act->setEnabled(false);
02705
02706 act = new KAction( i18n("GnuPG Log Viewer..."), "pgp-keys", 0, this,
02707 SLOT(slotStartWatchGnuPG()), actionCollection(), "tools_start_kwatchgnupg");
02708
02709 if (KStandardDirs::findExe("kwatchgnupg").isEmpty()) act->setEnabled(false);
02710
02711 act = new KAction( i18n("&Import Messages..."), "fileopen", 0, this,
02712 SLOT(slotImport()), actionCollection(), "import" );
02713 if (KStandardDirs::findExe("kmailcvt").isEmpty()) act->setEnabled(false);
02714
02715 #if !defined(NDEBUG)
02716 (void) new KAction( i18n("&Debug Sieve..."),
02717 "idea", 0, this, SLOT(slotDebugSieve()),
02718 actionCollection(), "tools_debug_sieve" );
02719 #endif
02720
02721 if ( GlobalSettings::allowOutOfOfficeSettings() ) {
02722 (void) new KAction( i18n("Edit \"Out of Office\" Replies..."),
02723 "configure", 0, this, SLOT(slotEditVacation()),
02724 actionCollection(), "tools_edit_vacation" );
02725
02726 }
02727
02728 (void) new KAction( i18n("Filter &Log Viewer..."), 0, this,
02729 SLOT(slotFilterLogViewer()), actionCollection(), "filter_log_viewer" );
02730
02731 (void) new KAction( i18n("&Anti-Spam Wizard..."), 0, this,
02732 SLOT(slotAntiSpamWizard()), actionCollection(), "antiSpamWizard" );
02733 (void) new KAction( i18n("&Anti-Virus Wizard..."), 0, this,
02734 SLOT(slotAntiVirusWizard()), actionCollection(), "antiVirusWizard" );
02735
02736
02737 mTrashAction = new KAction( KGuiItem( i18n("&Move to Trash"), "edittrash",
02738 i18n("Move message to trashcan") ),
02739 Key_Delete, this, SLOT(slotTrashMsg()),
02740 actionCollection(), "move_to_trash" );
02741
02742
02743
02744
02745
02746 mDeleteAction = new KAction( i18n("&Delete"), "editdelete", SHIFT+Key_Delete, this,
02747 SLOT(slotDeleteMsg()), actionCollection(), "delete" );
02748 mDeleteAction->plugAccel( actionCollection()->kaccel() );
02749
02750 mTrashThreadAction = new KAction( KGuiItem( i18n("M&ove Thread to Trash"), "edittrash",
02751 i18n("Move thread to trashcan") ),
02752 CTRL+Key_Delete, this, SLOT(slotTrashThread()),
02753 actionCollection(), "move_thread_to_trash" );
02754
02755 mDeleteThreadAction = new KAction( i18n("Delete T&hread"), "editdelete", CTRL+SHIFT+Key_Delete, this,
02756 SLOT(slotDeleteThread()), actionCollection(), "delete_thread" );
02757
02758
02759 (void) new KAction( i18n("&Find Messages..."), "mail_find", Key_S, this,
02760 SLOT(slotRequestFullSearchFromQuickSearch()), actionCollection(), "search_messages" );
02761
02762 mFindInMessageAction = new KAction( i18n("&Find in Message..."), "find", KStdAccel::shortcut(KStdAccel::Find), this,
02763 SLOT(slotFind()), actionCollection(), "find_in_messages" );
02764
02765 (void) new KAction( i18n("Select &All Messages"), KStdAccel::selectAll(), this,
02766 SLOT(slotMarkAll()), actionCollection(), "mark_all_messages" );
02767
02768
02769 mNewFolderAction = new KAction( i18n("&New Folder..."), "folder_new", 0, mFolderTree,
02770 SLOT(addChildFolder()), actionCollection(), "new_folder" );
02771
02772 mModifyFolderAction = new KAction( i18n("&Properties"), "configure", 0, this,
02773 SLOT(slotModifyFolder()), actionCollection(), "modify" );
02774
02775 mFolderMailingListPropertiesAction = new KAction( i18n("&Mailing List Management..."),
02776 0, this, SLOT( slotFolderMailingListProperties() ),
02777 actionCollection(), "folder_mailinglist_properties" );
02778
02779 mFolderShortCutCommandAction = new KAction( i18n("&Assign Shortcut..."), "configure_shortcuts",
02780 0, this, SLOT( slotFolderShortcutCommand() ), actionCollection(),
02781 "folder_shortcut_command" );
02782
02783
02784 mMarkAllAsReadAction = new KAction( i18n("Mark All Messages as &Read"), "goto", 0, this,
02785 SLOT(slotMarkAllAsRead()), actionCollection(), "mark_all_as_read" );
02786
02787 mExpireFolderAction = new KAction(i18n("&Expiration Settings"), 0, this, SLOT(slotExpireFolder()),
02788 actionCollection(), "expire");
02789
02790 mCompactFolderAction = new KAction( i18n("&Compact Folder"), 0, this,
02791 SLOT(slotCompactFolder()), actionCollection(), "compact" );
02792
02793 mRefreshFolderAction = new KAction( i18n("Check Mail &in This Folder"), "reload",
02794 KStdAccel::shortcut( KStdAccel::Reload ), this,
02795 SLOT(slotRefreshFolder()),
02796 actionCollection(), "refresh_folder" );
02797 mTroubleshootFolderAction = 0;
02798
02799 mEmptyFolderAction = new KAction( "foo" , "edittrash", 0, this,
02800 SLOT(slotEmptyFolder()), actionCollection(), "empty" );
02801
02802 mRemoveFolderAction = new KAction( "foo" , "editdelete", 0, this,
02803 SLOT(slotRemoveFolder()), actionCollection(), "delete_folder" );
02804
02805 mPreferHtmlAction = new KToggleAction( i18n("Prefer &HTML to Plain Text"), 0, this,
02806 SLOT(slotOverrideHtml()), actionCollection(), "prefer_html" );
02807
02808 mPreferHtmlLoadExtAction = new KToggleAction( i18n("Load E&xternal References"), 0, this,
02809 SLOT(slotOverrideHtmlLoadExt()), actionCollection(), "prefer_html_external_refs" );
02810
02811 mThreadMessagesAction = new KToggleAction( i18n("&Thread Messages"), 0, this,
02812 SLOT(slotOverrideThread()), actionCollection(), "thread_messages" );
02813
02814 mThreadBySubjectAction = new KToggleAction( i18n("Thread Messages also by &Subject"), 0, this,
02815 SLOT(slotToggleSubjectThreading()), actionCollection(), "thread_messages_by_subject" );
02816
02817 new KAction( i18n("Copy Folder"), "editcopy", SHIFT+CTRL+Key_C, folderTree(),
02818 SLOT(copyFolder()), actionCollection(), "copy_folder" );
02819 new KAction( i18n("Cut Folder"), "editcut", SHIFT+CTRL+Key_X, folderTree(),
02820 SLOT(cutFolder()), actionCollection(), "cut_folder" );
02821 new KAction( i18n("Paste Folder"), "editpaste", SHIFT+CTRL+Key_V, folderTree(),
02822 SLOT(pasteFolder()), actionCollection(), "paste_folder" );
02823
02824 new KAction( i18n("Copy Messages"), "editcopy", ALT+CTRL+Key_C, headers(),
02825 SLOT(copyMessages()), actionCollection(), "copy_messages" );
02826 new KAction( i18n("Cut Messages"), "editcut", ALT+CTRL+Key_X, headers(),
02827 SLOT(cutMessages()), actionCollection(), "cut_messages" );
02828 new KAction( i18n("Paste Messages"), "editpaste", ALT+CTRL+Key_V, headers(),
02829 SLOT(pasteMessages()), actionCollection(), "paste_messages" );
02830
02831
02832 (void) new KAction( i18n("&New Message..."), "mail_new", KStdAccel::shortcut(KStdAccel::New), this,
02833 SLOT(slotCompose()), actionCollection(), "new_message" );
02834 mTemplateMenu =
02835 new KActionMenu( i18n("New Message From &Template"), "filenew",
02836 actionCollection(), "new_from_template" );
02837 mTemplateMenu->setDelayed( true );
02838 connect( mTemplateMenu->popupMenu(), SIGNAL( aboutToShow() ), this,
02839 SLOT( slotShowNewFromTemplate() ) );
02840 connect( mTemplateMenu->popupMenu(), SIGNAL( activated(int) ), this,
02841 SLOT( slotNewFromTemplate(int) ) );
02842
02843 KAction* newToML = new KAction( i18n("New Message t&o Mailing-List..."), "mail_post_to",
02844 CTRL+SHIFT+Key_N, this,
02845 SLOT(slotPostToML()), actionCollection(), "post_message" );
02846 newToML->plugAccel( actionCollection()->kaccel() );
02847
02848 mForwardActionMenu = new KActionMenu( i18n("Message->","&Forward"),
02849 "mail_forward", actionCollection(),
02850 "message_forward" );
02851
02852 mForwardInlineAction = new KAction( i18n("&Inline..."),
02853 "mail_forward", 0, this,
02854 SLOT(slotForwardInlineMsg()),
02855 actionCollection(),
02856 "message_forward_inline" );
02857
02858 mForwardAttachedAction = new KAction( i18n("Message->Forward->","As &Attachment..."),
02859 "mail_forward", 0, this,
02860 SLOT(slotForwardAttachedMsg()),
02861 actionCollection(),
02862 "message_forward_as_attachment" );
02863
02864 mForwardDigestAction = new KAction( i18n("Message->Forward->","As Di&gest..."),
02865 "mail_forward", 0, this,
02866 SLOT(slotForwardDigestMsg()),
02867 actionCollection(),
02868 "message_forward_as_digest" );
02869
02870 mRedirectAction = new KAction( i18n("Message->Forward->","&Redirect..."),
02871 "mail_forward", Key_E, this,
02872 SLOT(slotRedirectMsg()),
02873 actionCollection(),
02874 "message_forward_redirect" );
02875
02876
02877 setupForwardActions();
02878
02879 mForwardActionMenu->insert( mForwardDigestAction );
02880 mForwardActionMenu->insert( mRedirectAction );
02881
02882 mSendAgainAction = new KAction( i18n("Send A&gain..."), 0, this,
02883 SLOT(slotResendMsg()), actionCollection(), "send_again" );
02884
02885
02886
02887 mFilterMenu = new KActionMenu( i18n("&Create Filter"), "filter", actionCollection(), "create_filter" );
02888 connect( mFilterMenu, SIGNAL(activated()), this,
02889 SLOT(slotFilter()) );
02890 mSubjectFilterAction = new KAction( i18n("Filter on &Subject..."), 0, this,
02891 SLOT(slotSubjectFilter()),
02892 actionCollection(), "subject_filter");
02893 mFilterMenu->insert( mSubjectFilterAction );
02894
02895 mFromFilterAction = new KAction( i18n("Filter on &From..."), 0, this,
02896 SLOT(slotFromFilter()),
02897 actionCollection(), "from_filter");
02898 mFilterMenu->insert( mFromFilterAction );
02899
02900 mToFilterAction = new KAction( i18n("Filter on &To..."), 0, this,
02901 SLOT(slotToFilter()),
02902 actionCollection(), "to_filter");
02903 mFilterMenu->insert( mToFilterAction );
02904
02905 mListFilterAction = new KAction( i18n("Filter on Mailing-&List..."), 0, this,
02906 SLOT(slotMailingListFilter()), actionCollection(),
02907 "mlist_filter");
02908 mFilterMenu->insert( mListFilterAction );
02909
02910 mPrintAction = KStdAction::print (this, SLOT(slotPrintMsg()), actionCollection());
02911
02912 mUseAction = new KAction( i18n("New Message From &Template"), "filenew",
02913 Key_N, this, SLOT( slotUseTemplate() ),
02914 actionCollection(), "use_template" );
02915 mUseAction->plugAccel( actionCollection()->kaccel() );
02916
02917
02918 mThreadStatusMenu = new KActionMenu ( i18n( "Mark &Thread" ),
02919 actionCollection(), "thread_status" );
02920
02921 mMarkThreadAsReadAction = new KAction(KGuiItem(i18n("Mark Thread as &Read"), "kmmsgread",
02922 i18n("Mark all messages in the selected thread as read")),
02923 0, this, SLOT(slotSetThreadStatusRead()),
02924 actionCollection(), "thread_read");
02925 mThreadStatusMenu->insert( mMarkThreadAsReadAction );
02926
02927 mMarkThreadAsNewAction = new KAction(KGuiItem(i18n("Mark Thread as &New"), "kmmsgnew",
02928 i18n("Mark all messages in the selected thread as new")),
02929 0, this, SLOT(slotSetThreadStatusNew()),
02930 actionCollection(), "thread_new");
02931 mThreadStatusMenu->insert( mMarkThreadAsNewAction );
02932
02933 mMarkThreadAsUnreadAction = new KAction(KGuiItem(i18n("Mark Thread as &Unread"), "kmmsgunseen",
02934 i18n("Mark all messages in the selected thread as unread")),
02935 0, this, SLOT(slotSetThreadStatusUnread()),
02936 actionCollection(), "thread_unread");
02937 mThreadStatusMenu->insert( mMarkThreadAsUnreadAction );
02938
02939 mThreadStatusMenu->insert( new KActionSeparator( this ) );
02940
02941
02942 mToggleThreadFlagAction = new KToggleAction(i18n("Mark Thread as &Important"), "mail_flag",
02943 0, this, SLOT(slotSetThreadStatusFlag()),
02944 actionCollection(), "thread_flag");
02945 mToggleThreadFlagAction->setCheckedState( i18n("Remove &Important Thread Mark") );
02946 mThreadStatusMenu->insert( mToggleThreadFlagAction );
02947
02948 mToggleThreadTodoAction = new KToggleAction(i18n("Mark Thread as &Action Item"), "mail_todo",
02949 0, this, SLOT(slotSetThreadStatusTodo()),
02950 actionCollection(), "thread_todo");
02951 mToggleThreadTodoAction->setCheckedState( i18n("Remove &Action Item Thread Mark") );
02952 mThreadStatusMenu->insert( mToggleThreadTodoAction );
02953
02954
02955 mWatchThreadAction = new KToggleAction(i18n("&Watch Thread"), "kmmsgwatched",
02956 0, this, SLOT(slotSetThreadStatusWatched()),
02957 actionCollection(), "thread_watched");
02958
02959 mIgnoreThreadAction = new KToggleAction(i18n("&Ignore Thread"), "mail_ignore",
02960 0, this, SLOT(slotSetThreadStatusIgnored()),
02961 actionCollection(), "thread_ignored");
02962
02963 mThreadStatusMenu->insert( new KActionSeparator( this ) );
02964 mThreadStatusMenu->insert( mWatchThreadAction );
02965 mThreadStatusMenu->insert( mIgnoreThreadAction );
02966
02967 mSaveAttachmentsAction = new KAction( i18n("Save A&ttachments..."), "attach",
02968 0, this, SLOT(slotSaveAttachments()),
02969 actionCollection(), "file_save_attachments" );
02970
02971 mMoveActionMenu = new KActionMenu( i18n("&Move To" ),
02972 actionCollection(), "move_to" );
02973
02974 mCopyActionMenu = new KActionMenu( i18n("&Copy To" ),
02975 actionCollection(), "copy_to" );
02976
02977 mApplyAllFiltersAction = new KAction( i18n("Appl&y All Filters"), "filter",
02978 CTRL+Key_J, this,
02979 SLOT(slotApplyFilters()),
02980 actionCollection(), "apply_filters" );
02981
02982 mApplyFilterActionsMenu = new KActionMenu( i18n("A&pply Filter" ),
02983 actionCollection(),
02984 "apply_filter_actions" );
02985
02986
02987
02988 KActionMenu * unreadMenu =
02989 new KActionMenu( i18n("View->", "&Unread Count"),
02990 actionCollection(), "view_unread" );
02991 unreadMenu->setToolTip( i18n("Choose how to display the count of unread messages") );
02992
02993 mUnreadColumnToggle = new KRadioAction( i18n("View->Unread Count", "View in &Separate Column"), 0, this,
02994 SLOT(slotToggleUnread()),
02995 actionCollection(), "view_unread_column" );
02996 mUnreadColumnToggle->setExclusiveGroup( "view_unread_group" );
02997 unreadMenu->insert( mUnreadColumnToggle );
02998
02999 mUnreadTextToggle = new KRadioAction( i18n("View->Unread Count", "View After &Folder Name"), 0, this,
03000 SLOT(slotToggleUnread()),
03001 actionCollection(), "view_unread_text" );
03002 mUnreadTextToggle->setExclusiveGroup( "view_unread_group" );
03003 unreadMenu->insert( mUnreadTextToggle );
03004
03005
03006 mTotalColumnToggle = new KToggleAction( i18n("View->", "&Total Column"), 0, this,
03007 SLOT(slotToggleTotalColumn()),
03008 actionCollection(), "view_columns_total" );
03009 mTotalColumnToggle->setToolTip( i18n("Toggle display of column showing the "
03010 "total number of messages in folders.") );
03011 mSizeColumnToggle = new KToggleAction( i18n("View->", "&Size Column"), 0, this,
03012 SLOT(slotToggleSizeColumn()),
03013 actionCollection(), "view_columns_size" );
03014 mSizeColumnToggle->setToolTip( i18n("Toggle display of column showing the "
03015 "total size of messages in folders.") );
03016
03017 (void)new KAction( KGuiItem( i18n("View->","&Expand Thread"), QString::null,
03018 i18n("Expand the current thread") ),
03019 Key_Period, this,
03020 SLOT(slotExpandThread()),
03021 actionCollection(), "expand_thread" );
03022
03023 (void)new KAction( KGuiItem( i18n("View->","&Collapse Thread"), QString::null,
03024 i18n("Collapse the current thread") ),
03025 Key_Comma, this,
03026 SLOT(slotCollapseThread()),
03027 actionCollection(), "collapse_thread" );
03028
03029 (void)new KAction( KGuiItem( i18n("View->","Ex&pand All Threads"), QString::null,
03030 i18n("Expand all threads in the current folder") ),
03031 CTRL+Key_Period, this,
03032 SLOT(slotExpandAllThreads()),
03033 actionCollection(), "expand_all_threads" );
03034
03035 (void)new KAction( KGuiItem( i18n("View->","C&ollapse All Threads"), QString::null,
03036 i18n("Collapse all threads in the current folder") ),
03037 CTRL+Key_Comma, this,
03038 SLOT(slotCollapseAllThreads()),
03039 actionCollection(), "collapse_all_threads" );
03040
03041 mViewSourceAction = new KAction( i18n("&View Source"), Key_V, this,
03042 SLOT(slotShowMsgSrc()), actionCollection(),
03043 "view_source" );
03044
03045 KAction* dukeOfMonmoth = new KAction( i18n("&Display Message"), Key_Return, this,
03046 SLOT( slotDisplayCurrentMessage() ), actionCollection(),
03047 "display_message" );
03048 dukeOfMonmoth->plugAccel( actionCollection()->kaccel() );
03049
03050
03051 new KAction( KGuiItem( i18n("&Next Message"), QString::null,
03052 i18n("Go to the next message") ),
03053 "N;Right", this, SLOT(slotNextMessage()),
03054 actionCollection(), "go_next_message" );
03055
03056 new KAction( KGuiItem( i18n("Next &Unread Message"),
03057 QApplication::reverseLayout() ? "previous" : "next",
03058 i18n("Go to the next unread message") ),
03059 Key_Plus, this, SLOT(slotNextUnreadMessage()),
03060 actionCollection(), "go_next_unread_message" );
03061
03062
03063
03064
03065
03066
03067
03068
03069 new KAction( KGuiItem( i18n("&Previous Message"), QString::null,
03070 i18n("Go to the previous message") ),
03071 "P;Left", this, SLOT(slotPrevMessage()),
03072 actionCollection(), "go_prev_message" );
03073
03074 new KAction( KGuiItem( i18n("Previous Unread &Message"),
03075 QApplication::reverseLayout() ? "next" : "previous",
03076 i18n("Go to the previous unread message") ),
03077 Key_Minus, this, SLOT(slotPrevUnreadMessage()),
03078 actionCollection(), "go_prev_unread_message" );
03079
03080
03081
03082
03083
03084
03085
03086
03087 KAction *action =
03088 new KAction( KGuiItem( i18n("Next Unread &Folder"), QString::null,
03089 i18n("Go to the next folder with unread messages") ),
03090 ALT+Key_Plus, this, SLOT(slotNextUnreadFolder()),
03091 actionCollection(), "go_next_unread_folder" );
03092 KShortcut shortcut = action->shortcut();
03093 shortcut.append( KKey( CTRL+Key_Plus ) );
03094 action->setShortcut( shortcut );
03095
03096 action =
03097 new KAction( KGuiItem( i18n("Previous Unread F&older"), QString::null,
03098 i18n("Go to the previous folder with unread messages") ),
03099 ALT+Key_Minus, this, SLOT(slotPrevUnreadFolder()),
03100 actionCollection(), "go_prev_unread_folder" );
03101 shortcut = action->shortcut();
03102 shortcut.append( KKey( CTRL+Key_Minus ) );
03103 action->setShortcut( shortcut );
03104
03105 new KAction( KGuiItem( i18n("Go->","Next Unread &Text"), QString::null,
03106 i18n("Go to the next unread text"),
03107 i18n("Scroll down current message. "
03108 "If at end of current message, "
03109 "go to next unread message.") ),
03110 Key_Space, this, SLOT(slotReadOn()),
03111 actionCollection(), "go_next_unread_text" );
03112
03113
03114 mToggleShowQuickSearchAction = new KToggleAction(i18n("Show Quick Search"), QString::null,
03115 0, this, SLOT(slotToggleShowQuickSearch()),
03116 actionCollection(), "show_quick_search");
03117 mToggleShowQuickSearchAction->setChecked( GlobalSettings::self()->quickSearchActive() );
03118 mToggleShowQuickSearchAction->setWhatsThis(
03119 i18n( GlobalSettings::self()->quickSearchActiveItem()->whatsThis().utf8() ) );
03120
03121 (void) new KAction( i18n("Configure &Filters..."), 0, this,
03122 SLOT(slotFilter()), actionCollection(), "filter" );
03123 (void) new KAction( i18n("Configure &POP Filters..."), 0, this,
03124 SLOT(slotPopFilter()), actionCollection(), "popFilter" );
03125 (void) new KAction( i18n("Manage &Sieve Scripts..."), 0, this,
03126 SLOT(slotManageSieveScripts()), actionCollection(), "sieveFilters" );
03127
03128 (void) new KAction( KGuiItem( i18n("KMail &Introduction"), 0,
03129 i18n("Display KMail's Welcome Page") ),
03130 0, this, SLOT(slotIntro()),
03131 actionCollection(), "help_kmail_welcomepage" );
03132
03133
03134
03135 (void) new KAction( i18n("Configure &Notifications..."),
03136 "knotify", 0, this,
03137 SLOT(slotEditNotifications()), actionCollection(),
03138 "kmail_configure_notifications" );
03139
03140 (void) new KAction( i18n("&Configure KMail..."),
03141 "configure", 0, kmkernel,
03142 SLOT(slotShowConfigurationDialog()), actionCollection(),
03143 "kmail_configure_kmail" );
03144
03145 KStdAction::undo(this, SLOT(slotUndo()), actionCollection(), "kmail_undo");
03146
03147 KStdAction::tipOfDay( this, SLOT( slotShowTip() ), actionCollection() );
03148
03149 menutimer = new QTimer( this, "menutimer" );
03150 connect( menutimer, SIGNAL( timeout() ), SLOT( updateMessageActions() ) );
03151 connect( kmkernel->undoStack(),
03152 SIGNAL( undoStackChanged() ), this, SLOT( slotUpdateUndo() ));
03153
03154 initializeIMAPActions( false );
03155 updateMessageActions();
03156 updateCustomTemplateMenus();
03157 updateFolderMenu();
03158 }
03159
03160 void KMMainWidget::setupForwardingActionsList()
03161 {
03162 QPtrList<KAction> mForwardActionList;
03163 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
03164 mGUIClient->unplugActionList( "forward_action_list" );
03165 mForwardActionList.append( mForwardInlineAction );
03166 mForwardActionList.append( mForwardAttachedAction );
03167 mForwardActionList.append( mForwardDigestAction );
03168 mForwardActionList.append( mRedirectAction );
03169 mGUIClient->plugActionList( "forward_action_list", mForwardActionList );
03170 } else {
03171 mGUIClient->unplugActionList( "forward_action_list" );
03172 mForwardActionList.append( mForwardAttachedAction );
03173 mForwardActionList.append( mForwardInlineAction );
03174 mForwardActionList.append( mForwardDigestAction );
03175 mForwardActionList.append( mRedirectAction );
03176 mGUIClient->plugActionList( "forward_action_list", mForwardActionList );
03177 }
03178 }
03179
03180
03181 void KMMainWidget::slotEditNotifications()
03182 {
03183 if(kmkernel->xmlGuiInstance())
03184 KNotifyDialog::configure(this, 0, kmkernel->xmlGuiInstance()->aboutData());
03185 else
03186 KNotifyDialog::configure(this);
03187 }
03188
03189 void KMMainWidget::slotEditKeys()
03190 {
03191 KKeyDialog::configure( actionCollection(),
03192 true
03193 );
03194 }
03195
03196
03197 void KMMainWidget::slotReadOn()
03198 {
03199 if ( !mMsgView )
03200 return;
03201
03202 if ( !mMsgView->atBottom() ) {
03203 mMsgView->slotJumpDown();
03204 return;
03205 }
03206 slotNextUnreadMessage();
03207 }
03208
03209 void KMMainWidget::slotNextUnreadFolder() {
03210 if ( !mFolderTree ) return;
03211 mFolderTree->nextUnreadFolder();
03212 }
03213
03214 void KMMainWidget::slotPrevUnreadFolder() {
03215 if ( !mFolderTree ) return;
03216 mFolderTree->prevUnreadFolder();
03217 }
03218
03219 void KMMainWidget::slotExpandThread()
03220 {
03221 mHeaders->slotExpandOrCollapseThread( true );
03222 }
03223
03224 void KMMainWidget::slotCollapseThread()
03225 {
03226 mHeaders->slotExpandOrCollapseThread( false );
03227 }
03228
03229 void KMMainWidget::slotExpandAllThreads()
03230 {
03231 mHeaders->slotExpandOrCollapseAllThreads( true );
03232 }
03233
03234 void KMMainWidget::slotCollapseAllThreads()
03235 {
03236 mHeaders->slotExpandOrCollapseAllThreads( false );
03237 }
03238
03239
03240 void KMMainWidget::slotShowMsgSrc()
03241 {
03242 if ( mMsgView )
03243 mMsgView->setUpdateAttachment( false );
03244 KMMessage *msg = mHeaders->currentMsg();
03245 if ( !msg )
03246 return;
03247 KMCommand *command = new KMShowMsgSrcCommand( this, msg,
03248 mMsgView
03249 ? mMsgView->isFixedFont()
03250 : false );
03251 command->start();
03252 }
03253
03254
03255
03256 void KMMainWidget::moveSelectedToFolder( int menuId )
03257 {
03258 if (mMenuToFolder[menuId])
03259 mHeaders->moveMsgToFolder( mMenuToFolder[menuId] );
03260 }
03261
03262
03263
03264 void KMMainWidget::copySelectedToFolder(int menuId )
03265 {
03266 if (mMenuToFolder[menuId])
03267 mHeaders->copyMsgToFolder( mMenuToFolder[menuId] );
03268 }
03269
03270
03271
03272 void KMMainWidget::updateMessageMenu()
03273 {
03274 mMenuToFolder.clear();
03275 folderTree()->folderToPopupMenu( KMFolderTree::MoveMessage, this,
03276 &mMenuToFolder, mMoveActionMenu->popupMenu() );
03277 folderTree()->folderToPopupMenu( KMFolderTree::CopyMessage, this,
03278 &mMenuToFolder, mCopyActionMenu->popupMenu() );
03279 updateMessageActions();
03280 }
03281
03282 void KMMainWidget::startUpdateMessageActionsTimer()
03283 {
03284 menutimer->stop();
03285 menutimer->start( 20, true );
03286 }
03287
03288 void KMMainWidget::updateMessageActions()
03289 {
03290 int count = 0;
03291 QPtrList<QListViewItem> selectedItems;
03292
03293 if ( mFolder ) {
03294 for (QListViewItem *item = mHeaders->firstChild(); item; item = item->itemBelow())
03295 if (item->isSelected() )
03296 selectedItems.append(item);
03297 if ( selectedItems.isEmpty() && mFolder->count() )
03298 count = 1;
03299 else
03300 count = selectedItems.count();
03301 mMsgActions->setCurrentMessage( mHeaders->currentMsg() );
03302 mMsgActions->setSelectedSernums( mHeaders->selectedSernums() );
03303 mMsgActions->setSelectedVisibleSernums( mHeaders->selectedVisibleSernums() );
03304 } else {
03305 mMsgActions->setCurrentMessage( 0 );
03306 }
03307
03308 updateListFilterAction();
03309
03310 bool allSelectedInCommonThread = false;
03311 if ( mHeaders->isThreaded() && count > 1 ) {
03312 allSelectedInCommonThread = true;
03313 for ( QPtrListIterator<QListViewItem> it( selectedItems ) ;
03314 it.current() ; ++ it ) {
03315 QListViewItem * item = *it;
03316 if ( item->parent()==0 && item->childCount()==0 ) {
03317 allSelectedInCommonThread = false;
03318 break;
03319 }
03320 }
03321 }
03322 else if ( mHeaders->isThreaded() && count == 1 ) {
03323 allSelectedInCommonThread = true;
03324 }
03325
03326 QListViewItem *curItemParent = mHeaders->currentItem();
03327 bool parent_thread = 0;
03328 if ( curItemParent && curItemParent->firstChild() != 0 ) parent_thread = 1;
03329
03330 bool mass_actions = count >= 1;
03331 bool thread_actions = mass_actions && allSelectedInCommonThread &&
03332 mHeaders->isThreaded();
03333 bool flags_available = GlobalSettings::self()->allowLocalFlags() || !(mFolder ? mFolder->isReadOnly() : true);
03334 mThreadStatusMenu->setEnabled( thread_actions );
03335
03336
03337 mWatchThreadAction->setEnabled( thread_actions && flags_available );
03338 mIgnoreThreadAction->setEnabled( thread_actions && flags_available );
03339 mMarkThreadAsNewAction->setEnabled( thread_actions );
03340 mMarkThreadAsReadAction->setEnabled( thread_actions );
03341 mMarkThreadAsUnreadAction->setEnabled( thread_actions );
03342 mToggleThreadTodoAction->setEnabled( thread_actions && flags_available );
03343 mToggleThreadFlagAction->setEnabled( thread_actions && flags_available );
03344 mTrashThreadAction->setEnabled( thread_actions && mFolder->canDeleteMessages() );
03345 mDeleteThreadAction->setEnabled( thread_actions && mFolder->canDeleteMessages() );
03346
03347 if (mFolder && mHeaders && mHeaders->currentMsg()) {
03348 if (thread_actions) {
03349 mToggleThreadTodoAction->setChecked(mHeaders->currentMsg()->isTodo());
03350 mToggleThreadFlagAction->setChecked(mHeaders->currentMsg()->isImportant());
03351 mWatchThreadAction->setChecked( mHeaders->currentMsg()->isWatched());
03352 mIgnoreThreadAction->setChecked( mHeaders->currentMsg()->isIgnored());
03353 }
03354 }
03355
03356 mMoveActionMenu->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03357 mMoveMsgToFolderAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03358 mCopyActionMenu->setEnabled( mass_actions );
03359 mTrashAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03360 mDeleteAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03361 mFindInMessageAction->setEnabled( mass_actions );
03362 mForwardInlineAction->setEnabled( mass_actions );
03363 mForwardAttachedAction->setEnabled( mass_actions );
03364 mForwardDigestAction->setEnabled( count > 1 || parent_thread );
03365
03366 forwardMenu()->setEnabled( mass_actions );
03367
03368 bool single_actions = count == 1;
03369 mUseAction->setEnabled( single_actions &&
03370 kmkernel->folderIsTemplates( mFolder ) );
03371 filterMenu()->setEnabled( single_actions );
03372 redirectAction()->setEnabled( single_actions );
03373 printAction()->setEnabled( single_actions );
03374 viewSourceAction()->setEnabled( single_actions );
03375
03376 mSendAgainAction->setEnabled( single_actions
03377 && ( mHeaders->currentMsg() && mHeaders->currentMsg()->isSent() )
03378 || ( mFolder && mHeaders->currentMsg() &&
03379 kmkernel->folderIsSentMailFolder( mFolder ) ) );
03380 mSaveAsAction->setEnabled( mass_actions );
03381 bool mails = mFolder && mFolder->count();
03382 bool enable_goto_unread = mails
03383 || (GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders);
03384 actionCollection()->action( "go_next_message" )->setEnabled( mails );
03385 actionCollection()->action( "go_next_unread_message" )->setEnabled( enable_goto_unread );
03386 actionCollection()->action( "go_prev_message" )->setEnabled( mails );
03387 actionCollection()->action( "go_prev_unread_message" )->setEnabled( enable_goto_unread );
03388 actionCollection()->action( "send_queued" )->setEnabled( kmkernel->outboxFolder()->count() > 0 );
03389 actionCollection()->action( "send_queued_via" )->setEnabled( kmkernel->outboxFolder()->count() > 0 );
03390 slotUpdateOnlineStatus( static_cast<GlobalSettingsBase::EnumNetworkState::type>( GlobalSettings::self()->networkState() ) );
03391 if (action( "edit_undo" ))
03392 action( "edit_undo" )->setEnabled( mHeaders->canUndo() );
03393
03394 if ( count == 1 ) {
03395 KMMessage *msg;
03396 int aIdx;
03397 if((aIdx = mHeaders->currentItemIndex()) <= -1)
03398 return;
03399 if(!(msg = mFolder->getMsg(aIdx)))
03400 return;
03401
03402 if ((KMFolder*)mFolder == kmkernel->outboxFolder())
03403 editAction()->setEnabled( !msg->transferInProgress() );
03404 }
03405
03406 mApplyAllFiltersAction->setEnabled(count);
03407 mApplyFilterActionsMenu->setEnabled(count);
03408 }
03409
03410
03411 void KMMainWidget::updateMarkAsReadAction()
03412 {
03413 mMarkAllAsReadAction->setEnabled( mFolder && (mFolder->countUnread() > 0) );
03414 }
03415
03416
03417 void KMMainWidget::updateFolderMenu()
03418 {
03419 bool folderWithContent = mFolder && !mFolder->noContent();
03420 bool multiFolder = folderTree()->selectedFolders().count() > 1;
03421 mModifyFolderAction->setEnabled( folderWithContent && !multiFolder );
03422 mFolderMailingListPropertiesAction->setEnabled( folderWithContent && !multiFolder );
03423 mCompactFolderAction->setEnabled( folderWithContent && !multiFolder );
03424
03425
03426 bool imap = mFolder && mFolder->folderType() == KMFolderTypeImap;
03427 bool cachedImap = mFolder && mFolder->folderType() == KMFolderTypeCachedImap;
03428
03429 bool knownImapPath = cachedImap && !static_cast<KMFolderCachedImap*>( mFolder->storage() )->imapPath().isEmpty();
03430 mRefreshFolderAction->setEnabled( folderWithContent && ( imap
03431 || ( cachedImap && knownImapPath ) ) && !multiFolder );
03432 if ( mTroubleshootFolderAction )
03433 mTroubleshootFolderAction->setEnabled( folderWithContent && ( cachedImap && knownImapPath ) && !multiFolder );
03434 mEmptyFolderAction->setEnabled( folderWithContent && ( mFolder->count() > 0 ) && mFolder->canDeleteMessages() && !multiFolder );
03435 mEmptyFolderAction->setText( (mFolder && kmkernel->folderIsTrash(mFolder))
03436 ? i18n("E&mpty Trash") : i18n("&Move All Messages to Trash") );
03437 mRemoveFolderAction->setEnabled( mFolder && !mFolder->isSystemFolder() && mFolder->canDeleteMessages() && !multiFolder);
03438 mRemoveFolderAction->setText( mFolder && mFolder->folderType() == KMFolderTypeSearch
03439 ? i18n("&Delete Search") : i18n("&Delete Folder") );
03440 mExpireFolderAction->setEnabled( mFolder && mFolder->isAutoExpire() && !multiFolder && mFolder->canDeleteMessages() );
03441 updateMarkAsReadAction();
03442
03443 mPreferHtmlAction->setEnabled( mHeaders->folder() ? true : false );
03444 mPreferHtmlLoadExtAction->setEnabled( mHeaders->folder() && (mHtmlPref ? !mFolderHtmlPref : mFolderHtmlPref) ? true : false );
03445 mThreadMessagesAction->setEnabled( mHeaders->folder() ? true : false );
03446
03447 mPreferHtmlAction->setChecked( mHtmlPref ? !mFolderHtmlPref : mFolderHtmlPref );
03448 mPreferHtmlLoadExtAction->setChecked( mHtmlLoadExtPref ? !mFolderHtmlLoadExtPref : mFolderHtmlLoadExtPref );
03449 mThreadMessagesAction->setChecked(
03450 mThreadPref ? !mFolderThreadPref : mFolderThreadPref );
03451 mThreadBySubjectAction->setEnabled(
03452 mHeaders->folder() ? ( mThreadMessagesAction->isChecked()) : false );
03453 mThreadBySubjectAction->setChecked( mFolderThreadSubjPref );
03454
03455 mNewFolderAction->setEnabled( !multiFolder );
03456 mRemoveDuplicatesAction->setEnabled( !multiFolder && mFolder && mFolder->canDeleteMessages() );
03457 mFolderShortCutCommandAction->setEnabled( !multiFolder );
03458 }
03459
03460
03461 #ifdef MALLOC_DEBUG
03462 static QString fmt(long n) {
03463 char buf[32];
03464
03465 if(n > 1024*1024*1024)
03466 sprintf(buf, "%0.2f GB", ((double)n)/1024.0/1024.0/1024.0);
03467 else if(n > 1024*1024)
03468 sprintf(buf, "%0.2f MB", ((double)n)/1024.0/1024.0);
03469 else if(n > 1024)
03470 sprintf(buf, "%0.2f KB", ((double)n)/1024.0);
03471 else
03472 sprintf(buf, "%ld Byte", n);
03473 return QString(buf);
03474 }
03475 #endif
03476
03477 void KMMainWidget::slotMemInfo() {
03478 #ifdef MALLOC_DEBUG
03479 struct mallinfo mi;
03480
03481 mi = mallinfo();
03482 QString s = QString("\nMALLOC - Info\n\n"
03483 "Number of mmapped regions : %1\n"
03484 "Memory allocated in use : %2\n"
03485 "Memory allocated, not used: %3\n"
03486 "Memory total allocated : %4\n"
03487 "Max. freeable memory : %5\n")
03488 .arg(mi.hblks).arg(fmt(mi.uordblks)).arg(fmt(mi.fordblks))
03489 .arg(fmt(mi.arena)).arg(fmt(mi.keepcost));
03490 KMessageBox::information(0, s, "Malloc information", s);
03491 #endif
03492 }
03493
03494
03495
03496 void KMMainWidget::slotIntro()
03497 {
03498 if ( !mMsgView ) return;
03499
03500 mMsgView->clear( true );
03501
03502 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
03503 mSearchAndHeaders->hide();
03504
03505
03506 mMsgView->displayAboutPage();
03507
03508 mFolder = 0;
03509 }
03510
03511 void KMMainWidget::slotShowStartupFolder()
03512 {
03513 if ( mFolderTree ) {
03514 mFolderTree->reload();
03515 mFolderTree->readConfig();
03516
03517 mFolderTree->cleanupConfigFile();
03518 }
03519
03520 connect( kmkernel->filterMgr(), SIGNAL( filterListUpdated() ),
03521 this, SLOT( initializeFilterActions() ));
03522
03523
03524 initializeFilterActions();
03525
03526
03527 initializeFolderShortcutActions();
03528
03529 QString newFeaturesMD5 = KMReaderWin::newFeaturesMD5();
03530 if ( kmkernel->firstStart() ||
03531 GlobalSettings::self()->previousNewFeaturesMD5() != newFeaturesMD5 ) {
03532 GlobalSettings::self()->setPreviousNewFeaturesMD5( newFeaturesMD5 );
03533 slotIntro();
03534 return;
03535 }
03536
03537 KMFolder* startup = 0;
03538 if ( !mStartupFolder.isEmpty() ) {
03539
03540 startup = kmkernel->findFolderById( mStartupFolder );
03541 }
03542 if ( !startup )
03543 startup = kmkernel->inboxFolder();
03544
03545 if ( mFolderTree ) {
03546 mFolderTree->showFolder( startup );
03547 }
03548 }
03549
03550 void KMMainWidget::slotShowTip()
03551 {
03552 KTipDialog::showTip( this, QString::null, true );
03553 }
03554
03555
03556 void KMMainWidget::slotChangeCaption(QListViewItem * i)
03557 {
03558 if ( !i ) return;
03559
03560 QStringList names;
03561 for ( QListViewItem * item = i ; item ; item = item->parent() )
03562 names.prepend( item->text(0) );
03563 emit captionChangeRequest( names.join( "/" ) );
03564 }
03565
03566
03567 void KMMainWidget::removeDuplicates()
03568 {
03569 if (!mFolder)
03570 return;
03571 KMFolder *oFolder = mFolder;
03572 mHeaders->setFolder(0);
03573 QMap< QString, QValueList<int> > idMD5s;
03574 QValueList<int> redundantIds;
03575 QValueList<int>::Iterator kt;
03576 mFolder->open("removedups");
03577 for (int i = mFolder->count() - 1; i >= 0; --i) {
03578 QString id = (*mFolder)[i]->msgIdMD5();
03579 if ( !id.isEmpty() ) {
03580 QString subjMD5 = (*mFolder)[i]->strippedSubjectMD5();
03581 int other = -1;
03582 if ( idMD5s.contains(id) )
03583 other = idMD5s[id].first();
03584 else
03585 idMD5s[id].append( i );
03586 if ( other != -1 ) {
03587 QString otherSubjMD5 = (*mFolder)[other]->strippedSubjectMD5();
03588 if (otherSubjMD5 == subjMD5)
03589 idMD5s[id].append( i );
03590 }
03591 }
03592 }
03593 QMap< QString, QValueList<int> >::Iterator it;
03594 for ( it = idMD5s.begin(); it != idMD5s.end() ; ++it ) {
03595 QValueList<int>::Iterator jt;
03596 bool finished = false;
03597 for ( jt = (*it).begin(); jt != (*it).end() && !finished; ++jt )
03598 if (!((*mFolder)[*jt]->isUnread())) {
03599 (*it).remove( jt );
03600 (*it).prepend( *jt );
03601 finished = true;
03602 }
03603 for ( jt = (*it).begin(), ++jt; jt != (*it).end(); ++jt )
03604 redundantIds.append( *jt );
03605 }
03606 qHeapSort( redundantIds );
03607 kt = redundantIds.end();
03608 int numDuplicates = 0;
03609 if (kt != redundantIds.begin()) do {
03610 mFolder->removeMsg( *(--kt) );
03611 ++numDuplicates;
03612 }
03613 while (kt != redundantIds.begin());
03614
03615 mFolder->close("removedups");
03616 mHeaders->setFolder(oFolder);
03617 QString msg;
03618 if ( numDuplicates )
03619 msg = i18n("Removed %n duplicate message.",
03620 "Removed %n duplicate messages.", numDuplicates );
03621 else
03622 msg = i18n("No duplicate messages found.");
03623 BroadcastStatus::instance()->setStatusMsg( msg );
03624 }
03625
03626
03627
03628 void KMMainWidget::slotUpdateUndo()
03629 {
03630 if (actionCollection()->action( "edit_undo" ))
03631 actionCollection()->action( "edit_undo" )->setEnabled( mHeaders->canUndo() );
03632 }
03633
03634
03635
03636 void KMMainWidget::clearFilterActions()
03637 {
03638 if ( !mFilterTBarActions.isEmpty() ) {
03639 if ( mGUIClient->factory() )
03640 mGUIClient->unplugActionList( "toolbar_filter_actions" );
03641 mFilterTBarActions.clear();
03642 }
03643 mApplyFilterActionsMenu->popupMenu()->clear();
03644 if ( !mFilterMenuActions.isEmpty() ) {
03645 if ( mGUIClient->factory() )
03646 mGUIClient->unplugActionList( "menu_filter_actions" );
03647 mFilterMenuActions.clear();
03648 }
03649 mFilterCommands.clear();
03650 }
03651
03652
03653 void KMMainWidget::initializeFolderShortcutActions()
03654 {
03655
03656
03657
03658
03659 bool old = actionCollection()->isAutoConnectShortcuts();
03660
03661 actionCollection()->setAutoConnectShortcuts( true );
03662 QValueList< QGuardedPtr< KMFolder > > folders = kmkernel->allFolders();
03663 QValueList< QGuardedPtr< KMFolder > >::Iterator it = folders.begin();
03664 while ( it != folders.end() ) {
03665 KMFolder *folder = (*it);
03666 ++it;
03667 slotShortcutChanged( folder );
03668 }
03669 actionCollection()->setAutoConnectShortcuts( old );
03670 }
03671
03672
03673
03674 void KMMainWidget::initializeFilterActions()
03675 {
03676 QString filterName, normalizedName;
03677 KMMetaFilterActionCommand *filterCommand;
03678 KAction *filterAction = 0;
03679
03680 clearFilterActions();
03681 mApplyAllFiltersAction->plug(mApplyFilterActionsMenu->popupMenu());
03682 bool addedSeparator = false;
03683 QValueListConstIterator<KMFilter*> it = kmkernel->filterMgr()->filters().constBegin();
03684 for ( ;it != kmkernel->filterMgr()->filters().constEnd(); ++it ) {
03685 if (!(*it)->isEmpty() && (*it)->configureShortcut()) {
03686 filterName = QString("Filter %1").arg((*it)->name());
03687 normalizedName = filterName.replace(" ", "_");
03688 if (action(normalizedName.utf8()))
03689 continue;
03690 filterCommand = new KMMetaFilterActionCommand(*it, mHeaders, this);
03691 mFilterCommands.append(filterCommand);
03692 QString as = i18n("Filter %1").arg((*it)->name());
03693 QString icon = (*it)->icon();
03694 if ( icon.isEmpty() )
03695 icon = "gear";
03696 filterAction = new KAction(as, icon, (*it)->shortcut(), filterCommand,
03697 SLOT(start()), actionCollection(),
03698 normalizedName.local8Bit());
03699 if(!addedSeparator) {
03700 mApplyFilterActionsMenu->popupMenu()->insertSeparator();
03701 addedSeparator = !addedSeparator;
03702 mFilterMenuActions.append( new KActionSeparator());
03703 }
03704 filterAction->plug( mApplyFilterActionsMenu->popupMenu() );
03705 mFilterMenuActions.append(filterAction);
03706 if ( (*it)->configureToolbar() )
03707 mFilterTBarActions.append(filterAction);
03708 }
03709 }
03710 if ( !mFilterMenuActions.isEmpty() && mGUIClient->factory() )
03711 mGUIClient->plugActionList( "menu_filter_actions", mFilterMenuActions );
03712 if ( !mFilterTBarActions.isEmpty() && mGUIClient->factory() ) {
03713 mFilterTBarActions.prepend( mToolbarActionSeparator );
03714 mGUIClient->plugActionList( "toolbar_filter_actions", mFilterTBarActions );
03715 }
03716 }
03717
03718 void KMMainWidget::slotFolderRemoved( KMFolder *folder )
03719 {
03720 mFolderShortcutCommands.remove( folder->idString() );
03721 }
03722
03723
03724 void KMMainWidget::initializeIMAPActions( bool setState )
03725 {
03726 bool hasImapAccount = false;
03727 for( KMAccount *a = kmkernel->acctMgr()->first(); a;
03728 a = kmkernel->acctMgr()->next() ) {
03729 if ( a->type() == "cachedimap" ) {
03730 hasImapAccount = true;
03731 break;
03732 }
03733 }
03734 if ( hasImapAccount == ( mTroubleshootFolderAction != 0 ) )
03735 return;
03736
03737 KXMLGUIFactory* factory = mGUIClient->factory();
03738 if ( factory )
03739 factory->removeClient( mGUIClient );
03740
03741 if ( !mTroubleshootFolderAction ) {
03742 mTroubleshootFolderAction = new KAction( i18n("&Troubleshoot IMAP Cache..."), "wizard", 0,
03743 this, SLOT(slotTroubleshootFolder()), actionCollection(), "troubleshoot_folder" );
03744 if ( setState )
03745 updateFolderMenu();
03746 } else {
03747 delete mTroubleshootFolderAction ;
03748 mTroubleshootFolderAction = 0;
03749 }
03750
03751 if ( factory )
03752 factory->addClient( mGUIClient );
03753 }
03754
03755 bool KMMainWidget::shortcutIsValid( const KShortcut &sc ) const
03756 {
03757 KActionPtrList actions = actionCollection()->actions();
03758 KActionPtrList::Iterator it( actions.begin() );
03759 for ( ; it != actions.end(); it++ ) {
03760 if ( (*it)->shortcut() == sc ) return false;
03761 }
03762 return true;
03763 }
03764
03765 void KMMainWidget::slotShortcutChanged( KMFolder *folder )
03766 {
03767
03768 mFolderShortcutCommands.remove( folder->idString() );
03769 if ( folder->shortcut().isNull() )
03770 return;
03771
03772 FolderShortcutCommand *c = new FolderShortcutCommand( this, folder );
03773 mFolderShortcutCommands.insert( folder->idString(), c );
03774
03775 QString actionlabel = QString( "FolderShortcut %1").arg( folder->prettyURL() );
03776 QString actionname = QString( "FolderShortcut %1").arg( folder->idString() );
03777 QString normalizedName = actionname.replace(" ", "_");
03778 KAction* action =
03779 new KAction(actionlabel, folder->shortcut(), c, SLOT(start()),
03780 actionCollection(), normalizedName.local8Bit());
03781 action->setIcon( folder->unreadIconPath() );
03782 c->setAction( action );
03783 }
03784
03785
03786 QString KMMainWidget::findCurrentImapPath()
03787 {
03788 QString startPath;
03789 if (!mFolder) return startPath;
03790 if (mFolder->folderType() == KMFolderTypeImap)
03791 {
03792 startPath = static_cast<KMFolderImap*>(mFolder->storage())->imapPath();
03793 } else if (mFolder->folderType() == KMFolderTypeCachedImap)
03794 {
03795 startPath = static_cast<KMFolderCachedImap*>(mFolder->storage())->imapPath();
03796 }
03797 return startPath;
03798 }
03799
03800
03801 ImapAccountBase* KMMainWidget::findCurrentImapAccountBase()
03802 {
03803 ImapAccountBase* account = 0;
03804 if (!mFolder) return account;
03805 if (mFolder->folderType() == KMFolderTypeImap)
03806 {
03807 account = static_cast<KMFolderImap*>(mFolder->storage())->account();
03808 } else if (mFolder->folderType() == KMFolderTypeCachedImap)
03809 {
03810 account = static_cast<KMFolderCachedImap*>(mFolder->storage())->account();
03811 }
03812 return account;
03813 }
03814
03815
03816 void KMMainWidget::slotSubscriptionDialog()
03817 {
03818 if ( !kmkernel->askToGoOnline() )
03819 return;
03820 ImapAccountBase* account = findCurrentImapAccountBase();
03821 if ( !account ) return;
03822 const QString startPath = findCurrentImapPath();
03823
03824
03825 SubscriptionDialog * dialog =
03826 new SubscriptionDialog(this, i18n("Subscription"), account, startPath);
03827 if ( dialog->exec() ) {
03828
03829 if (mFolder->folderType() == KMFolderTypeImap)
03830 static_cast<KMFolderImap*>(mFolder->storage())->account()->listDirectory();
03831 }
03832 }
03833
03834
03835 void KMMainWidget::slotLocalSubscriptionDialog()
03836 {
03837 ImapAccountBase* account = findCurrentImapAccountBase();
03838 if ( !account ) return;
03839
03840 const QString startPath = findCurrentImapPath();
03841
03842 LocalSubscriptionDialog *dialog =
03843 new LocalSubscriptionDialog(this, i18n("Local Subscription"), account, startPath);
03844 if ( dialog->exec() ) {
03845
03846 if (mFolder->folderType() == KMFolderTypeImap)
03847 static_cast<KMFolderImap*>(mFolder->storage())->account()->listDirectory();
03848 }
03849 }
03850
03851
03852 void KMMainWidget::slotFolderTreeColumnsChanged()
03853 {
03854 mTotalColumnToggle->setChecked( mFolderTree->isTotalActive() );
03855 mUnreadColumnToggle->setChecked( mFolderTree->isUnreadActive() );
03856 mSizeColumnToggle->setChecked( mFolderTree->isSizeActive() );
03857 }
03858
03859 void KMMainWidget::toggleSystemTray()
03860 {
03861 if ( !mSystemTray && GlobalSettings::self()->systemTrayEnabled() ) {
03862 mSystemTray = new KMSystemTray();
03863 }
03864 else if ( mSystemTray && !GlobalSettings::self()->systemTrayEnabled() ) {
03865
03866 kdDebug(5006) << "deleting systray" << endl;
03867 delete mSystemTray;
03868 mSystemTray = 0;
03869 }
03870
03871
03872 if ( mSystemTray )
03873 mSystemTray->setMode( GlobalSettings::self()->systemTrayPolicy() );
03874 }
03875
03876
03877 void KMMainWidget::slotAntiSpamWizard()
03878 {
03879 AntiSpamWizard wiz( AntiSpamWizard::AntiSpam, this, folderTree() );
03880 wiz.exec();
03881 }
03882
03883
03884 void KMMainWidget::slotAntiVirusWizard()
03885 {
03886 AntiSpamWizard wiz( AntiSpamWizard::AntiVirus, this, folderTree() );
03887 wiz.exec();
03888 }
03889
03890
03891 void KMMainWidget::slotFilterLogViewer()
03892 {
03893 FilterLogDialog * dlg = new FilterLogDialog( 0 );
03894 dlg->show();
03895 }
03896
03897
03898 void KMMainWidget::updateFileMenu()
03899 {
03900 QStringList actList = kmkernel->acctMgr()->getAccounts();
03901
03902 actionCollection()->action("check_mail")->setEnabled( actList.size() > 0 );
03903 actionCollection()->action("check_mail_in")->setEnabled( actList.size() > 0 );
03904 }
03905
03906
03907
03908 void KMMainWidget::setAccelsEnabled( bool enabled )
03909 {
03910 actionCollection()->kaccel()->setEnabled( enabled );
03911 }
03912
03913
03914
03915 KMSystemTray *KMMainWidget::systray() const
03916 {
03917 return mSystemTray;
03918 }
03919
03920
03921 QString KMMainWidget::overrideEncoding() const
03922 {
03923 if ( mMsgView )
03924 return mMsgView->overrideEncoding();
03925 else
03926 return GlobalSettings::self()->overrideCharacterEncoding();
03927 }
03928
03929 void KMMainWidget::slotCreateTodo()
03930 {
03931 KMMessage *msg = mHeaders->currentMsg();
03932 if ( !msg )
03933 return;
03934 KMCommand *command = new CreateTodoCommand( this, msg );
03935 command->start();
03936 }
03937
03938 void KMMainWidget::setupFolderView()
03939 {
03940 if ( GlobalSettings::self()->enableFavoriteFolderView() ) {
03941 mFolderView = mFolderViewSplitter;
03942 mFolderTree->reparent( mFolderViewSplitter, 0, QPoint( 0, 0 ) );
03943 mFolderViewSplitter->show();
03944 mFavoriteFolderView->show();
03945 } else {
03946 mFolderView = mFolderTree;
03947 mFolderViewSplitter->hide();
03948 mFavoriteFolderView->hide();
03949 }
03950 mFolderView->reparent( mFolderViewParent, 0, QPoint( 0, 0 ) );
03951 mFolderViewParent->moveToFirst( mFolderView );
03952 mFolderTree->show();
03953 }
03954
03955
03956 void KMMainWidget::slotRequestFullSearchFromQuickSearch()
03957 {
03958 slotSearch();
03959 #ifdef HAVE_INDEXLIB
03960 return;
03961 #endif
03962 assert( mSearchWin );
03963 KMSearchPattern pattern;
03964 pattern.append( KMSearchRule::createInstance( "<message>", KMSearchRule::FuncContains, mQuickSearchLine->currentSearchTerm() ) );
03965 int status = mQuickSearchLine->currentStatus();
03966 if ( status != 0 ) {
03967 pattern.append( new KMSearchRuleStatus( status ) );
03968 }
03969 mSearchWin->setSearchPattern( pattern );
03970 }
03971
03972 void KMMainWidget::updateVactionScriptStatus(bool active)
03973 {
03974 mVacationIndicatorActive = active;
03975 if ( active ) {
03976 mVacationScriptIndicator->setText( i18n("Out of office reply active") );
03977 mVacationScriptIndicator->setPaletteBackgroundColor( Qt::yellow );
03978 mVacationScriptIndicator->setCursor( QCursor( Qt::PointingHandCursor ) );
03979 mVacationScriptIndicator->show();
03980 } else {
03981 mVacationScriptIndicator->hide();
03982 }
03983 }
03984