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