15 #undef Unsorted // X headers...
20 #include <tqpopupmenu.h>
21 #include <tqptrlist.h>
22 #include <tqsignalmapper.h>
23 #include <tqvaluevector.h>
24 #include <tqstylesheet.h>
26 #include <kopenwith.h>
27 #include <tdemessagebox.h>
28 #include <tdepopupmenu.h>
29 #include <tdeaccelmanager.h>
30 #include <tdeglobalsettings.h>
31 #include <tdestdaccel.h>
32 #include <kkeydialog.h>
33 #include <kcharsets.h>
34 #include <knotifyclient.h>
36 #include <tdeapplication.h>
37 #include <tdefiledialog.h>
39 #include <knotifydialog.h>
40 #include <kstandarddirs.h>
41 #include <dcopclient.h>
42 #include <kaddrbook.h>
44 #include <kstringhandler.h>
46 #include "globalsettings.h"
47 #include "kcursorsaver.h"
48 #include "broadcaststatus.h"
49 using KPIM::BroadcastStatus;
50 #include "kmfoldermgr.h"
51 #include "kmfolderdia.h"
52 #include "accountmanager.h"
55 #include "kmfoldertree.h"
56 #include "kmreadermainwin.h"
57 #include "kmfoldercachedimap.h"
58 #include "kmfolderimap.h"
59 #include "kmacctcachedimap.h"
61 #include "kmfolderseldlg.h"
62 #include "kmfiltermgr.h"
63 #include "messagesender.h"
64 #include "kmaddrbook.h"
65 #include "kmversion.h"
66 #include "searchwindow.h"
68 #include "kmacctfolder.h"
69 #include "undostack.h"
70 #include "kmcommands.h"
71 #include "kmmainwin.h"
72 #include "kmsystemtray.h"
73 #include "imapaccountbase.h"
74 #include "transportmanager.h"
75 using KMail::ImapAccountBase;
77 using KMail::Vacation;
78 #include "favoritefolderview.h"
79 #include "subscriptiondialog.h"
80 using KMail::SubscriptionDialog;
81 #include "localsubscriptiondialog.h"
82 using KMail::LocalSubscriptionDialog;
83 #include "attachmentstrategy.h"
84 using KMail::AttachmentStrategy;
85 #include "headerstrategy.h"
86 using KMail::HeaderStrategy;
87 #include "headerstyle.h"
89 #include "folderjob.h"
90 using KMail::FolderJob;
91 #include "mailinglist-magic.h"
92 #include "antispamwizard.h"
94 #include "filterlogdlg.h"
96 #include <headerlistquicksearch.h>
97 #include "tdelistviewindexedsearchline.h"
98 using KMail::HeaderListQuickSearch;
99 #include "kmheaders.h"
100 #include "mailinglistpropertiesdialog.h"
101 #include "templateparser.h"
102 #include "archivefolderdialog.h"
103 #include "folderutil.h"
104 #include "csshelper.h"
107 #include "sievedebugdialog.h"
111 #include <libkpimidentities/identity.h>
112 #include <libkpimidentities/identitymanager.h>
115 #include <kstatusbar.h>
116 #include <kstaticdeleter.h>
117 #include <tdeaction.h>
119 #include <kmime_mdn.h>
120 #include <kmime_header_parsing.h>
121 using namespace KMime;
122 using KMime::Types::AddrSpecList;
124 #include "progressmanager.h"
125 using KPIM::ProgressManager;
127 #include "managesievescriptsdialog.h"
129 #include "customtemplates.h"
130 #include "customtemplates_kfg.h"
132 #include "kmmainwidget.moc"
134 TQValueList<KMMainWidget*>* KMMainWidget::s_mainWidgetList = 0;
135 static KStaticDeleter<TQValueList<KMMainWidget*> > mwlsd;
138 KMMainWidget::KMMainWidget(TQWidget *parent,
const char *name,
139 KXMLGUIClient *aGUIClient,
140 TDEActionCollection *actionCollection, TDEConfig* config ) :
141 TQWidget(parent, name),
142 mFavoritesCheckMailAction( 0 ),
143 mFavoriteFolderView( 0 ),
145 mFolderViewParent( 0 ),
146 mFolderViewSplitter( 0 ),
147 mQuickSearchLine( 0 ),
148 mArchiveFolderAction( 0 ),
149 mShowBusySplashTimer( 0 ),
150 mShowingOfflineScreen( false ),
152 mVacationIndicatorActive( false )
155 mStartupDone =
false;
160 mFolderThreadPref =
false;
161 mFolderThreadSubjPref =
true;
162 mReaderWindowActive =
true;
163 mReaderWindowBelow =
true;
164 mFolderHtmlPref =
false;
165 mFolderHtmlLoadExtPref =
false;
168 mActionCollection = actionCollection;
169 mTopLayout =
new TQVBoxLayout(
this);
170 mFilterMenuActions.setAutoDelete(
true);
171 mFilterTBarActions.setAutoDelete(
false);
172 mFilterCommands.setAutoDelete(
true);
173 mFolderShortcutCommands.setAutoDelete(
true);
176 mGUIClient = aGUIClient;
178 mCustomReplyActionMenu = 0;
179 mCustomReplyAllActionMenu = 0;
180 mCustomForwardActionMenu = 0;
181 mCustomReplyMapper = 0;
182 mCustomReplyAllMapper = 0;
183 mCustomForwardMapper = 0;
187 mToolbarActionSeparator =
new TDEActionSeparator( actionCollection );
189 if( !s_mainWidgetList )
190 mwlsd.setObject( s_mainWidgetList,
new TQValueList<KMMainWidget*>() );
191 s_mainWidgetList->append(
this );
193 mPanner1Sep << 1 << 1;
194 mPanner2Sep << 1 << 1;
196 setMinimumSize(400, 300);
207 TQTimer::singleShot( 0, TQT_TQOBJECT(
this), TQT_SLOT( slotShowStartupFolder() ));
209 connect( kmkernel->acctMgr(), TQT_SIGNAL( checkedMail(
bool,
bool,
const TQMap<TQString, int> & ) ),
210 this, TQT_SLOT( slotMailChecked(
bool,
bool,
const TQMap<TQString, int> & ) ) );
212 connect( kmkernel->acctMgr(), TQT_SIGNAL( accountAdded( KMAccount* ) ),
213 this, TQT_SLOT( initializeIMAPActions() ) );
214 connect( kmkernel->acctMgr(), TQT_SIGNAL( accountRemoved( KMAccount* ) ),
215 this, TQT_SLOT( initializeIMAPActions() ) );
217 connect(kmkernel, TQT_SIGNAL( configChanged() ),
218 this, TQT_SLOT( slotConfigChanged() ));
221 connect(mFolderTree, TQT_SIGNAL(currentChanged(TQListViewItem*)),
222 this, TQT_SLOT(slotChangeCaption(TQListViewItem*)));
223 connect(mFolderTree, TQT_SIGNAL(selectionChanged()),
224 TQT_SLOT(updateFolderMenu()) );
225 connect( mFolderTree, TQT_SIGNAL(syncStateChanged()),
226 TQT_SLOT(updateFolderMenu()) );
228 connect(kmkernel->folderMgr(), TQT_SIGNAL(folderRemoved(
KMFolder*)),
229 this, TQT_SLOT(slotFolderRemoved(
KMFolder*)));
231 connect(kmkernel->imapFolderMgr(), TQT_SIGNAL(folderRemoved(
KMFolder*)),
232 this, TQT_SLOT(slotFolderRemoved(
KMFolder*)));
234 connect(kmkernel->dimapFolderMgr(), TQT_SIGNAL(folderRemoved(
KMFolder*)),
235 this, TQT_SLOT(slotFolderRemoved(
KMFolder*)));
237 connect(kmkernel->searchFolderMgr(), TQT_SIGNAL(folderRemoved(
KMFolder*)),
238 this, TQT_SLOT(slotFolderRemoved(
KMFolder*)));
240 connect( kmkernel, TQT_SIGNAL( onlineStatusChanged( GlobalSettings::EnumNetworkState::type ) ),
241 this, TQT_SLOT( slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type ) ) );
249 TDEMainWindow *
mainWin =
dynamic_cast<TDEMainWindow*
>(topLevelWidget());
250 KStatusBar *sb = mainWin ? mainWin->statusBar() : 0;
251 mVacationScriptIndicator =
new KStatusBarLabel( TQString(), 0, sb );
252 mVacationScriptIndicator->hide();
253 connect( mVacationScriptIndicator, TQT_SIGNAL(itemReleased(
int)), TQT_SLOT(slotEditVacation()) );
254 if ( GlobalSettings::checkOutOfOfficeOnStartup() )
255 TQTimer::singleShot( 0, TQT_TQOBJECT(
this), TQT_SLOT(slotCheckVacation()) );
262 KMMainWidget::~KMMainWidget()
264 s_mainWidgetList->remove(
this );
271 void KMMainWidget::destruct()
288 void KMMainWidget::readPreConfig(
void)
290 const TDEConfigGroup geometry( KMKernel::config(),
"Geometry" );
291 const TDEConfigGroup reader( KMKernel::config(),
"Reader" );
293 mLongFolderList = geometry.readEntry(
"FolderList",
"long" ) !=
"short";
294 mReaderWindowActive = geometry.readEntry(
"readerWindowMode",
"below" ) !=
"hide";
295 mReaderWindowBelow = geometry.readEntry(
"readerWindowMode",
"below" ) ==
"below";
296 mThreadPref = geometry.readBoolEntry(
"nestedMessages",
false );
298 mHtmlPref = reader.readBoolEntry(
"htmlMail",
false );
299 mHtmlLoadExtPref = reader.readBoolEntry(
"htmlLoadExternal",
false );
300 mEnableFavoriteFolderView = GlobalSettings::self()->enableFavoriteFolderView();
305 void KMMainWidget::readFolderConfig(
void)
310 TDEConfig *config = KMKernel::config();
311 TDEConfigGroupSaver saver(config,
"Folder-" + mFolder->idString());
312 mFolderThreadPref = config->readBoolEntry(
"threadMessagesOverride",
false );
313 mFolderThreadSubjPref = config->readBoolEntry(
"threadMessagesBySubject",
true );
314 mFolderHtmlPref = config->readBoolEntry(
"htmlMailOverride",
false );
315 mFolderHtmlLoadExtPref = config->readBoolEntry(
"htmlLoadExternalOverride",
false );
320 void KMMainWidget::writeFolderConfig(
void)
325 TDEConfig *config = KMKernel::config();
326 TDEConfigGroupSaver saver(config,
"Folder-" + mFolder->idString());
327 config->writeEntry(
"threadMessagesOverride", mFolderThreadPref );
328 config->writeEntry(
"threadMessagesBySubject", mFolderThreadSubjPref );
329 config->writeEntry(
"htmlMailOverride", mFolderHtmlPref );
330 config->writeEntry(
"htmlLoadExternalOverride", mFolderHtmlLoadExtPref );
335 void KMMainWidget::readConfig(
void)
337 TDEConfig *config = KMKernel::config();
339 bool oldLongFolderList = mLongFolderList;
340 bool oldReaderWindowActive = mReaderWindowActive;
341 bool oldReaderWindowBelow = mReaderWindowBelow;
342 bool oldFavoriteFolderView = mEnableFavoriteFolderView;
352 mHeaders->refreshNestedState();
354 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
355 || ( oldReaderWindowActive != mReaderWindowActive )
356 || ( oldReaderWindowBelow != mReaderWindowBelow )
357 || ( oldFavoriteFolderView != mEnableFavoriteFolderView );
360 if( layoutChanged ) {
370 TDEConfigGroupSaver saver(config,
"Geometry");
372 TQSize defaultSize(750,560);
373 siz = config->readSizeEntry(
"MainWin", &defaultSize);
377 static const int folderpanewidth = 250;
379 const int folderW = config->readNumEntry(
"FolderPaneWidth", folderpanewidth );
380 const int headerW = config->readNumEntry(
"HeaderPaneWidth", width()-folderpanewidth );
381 const int headerH = config->readNumEntry(
"HeaderPaneHeight", 180 );
382 const int readerH = config->readNumEntry(
"ReaderPaneHeight", 280 );
386 TQValueList<int> & widths = mLongFolderList ? mPanner1Sep : mPanner2Sep ;
387 TQValueList<int> & heights = mLongFolderList ? mPanner2Sep : mPanner1Sep ;
389 widths << folderW << headerW;
390 heights << headerH << readerH;
392 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
393 || ( oldReaderWindowActive != mReaderWindowActive )
394 || ( oldReaderWindowBelow != mReaderWindowBelow );
396 if (!mStartupDone || layoutChanged )
403 const int unreadColumn = config->readNumEntry(
"UnreadColumn", 1);
404 const int totalColumn = config->readNumEntry(
"TotalColumn", 2);
405 const int sizeColumn = config->readNumEntry(
"SizeColumn", 3);
411 if (unreadColumn == 1)
412 mFolderTree->addUnreadColumn( i18n(
"Unread"), 70 );
413 else if (totalColumn == 1)
414 mFolderTree->addTotalColumn( i18n(
"Total"), 70 );
415 else if (sizeColumn == 1)
416 mFolderTree->addSizeColumn( i18n(
"Size"), 70 );
418 if (unreadColumn == 2)
419 mFolderTree->addUnreadColumn( i18n(
"Unread"), 70 );
420 else if (totalColumn == 2)
421 mFolderTree->addTotalColumn( i18n(
"Total"), 70 );
422 else if (sizeColumn == 2)
423 mFolderTree->addSizeColumn( i18n(
"Size"), 70 );
425 if (unreadColumn == 3)
426 mFolderTree->addUnreadColumn( i18n(
"Unread"), 70 );
427 else if (totalColumn == 3)
428 mFolderTree->addTotalColumn( i18n(
"Total"), 70 );
429 else if (sizeColumn == 3)
430 mFolderTree->addSizeColumn( i18n(
"Size"), 70 );
432 mUnreadColumnToggle->setChecked( mFolderTree->isUnreadActive() );
433 mUnreadTextToggle->setChecked( !mFolderTree->isUnreadActive() );
434 mTotalColumnToggle->setChecked( mFolderTree->isTotalActive() );
435 mSizeColumnToggle->setChecked( mFolderTree->isSizeActive() );
437 mFolderTree->updatePopup();
442 mMsgView->readConfig();
444 mHeaders->readConfig();
445 mHeaders->restoreColumnLayout( KMKernel::config(),
"Header-Geometry" );
447 if ( mFolderViewSplitter && !GlobalSettings::self()->folderViewSplitterPosition().isEmpty() ) {
448 mFolderViewSplitter->setSizes( GlobalSettings::self()->folderViewSplitterPosition() );
450 TQValueList<int> defaults;
451 defaults << (int)(height() * 0.2) << (int)(height() * 0.8);
452 mFolderViewSplitter->setSizes( defaults );
455 mFolderTree->readConfig();
456 if ( mFavoriteFolderView )
457 mFavoriteFolderView->readConfig();
458 mFavoritesCheckMailAction->setEnabled( GlobalSettings::self()->enableFavoriteFolderView() );
461 TDEConfigGroupSaver saver(config,
"General");
462 mBeepOnNew = config->readBoolEntry(
"beep-on-mail",
false);
463 mConfirmEmpty = config->readBoolEntry(
"confirm-before-empty",
true);
465 mStartupFolder = config->readEntry(
"startupFolder", kmkernel->inboxFolder()->idString());
469 bool check = config->readBoolEntry(
"checkmail-startup",
false);
472 TQTimer::singleShot( 0, TQT_TQOBJECT(
this), TQT_SLOT( slotCheckMail() ) );
477 mFolderTree->reload();
485 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
486 || ( oldReaderWindowActive != mReaderWindowActive )
487 || ( oldReaderWindowBelow != mReaderWindowBelow )
488 || ( oldFavoriteFolderView != mEnableFavoriteFolderView );
489 if ( layoutChanged ) {
493 mFolderTree->showFolder( mFolder );
496 mHeaders->setFolder(mFolder);
498 int aIdx = mHeaders->currentItemIndex();
500 mMsgView->setMsg( mFolder->getMsg(aIdx), true );
502 mMsgView->clear(
true );
504 updateMessageActions();
515 void KMMainWidget::writeConfig(
void)
518 TDEConfig *config = KMKernel::config();
519 TDEConfigGroup geometry( config,
"Geometry" );
522 mMsgView->writeConfig();
524 if ( mFolderViewSplitter )
525 GlobalSettings::setFolderViewSplitterPosition( mFolderViewSplitter->sizes() );
526 mFolderTree->writeConfig();
527 if ( mFavoriteFolderView )
528 mFavoriteFolderView->writeConfig();
530 geometry.writeEntry(
"MainWin", this->geometry().size() );
532 const TQValueList<int> widths = ( mLongFolderList ? mPanner1 : mPanner2 )->sizes();
533 const TQValueList<int> heights = ( mLongFolderList ? mPanner2 : mPanner1 )->sizes();
535 geometry.writeEntry(
"FolderPaneWidth", widths[0] );
536 geometry.writeEntry(
"HeaderPaneWidth", widths[1] );
539 if ( mSearchAndHeaders && mSearchAndHeaders->isShown() ) {
540 geometry.writeEntry(
"HeaderPaneHeight", heights[0] );
541 geometry.writeEntry(
"ReaderPaneHeight", heights[1] );
545 geometry.writeEntry(
"UnreadColumn", mFolderTree->unreadIndex() );
546 geometry.writeEntry(
"TotalColumn", mFolderTree->totalIndex() );
547 geometry.writeEntry(
"SizeColumn", mFolderTree->sizeIndex() );
552 void KMMainWidget::createWidgets(
void)
555 TQWidget *headerParent = 0,
556 *mimeParent = 0, *messageParent = 0;
558 const bool opaqueResize = TDEGlobalSettings::opaqueResize();
559 if ( mLongFolderList ) {
562 mPanner1 =
new TQSplitter( Qt::Horizontal,
this,
"panner 1" );
563 mPanner1->setOpaqueResize( opaqueResize );
564 Qt::Orientation orientation = mReaderWindowBelow ? Qt::Vertical : Qt::Horizontal;
565 mPanner2 =
new TQSplitter( orientation, mPanner1,
"panner 2" );
566 mPanner2->setOpaqueResize( opaqueResize );
567 mPanner2->setChildrenCollapsible(
false );
568 mFolderViewParent = mPanner1;
569 headerParent = mimeParent = messageParent = mPanner2;
573 mPanner1 =
new TQSplitter( Qt::Vertical,
this,
"panner 1" );
574 mPanner1->setOpaqueResize( opaqueResize );
575 mPanner1->setChildrenCollapsible(
false );
576 mPanner2 =
new TQSplitter( Qt::Horizontal, mPanner1,
"panner 2" );
577 mPanner2->setOpaqueResize( opaqueResize );
578 headerParent = mFolderViewParent = mPanner2;
579 mimeParent = messageParent = mPanner1;
583 if( mPanner1 ) mPanner1->dumpObjectTree();
584 if( mPanner2 ) mPanner2->dumpObjectTree();
587 mTopLayout->add( mPanner1 );
595 headerParent->dumpObjectTree();
597 mSearchAndHeaders =
new TQVBox( headerParent );
598 mSearchToolBar =
new TDEToolBar( mSearchAndHeaders,
"search toolbar");
599 mSearchToolBar->setMovingEnabled(
false);
600 mSearchToolBar->boxLayout()->setSpacing( KDialog::spacingHint() );
601 TQLabel *label =
new TQLabel( i18n(
"S&earch:"), mSearchToolBar,
"tde toolbar widget" );
604 mHeaders =
new KMHeaders(
this, mSearchAndHeaders,
"headers");
607 actionCollection(),
"headers quick search line" );
609 mQuickSearchLine =
new HeaderListQuickSearch( mSearchToolBar, mHeaders,
610 actionCollection(),
"headers quick search line" );
612 label->setBuddy( mQuickSearchLine );
613 connect( mQuickSearchLine, TQT_SIGNAL( requestFullSearch() ),
614 this, TQT_SLOT( slotRequestFullSearchFromQuickSearch() ) );
615 mSearchToolBar->setStretchableWidget( mQuickSearchLine );
616 connect( mHeaders, TQT_SIGNAL( messageListUpdated() ),
617 mQuickSearchLine, TQT_SLOT( updateSearch() ) );
618 if ( !GlobalSettings::self()->quickSearchActive() ) mSearchToolBar->hide();
620 if (mReaderWindowActive) {
621 connect(mHeaders, TQT_SIGNAL(selected(
KMMessage*)),
622 this, TQT_SLOT(slotMsgSelected(
KMMessage*)));
624 connect(mHeaders, TQT_SIGNAL(activated(
KMMessage*)),
625 this, TQT_SLOT(slotMsgActivated(
KMMessage*)));
626 connect( mHeaders, TQT_SIGNAL( selectionChanged() ),
627 TQT_SLOT( startUpdateMessageActionsTimer() ) );
628 TQAccel *accel = actionCollection()->tdeaccel();
629 accel->connectItem(accel->insertItem(SHIFT+Key_Left),
630 mHeaders, TQT_SLOT(selectPrevMessage()));
631 accel->connectItem(accel->insertItem(SHIFT+Key_Right),
632 mHeaders, TQT_SLOT(selectNextMessage()));
634 if (mReaderWindowActive) {
635 mMsgView =
new KMReaderWin(messageParent, TQT_TQWIDGET(
this), actionCollection(), 0 );
637 mMsgActions->setMessageView( mMsgView );
640 connect(mMsgView, TQT_SIGNAL(replaceMsgByUnencryptedVersion()),
641 this, TQT_SLOT(slotReplaceMsgByUnencryptedVersion()));
642 connect(mMsgView, TQT_SIGNAL(popupMenu(
KMMessage&,
const KURL&,
const TQPoint&)),
643 this, TQT_SLOT(slotMsgPopup(
KMMessage&,
const KURL&,
const TQPoint&)));
644 connect(mMsgView, TQT_SIGNAL(urlClicked(
const KURL&,
int)),
645 mMsgView, TQT_SLOT(slotUrlClicked()));
646 connect(mHeaders, TQT_SIGNAL(maybeDeleting()),
647 mMsgView, TQT_SLOT(clearCache()));
648 connect(mMsgView, TQT_SIGNAL(noDrag()),
649 mHeaders, TQT_SLOT(slotNoDrag()));
650 accel->connectItem(accel->insertItem(Key_Up),
651 mMsgView, TQT_SLOT(slotScrollUp()));
652 accel->connectItem(accel->insertItem(Key_Down),
653 mMsgView, TQT_SLOT(slotScrollDown()));
654 accel->connectItem(accel->insertItem(Key_Prior),
655 mMsgView, TQT_SLOT(slotScrollPrior()));
656 accel->connectItem(accel->insertItem(Key_Next),
657 mMsgView, TQT_SLOT(slotScrollNext()));
664 mMoveMsgToFolderAction =
new TDEAction( i18n(
"Move Message to Folder"), Key_M, TQT_TQOBJECT(
this),
665 TQT_SLOT(slotMoveMsg()), actionCollection(),
666 "move_message_to_folder" );
667 mMoveMsgToFolderAction->plugAccel( actionCollection()->tdeaccel() );
669 action =
new TDEAction( i18n(
"Copy Message to Folder"), Key_C, TQT_TQOBJECT(
this),
670 TQT_SLOT(slotCopyMsg()), actionCollection(),
671 "copy_message_to_folder" );
672 action->plugAccel( actionCollection()->tdeaccel() );
674 action =
new TDEAction( i18n(
"Jump to Folder"), Key_J, TQT_TQOBJECT(
this),
675 TQT_SLOT(slotJumpToFolder()), actionCollection(),
677 action->plugAccel( actionCollection()->tdeaccel() );
680 mFolderViewSplitter =
new TQSplitter( Qt::Vertical, mFolderViewParent );
681 mFolderViewSplitter->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
682 mFavoriteFolderView =
new KMail::FavoriteFolderView(
this, mFolderViewSplitter );
683 if ( mFavoritesCheckMailAction )
684 connect( mFavoritesCheckMailAction, TQT_SIGNAL(activated()), mFavoriteFolderView, TQT_SLOT(checkMail()) );
685 TQWidget *folderTreeParent = mFolderViewParent;
686 if ( GlobalSettings::enableFavoriteFolderView() ) {
687 folderTreeParent = mFolderViewSplitter;
688 mFolderView = mFolderViewSplitter;
690 mFolderTree =
new KMFolderTree(
this, folderTreeParent,
"folderTree");
691 if ( !GlobalSettings::enableFavoriteFolderView() ) {
692 mFolderView = mFolderTree;
694 connect( mFolderTree, TQT_SIGNAL(folderSelected(
KMFolder*)),
695 mFavoriteFolderView, TQT_SLOT(folderTreeSelectionChanged(
KMFolder*)) );
697 connect(mFolderTree, TQT_SIGNAL(folderSelected(
KMFolder*)),
698 this, TQT_SLOT(folderSelected(
KMFolder*)));
699 connect( mFolderTree, TQT_SIGNAL( folderSelected(
KMFolder* ) ),
700 mQuickSearchLine, TQT_SLOT( reset() ) );
701 connect(mFolderTree, TQT_SIGNAL(folderSelectedUnread(
KMFolder*)),
702 this, TQT_SLOT(folderSelectedUnread(
KMFolder*)));
703 connect(mFolderTree, TQT_SIGNAL(folderDrop(
KMFolder*)),
704 this, TQT_SLOT(slotMoveMsgToFolder(
KMFolder*)));
705 connect(mFolderTree, TQT_SIGNAL(folderDropCopy(
KMFolder*)),
706 this, TQT_SLOT(slotCopyMsgToFolder(
KMFolder*)));
707 connect(mFolderTree, TQT_SIGNAL(columnsChanged()),
708 this, TQT_SLOT(slotFolderTreeColumnsChanged()));
710 if ( mFavoriteFolderView ) {
711 connect( mFavoriteFolderView, TQT_SIGNAL(folderDrop(
KMFolder*)), TQT_SLOT(slotMoveMsgToFolder(
KMFolder*)) );
712 connect( mFavoriteFolderView, TQT_SIGNAL(folderDropCopy(
KMFolder*)), TQT_SLOT(slotCopyMsgToFolder(
KMFolder*)) );
716 mRemoveDuplicatesAction =
new TDEAction(
717 i18n(
"Remove Duplicate Messages"), CTRL+Key_Asterisk, TQT_TQOBJECT(
this),
718 TQT_SLOT(removeDuplicates()), actionCollection(),
"remove_duplicate_messages");
719 action->plugAccel( actionCollection()->tdeaccel() );
721 action =
new TDEAction(
722 i18n(
"Abort Current Operation"), Key_Escape, ProgressManager::instance(),
723 TQT_SLOT(slotAbortAll()), actionCollection(),
"cancel" );
724 action->plugAccel( actionCollection()->tdeaccel() );
726 action =
new TDEAction(
727 i18n(
"Focus on Next Folder"), CTRL+Key_Right, TQT_TQOBJECT(mFolderTree),
728 TQT_SLOT(incCurrentFolder()), actionCollection(),
"inc_current_folder");
729 action->plugAccel( actionCollection()->tdeaccel() );
731 action =
new TDEAction(
732 i18n(
"Focus on Previous Folder"), CTRL+Key_Left, TQT_TQOBJECT(mFolderTree),
733 TQT_SLOT(decCurrentFolder()), actionCollection(),
"dec_current_folder");
734 action->plugAccel( actionCollection()->tdeaccel() );
736 action =
new TDEAction(
737 i18n(
"Select Folder with Focus"), CTRL+Key_Space, TQT_TQOBJECT(mFolderTree),
738 TQT_SLOT(selectCurrentFolder()), actionCollection(),
"select_current_folder");
739 action->plugAccel( actionCollection()->tdeaccel() );
741 action =
new TDEAction(
742 i18n(
"Focus on Next Message"), ALT+Key_Right, TQT_TQOBJECT(mHeaders),
743 TQT_SLOT(incCurrentMessage()), actionCollection(),
"inc_current_message");
744 action->plugAccel( actionCollection()->tdeaccel() );
746 action =
new TDEAction(
747 i18n(
"Focus on Previous Message"), ALT+Key_Left, TQT_TQOBJECT(mHeaders),
748 TQT_SLOT(decCurrentMessage()), actionCollection(),
"dec_current_message");
749 action->plugAccel( actionCollection()->tdeaccel() );
751 action =
new TDEAction(
752 i18n(
"Select Message with Focus"), ALT+Key_Space, TQT_TQOBJECT(mHeaders),
753 TQT_SLOT( selectCurrentMessage() ), actionCollection(),
"select_current_message");
754 action->plugAccel( actionCollection()->tdeaccel() );
756 connect( kmkernel->outboxFolder(), TQT_SIGNAL( msgRemoved(
int, TQString) ),
757 TQT_SLOT( startUpdateMessageActionsTimer() ) );
758 connect( kmkernel->outboxFolder(), TQT_SIGNAL( msgAdded(
int) ),
759 TQT_SLOT( startUpdateMessageActionsTimer() ) );
764 void KMMainWidget::activatePanners(
void)
767 TQObject::disconnect( mMsgView->copyAction(),
768 TQT_SIGNAL( activated() ),
769 mMsgView, TQT_SLOT( slotCopySelectedText() ));
773 if ( mLongFolderList ) {
774 mSearchAndHeaders->reparent( mPanner2, 0, TQPoint( 0, 0 ) );
776 mMsgView->reparent( mPanner2, 0, TQPoint( 0, 0 ) );
777 mPanner2->moveToLast( mMsgView );
779 mFolderViewParent = mPanner1;
780 mFolderView->reparent( mFolderViewParent, 0, TQPoint( 0, 0 ) );
781 mPanner1->moveToLast( mPanner2 );
782 mPanner1->setSizes( mPanner1Sep );
783 mPanner1->setResizeMode( mFolderView, TQSplitter::KeepSize );
784 mPanner2->setSizes( mPanner2Sep );
785 mPanner2->setResizeMode( mSearchAndHeaders, TQSplitter::KeepSize );
787 mFolderViewParent = mPanner2;
788 mFolderView->reparent( mFolderViewParent, 0, TQPoint( 0, 0 ) );
789 mSearchAndHeaders->reparent( mPanner2, 0, TQPoint( 0, 0 ) );
790 mPanner2->moveToLast( mSearchAndHeaders );
791 mPanner1->moveToFirst( mPanner2 );
793 mMsgView->reparent( mPanner1, 0, TQPoint( 0, 0 ) );
794 mPanner1->moveToLast( mMsgView );
796 mPanner1->setSizes( mPanner1Sep );
797 mPanner2->setSizes( mPanner2Sep );
798 mPanner1->setResizeMode( mPanner2, TQSplitter::KeepSize );
799 mPanner2->setResizeMode( mFolderView, TQSplitter::KeepSize );
803 TQObject::connect( mMsgView->copyAction(),
804 TQT_SIGNAL( activated() ),
805 mMsgView, TQT_SLOT( slotCopySelectedText() ));
811 void KMMainWidget::hide()
818 void KMMainWidget::show()
824 void KMMainWidget::slotSearch()
828 mSearchWin =
new SearchWindow(
this,
"Search", mFolder,
false);
829 connect(mSearchWin, TQT_SIGNAL(destroyed()),
830 this, TQT_SLOT(slotSearchClosed()));
834 mSearchWin->activateFolder(mFolder);
838 KWin::activateWindow( mSearchWin->winId() );
843 void KMMainWidget::slotSearchClosed()
850 void KMMainWidget::slotFind()
853 mMsgView->slotFind();
858 void KMMainWidget::slotHelp()
865 void KMMainWidget::slotFilter()
867 kmkernel->filterMgr()->openDialog(
this );
872 void KMMainWidget::slotPopFilter()
874 kmkernel->popFilterMgr()->openDialog(
this );
877 void KMMainWidget::slotManageSieveScripts()
879 if ( !kmkernel->askToGoOnline() ) {
882 KMail::ManageSieveScriptsDialog * dlg =
new KMail::ManageSieveScriptsDialog(
this );
888 void KMMainWidget::slotAddrBook()
890 KAddrBookExternal::openAddressBook(
this);
895 void KMMainWidget::slotImport()
897 KRun::runCommand(
"kmailcvt");
901 void KMMainWidget::slotCheckMail()
903 if ( !kmkernel->askToGoOnline() ) {
906 kmkernel->acctMgr()->checkMail(
true);
910 void KMMainWidget::slotCheckOneAccount(
int item)
912 if ( !kmkernel->askToGoOnline() ) {
915 kmkernel->acctMgr()->intCheckMail(item);
919 void KMMainWidget::slotMailChecked(
bool newMail,
bool sendOnCheck,
920 const TQMap<TQString, int> & newInFolder )
922 const bool sendOnAll =
923 GlobalSettings::self()->sendOnCheck() == GlobalSettings::EnumSendOnCheck::SendOnAllChecks;
924 const bool sendOnManual =
925 GlobalSettings::self()->sendOnCheck() == GlobalSettings::EnumSendOnCheck::SendOnManualChecks;
926 if( !kmkernel->isOffline() && ( sendOnAll || (sendOnManual && sendOnCheck ) ) )
929 if ( !newMail || newInFolder.isEmpty() )
932 kapp->dcopClient()->emitDCOPSignal(
"unreadCountChanged()", TQByteArray() );
935 bool showNotification =
false;
937 TQStringList keys( newInFolder.keys() );
939 for ( TQStringList::const_iterator it = keys.begin();
942 kdDebug(5006) << newInFolder.find( *it ).data() <<
" new message(s) in "
945 KMFolder *folder = kmkernel->findFolderById( *it );
948 showNotification =
true;
949 if ( GlobalSettings::self()->verboseNewMailNotification() ) {
950 summary +=
"<br>" + i18n(
"1 new message in %1",
951 "%n new messages in %1",
952 newInFolder.find( *it ).data() )
962 if ( !showNotification )
965 if ( GlobalSettings::self()->verboseNewMailNotification() ) {
966 summary = i18n(
"%1 is a list of the number of new messages per folder",
967 "<b>New mail arrived</b><br>%1" )
971 summary = i18n(
"New mail arrived" );
974 if(kmkernel->xmlGuiInstance()) {
975 KNotifyClient::Instance instance(kmkernel->xmlGuiInstance());
976 KNotifyClient::event( topLevelWidget()->winId(),
"new-mail-arrived",
980 KNotifyClient::event( topLevelWidget()->winId(),
"new-mail-arrived",
984 KNotifyClient::beep();
990 void KMMainWidget::slotCompose()
992 KMail::Composer * win;
998 parser.process( NULL, mFolder );
999 win = KMail::makeComposer( msg, mFolder->identity() );
1003 parser.process( NULL, NULL );
1004 win = KMail::makeComposer( msg );
1013 void KMMainWidget::slotShowNewFromTemplate()
1016 const KPIM::Identity & ident =
1017 kmkernel->identityManager()->identityForUoidOrDefault( mFolder->identity() );
1018 mTemplateFolder = kmkernel->folderMgr()->findIdString( ident.templates() );
1020 else mTemplateFolder = kmkernel->templatesFolder();
1021 if ( !mTemplateFolder )
1024 mTemplateMenu->popupMenu()->clear();
1025 for (
int idx = 0; idx<mTemplateFolder->count(); ++idx ) {
1026 KMMsgBase *mb = mTemplateFolder->getMsgBase( idx );
1028 TQString subj = mb->subject();
1029 if ( subj.isEmpty() ) subj = i18n(
"No Subject");
1030 mTemplateMenu->popupMenu()->insertItem(
1031 KStringHandler::rsqueeze( subj.replace(
"&",
"&&" ) ), idx );
1036 void KMMainWidget::slotNewFromTemplate(
int id )
1038 if ( !mTemplateFolder )
1040 newFromTemplate(mTemplateFolder->getMsg(
id ) );
1044 void KMMainWidget::newFromTemplate(
KMMessage *msg )
1048 KMCommand *command =
new KMUseTemplateCommand(
this, msg );
1053 void KMMainWidget::slotPostToML()
1055 if ( mFolder && mFolder->isMailingListEnabled() ) {
1056 KMCommand *command =
new KMMailingListPostCommand(
this, mFolder );
1064 void KMMainWidget::slotFolderMailingListProperties()
1066 if (!mFolderTree)
return;
1067 KMFolderTreeItem *item =
static_cast<KMFolderTreeItem*
>( mFolderTree->currentItem() );
1068 if ( !item )
return;
1071 (
new KMail::MailingListFolderPropertiesDialog(
this, folder ) )->show();
1076 void KMMainWidget::slotFolderShortcutCommand()
1078 if (!mFolderTree)
return;
1079 KMFolderTreeItem *item =
static_cast<KMFolderTreeItem*
>( mFolderTree->currentItem() );
1081 item->assignShortcut();
1086 void KMMainWidget::slotModifyFolder()
1088 if (!mFolderTree)
return;
1089 KMFolderTreeItem *item =
static_cast<KMFolderTreeItem*
>( mFolderTree->currentItem() );
1091 modifyFolder( item );
1095 void KMMainWidget::modifyFolder( KMFolderTreeItem* folderItem )
1097 KMFolder* folder = folderItem->folder();
1098 KMFolderTree* folderTree =
static_cast<KMFolderTree *
>( folderItem->listView() );
1100 i18n(
"Properties of Folder %1").arg( folder->
label() ) );
1105 mSystemTray->foldersChanged();
1109 void KMMainWidget::slotExpireFolder()
1112 bool canBeExpired =
true;
1114 if (!mFolder)
return;
1116 if (!mFolder->isAutoExpire()) {
1117 canBeExpired =
false;
1118 }
else if (mFolder->getUnreadExpireUnits()==expireNever &&
1119 mFolder->getReadExpireUnits()==expireNever) {
1120 canBeExpired =
false;
1123 if (!canBeExpired) {
1124 str = i18n(
"This folder does not have any expiry options set");
1125 KMessageBox::information(
this, str);
1128 TDEConfig *config = KMKernel::config();
1129 TDEConfigGroupSaver saver(config,
"General");
1131 if (config->readBoolEntry(
"warn-before-expire",
true)) {
1132 str = i18n(
"<qt>Are you sure you want to expire the folder <b>%1</b>?</qt>").arg(TQStyleSheet::escape( mFolder->label() ));
1133 if (KMessageBox::warningContinueCancel(
this, str, i18n(
"Expire Folder"),
1135 != KMessageBox::Continue)
return;
1138 mFolder->expireOldMessages(
true );
1142 void KMMainWidget::slotEmptyFolder()
1146 if (!mFolder)
return;
1147 bool isTrash = kmkernel->folderIsTrash(mFolder);
1151 TQString title = (isTrash) ? i18n(
"Empty Trash") : i18n(
"Move to Trash");
1152 TQString text = (isTrash) ?
1153 i18n(
"Are you sure you want to empty the trash folder?") :
1154 i18n(
"<qt>Are you sure you want to move all messages from "
1155 "folder <b>%1</b> to the trash?</qt>").arg( TQStyleSheet::escape( mFolder->label() ) );
1157 if (KMessageBox::warningContinueCancel(
this, text, title, KGuiItem( title,
"edittrash"))
1158 != KMessageBox::Continue)
return;
1165 slotDeleteMsg(
false );
1170 if (mMsgView) mMsgView->clearCache();
1173 BroadcastStatus::instance()->setStatusMsg(i18n(
"Moved all messages to the trash"));
1175 updateMessageActions();
1179 mEmptyFolderAction->setEnabled(
false );
1183 void KMMainWidget::slotArchiveFolder()
1185 KMail::ArchiveFolderDialog archiveDialog;
1186 archiveDialog.setFolder( mFolder );
1187 archiveDialog.exec();
1191 void KMMainWidget::slotRemoveFolder()
1196 if ( !mFolder )
return;
1197 if ( mFolder->isSystemFolder() )
return;
1198 if ( mFolder->isReadOnly() )
return;
1199 if ( mFolder->mailCheckInProgress() ) {
1200 KMessageBox::sorry(
this, i18n(
"It is not possible to delete this folder right now because it "
1201 "is being syncronized. Please wait until the syncronization of "
1202 "this folder is complete and then try again." ),
1203 i18n(
"Unable to delete folder" ) );
1208 if ( mFolder->folderType() == KMFolderTypeSearch ) {
1209 title = i18n(
"Delete Search");
1210 str = i18n(
"<qt>Are you sure you want to delete the search <b>%1</b>?<br>"
1211 "Any messages it shows will still be available in their original folder.</qt>")
1212 .arg( TQStyleSheet::escape( mFolder->label() ) );
1214 title = i18n(
"Delete Folder");
1215 if ( mFolder->count() == 0 ) {
1216 if ( !mFolder->child() || mFolder->child()->isEmpty() ) {
1217 str = i18n(
"<qt>Are you sure you want to delete the empty folder "
1219 .arg( TQStyleSheet::escape( mFolder->label() ) );
1222 str = i18n(
"<qt>Are you sure you want to delete the empty folder "
1223 "<b>%1</b> and all its subfolders? Those subfolders might "
1224 "not be empty and their contents will be discarded as well. "
1225 "<p><b>Beware</b> that discarded messages are not saved "
1226 "into your Trash folder and are permanently deleted.</qt>")
1227 .arg( TQStyleSheet::escape( mFolder->label() ) );
1230 if ( !mFolder->child() || mFolder->child()->isEmpty() ) {
1231 str = i18n(
"<qt>Are you sure you want to delete the folder "
1232 "<b>%1</b>, discarding its contents? "
1233 "<p><b>Beware</b> that discarded messages are not saved "
1234 "into your Trash folder and are permanently deleted.</qt>")
1235 .arg( TQStyleSheet::escape( mFolder->label() ) );
1238 str = i18n(
"<qt>Are you sure you want to delete the folder <b>%1</b> "
1239 "and all its subfolders, discarding their contents? "
1240 "<p><b>Beware</b> that discarded messages are not saved "
1241 "into your Trash folder and are permanently deleted.</qt>")
1242 .arg( TQStyleSheet::escape( mFolder->label() ) );
1247 if (KMessageBox::warningContinueCancel(
this, str, title,
1248 KGuiItem( i18n(
"&Delete"),
"edit-delete"))
1249 == KMessageBox::Continue)
1251 KMail::FolderUtil::deleteFolder( mFolder,
this );
1256 void KMMainWidget::slotMarkAllAsRead()
1260 mFolder->markUnreadAsRead();
1264 void KMMainWidget::slotCompactFolder()
1267 int idx = mHeaders->currentItemIndex();
1269 mFolder->compact( KMFolder::CompactNow );
1271 TQString statusMsg = BroadcastStatus::instance()->statusMsg();
1272 mHeaders->setCurrentItemByIndex(idx);
1273 BroadcastStatus::instance()->setStatusMsg( statusMsg );
1279 void KMMainWidget::slotRefreshFolder()
1283 if ( mFolder->folderType() == KMFolderTypeImap || mFolder->folderType() == KMFolderTypeCachedImap ) {
1284 if ( !kmkernel->askToGoOnline() ) {
1289 if (mFolder->folderType() == KMFolderTypeImap)
1291 KMFolderImap *imap =
static_cast<KMFolderImap*
>(mFolder->storage());
1292 imap->getAndCheckFolder();
1293 }
else if ( mFolder->folderType() == KMFolderTypeCachedImap ) {
1294 KMFolderCachedImap* f =
static_cast<KMFolderCachedImap*
>( mFolder->storage() );
1295 f->account()->processNewMailInFolder( mFolder );
1300 void KMMainWidget::slotTroubleshootFolder()
1304 if ( mFolder->folderType() == KMFolderTypeCachedImap ) {
1305 KMFolderCachedImap* f =
static_cast<KMFolderCachedImap*
>( mFolder->storage() );
1306 f->slotTroubleshoot();
1311 void KMMainWidget::slotInvalidateIMAPFolders() {
1312 if ( KMessageBox::warningContinueCancel(
this,
1313 i18n(
"Are you sure you want to refresh the IMAP cache?\n"
1314 "This will remove all changes that you have done "
1315 "locally to your IMAP folders."),
1316 i18n(
"Refresh IMAP Cache"), i18n(
"&Refresh") ) == KMessageBox::Continue )
1317 kmkernel->acctMgr()->invalidateIMAPFolders();
1321 void KMMainWidget::slotExpireAll() {
1322 TDEConfig *config = KMKernel::config();
1325 TDEConfigGroupSaver saver(config,
"General");
1327 if (config->readBoolEntry(
"warn-before-expire",
true)) {
1328 ret = KMessageBox::warningContinueCancel(TDEMainWindow::memberList->first(),
1329 i18n(
"Are you sure you want to expire all old messages?"),
1330 i18n(
"Expire Old Messages?"), i18n(
"Expire"));
1331 if (ret != KMessageBox::Continue) {
1336 kmkernel->expireAllFoldersNow();
1340 void KMMainWidget::slotCompactAll()
1343 kmkernel->compactAllFolders();
1348 void KMMainWidget::slotOverrideHtml()
1350 if( mHtmlPref == mFolderHtmlPref ) {
1351 int result = KMessageBox::warningContinueCancel(
this,
1353 i18n(
"Use of HTML in mail will make you more vulnerable to "
1354 "\"spam\" and may increase the likelihood that your system will be "
1355 "compromised by other present and anticipated security exploits." ),
1356 i18n(
"Security Warning" ),
1358 "OverrideHtmlWarning",
false);
1359 if( result == KMessageBox::Cancel ) {
1360 mPreferHtmlAction->setChecked(
false );
1364 mFolderHtmlPref = !mFolderHtmlPref;
1366 mMsgView->setHtmlOverride(mFolderHtmlPref);
1367 mMsgView->update(
true );
1372 void KMMainWidget::slotOverrideHtmlLoadExt()
1374 if( mHtmlLoadExtPref == mFolderHtmlLoadExtPref ) {
1375 int result = KMessageBox::warningContinueCancel(
this,
1377 i18n(
"Loading external references in html mail will make you more vulnerable to "
1378 "\"spam\" and may increase the likelihood that your system will be "
1379 "compromised by other present and anticipated security exploits." ),
1380 i18n(
"Security Warning" ),
1381 i18n(
"Load External References" ),
1382 "OverrideHtmlLoadExtWarning",
false);
1383 if( result == KMessageBox::Cancel ) {
1384 mPreferHtmlLoadExtAction->setChecked(
false );
1388 mFolderHtmlLoadExtPref = !mFolderHtmlLoadExtPref;
1390 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
1391 mMsgView->update(
true );
1396 void KMMainWidget::slotOverrideThread()
1398 mFolderThreadPref = !mFolderThreadPref;
1399 mHeaders->setNestedOverride(mFolderThreadPref);
1400 mThreadBySubjectAction->setEnabled(mThreadMessagesAction->isChecked());
1404 void KMMainWidget::slotToggleSubjectThreading()
1406 mFolderThreadSubjPref = !mFolderThreadSubjPref;
1407 mHeaders->setSubjectThreading(mFolderThreadSubjPref);
1411 void KMMainWidget::slotToggleShowQuickSearch()
1413 GlobalSettings::self()->setQuickSearchActive( !GlobalSettings::self()->quickSearchActive() );
1414 if ( GlobalSettings::self()->quickSearchActive() )
1415 mSearchToolBar->show();
1417 mQuickSearchLine->reset();
1418 mSearchToolBar->hide();
1423 void KMMainWidget::slotMessageQueuedOrDrafted()
1425 if (!kmkernel->folderIsDraftOrOutbox(mFolder))
1428 mMsgView->update(
true);
1433 void KMMainWidget::slotForwardInlineMsg()
1435 KMMessageList* selected = mHeaders->selectedMsgs();
1436 KMCommand *command = 0L;
1437 if(selected && !selected->isEmpty()) {
1438 command =
new KMForwardInlineCommand(
this, *selected,
1439 mFolder->identity() );
1441 command =
new KMForwardInlineCommand(
this, mHeaders->currentMsg(),
1442 mFolder->identity() );
1450 void KMMainWidget::slotForwardAttachedMsg()
1452 KMMessageList* selected = mHeaders->selectedMsgs();
1453 KMCommand *command = 0L;
1454 if(selected && !selected->isEmpty()) {
1455 command =
new KMForwardAttachedCommand(
this, *selected, mFolder->identity() );
1457 command =
new KMForwardAttachedCommand(
this, mHeaders->currentMsg(), mFolder->identity() );
1464 void KMMainWidget::slotForwardDigestMsg()
1466 KMMessageList* selected = mHeaders->selectedMsgs();
1467 KMCommand *command = 0L;
1468 if(selected && !selected->isEmpty()) {
1469 command =
new KMForwardDigestCommand(
this, *selected, mFolder->identity() );
1471 command =
new KMForwardDigestCommand(
this, mHeaders->currentMsg(), mFolder->identity() );
1478 void KMMainWidget::slotUseTemplate()
1480 newFromTemplate( mHeaders->currentMsg() );
1484 void KMMainWidget::slotResendMsg()
1486 KMCommand *command =
new KMResendMessageCommand(
this, mHeaders->currentMsg() );
1492 void KMMainWidget::slotTrashMsg()
1494 mHeaders->deleteMsg();
1498 void KMMainWidget::slotDeleteMsg(
bool confirmDelete )
1500 mHeaders->moveMsgToFolder( 0, confirmDelete );
1504 void KMMainWidget::slotTrashThread()
1506 mHeaders->highlightCurrentThread();
1507 mHeaders->deleteMsg();
1511 void KMMainWidget::slotDeleteThread(
bool confirmDelete )
1513 mHeaders->highlightCurrentThread();
1514 mHeaders->moveMsgToFolder( 0, confirmDelete );
1518 void KMMainWidget::slotRedirectMsg()
1520 KMCommand *command =
new KMRedirectCommand(
this, mHeaders->currentMsg() );
1526 void KMMainWidget::slotCustomReplyToMsg(
int tid )
1528 TQString text = mMsgView? mMsgView->copyText() :
"";
1529 TQString tmpl = mCustomTemplates[ tid ];
1530 kdDebug() <<
"Reply with template: " << tmpl <<
" (" << tid <<
")" << endl;
1531 KMCommand *command =
new KMCustomReplyToCommand(
this,
1532 mHeaders->currentMsg(),
1540 void KMMainWidget::slotCustomReplyAllToMsg(
int tid )
1542 TQString text = mMsgView? mMsgView->copyText() :
"";
1543 TQString tmpl = mCustomTemplates[ tid ];
1544 kdDebug() <<
"Reply to All with template: " << tmpl <<
" (" << tid <<
")" << endl;
1545 KMCommand *command =
new KMCustomReplyAllToCommand(
this,
1546 mHeaders->currentMsg(),
1554 void KMMainWidget::slotCustomForwardMsg(
int tid )
1556 TQString tmpl = mCustomTemplates[ tid ];
1557 kdDebug() <<
"Forward with template: " << tmpl <<
" (" << tid <<
")" << endl;
1558 KMMessageList* selected = mHeaders->selectedMsgs();
1559 KMCommand *command = 0L;
1560 if(selected && !selected->isEmpty()) {
1561 command =
new KMCustomForwardCommand(
this, *selected,
1562 mFolder->identity(), tmpl );
1564 command =
new KMCustomForwardCommand(
this, mHeaders->currentMsg(),
1565 mFolder->identity(), tmpl );
1572 void KMMainWidget::slotNoQuoteReplyToMsg()
1574 KMCommand *command =
new KMNoQuoteReplyToCommand(
this, mHeaders->currentMsg() );
1579 void KMMainWidget::slotSubjectFilter()
1581 KMMessage *msg = mHeaders->currentMsg();
1585 KMCommand *command =
new KMFilterCommand(
"Subject", msg->
subject() );
1590 void KMMainWidget::slotMailingListFilter()
1592 KMMessage *msg = mHeaders->currentMsg();
1596 KMCommand *command =
new KMMailingListFilterCommand(
this, msg );
1601 void KMMainWidget::slotFromFilter()
1603 KMMessage *msg = mHeaders->currentMsg();
1607 AddrSpecList al = msg->extractAddrSpecs(
"From" );
1610 command =
new KMFilterCommand(
"From", msg->
from() );
1612 command =
new KMFilterCommand(
"From", al.front().asString() );
1617 void KMMainWidget::slotToFilter()
1619 KMMessage *msg = mHeaders->currentMsg();
1623 KMCommand *command =
new KMFilterCommand(
"To", msg->
to() );
1628 void KMMainWidget::updateListFilterAction()
1633 TQString lname = MailingList::name( mHeaders->currentMsg(), name, value );
1634 mListFilterAction->setText( i18n(
"Filter on Mailing-List...") );
1635 if ( lname.isNull() )
1636 mListFilterAction->setEnabled(
false );
1638 mListFilterAction->setEnabled(
true );
1639 mListFilterAction->setText( i18n(
"Filter on Mailing-List %1..." ).arg( lname ) );
1645 void KMMainWidget::slotUndo()
1648 updateMessageActions();
1653 void KMMainWidget::slotToggleUnread()
1655 mFolderTree->toggleColumn(KMFolderTree::unread);
1659 void KMMainWidget::slotToggleTotalColumn()
1661 mFolderTree->toggleColumn(KMFolderTree::total,
true);
1665 void KMMainWidget::slotToggleSizeColumn()
1667 mFolderTree->toggleColumn(KMFolderTree::foldersize);
1672 void KMMainWidget::slotJumpToFolder()
1674 KMail::KMFolderSelDlg dlg(
this, i18n(
"Jump to Folder"),
true );
1677 if (!dlg.exec())
return;
1678 if (!(dest = dlg.folder()))
return;
1680 slotSelectFolder( dest );
1684 void KMMainWidget::slotMoveMsg()
1686 KMail::KMFolderSelDlg dlg(
this, i18n(
"Move Message to Folder"),
true );
1689 if (!dlg.exec())
return;
1690 if (!(dest = dlg.folder()))
return;
1692 mHeaders->moveMsgToFolder(dest);
1696 void KMMainWidget::slotMoveMsgToFolder(
KMFolder *dest)
1698 mHeaders->moveMsgToFolder(dest);
1702 void KMMainWidget::slotCopyMsgToFolder(
KMFolder *dest)
1704 mHeaders->copyMsgToFolder(dest);
1708 void KMMainWidget::slotApplyFilters()
1710 mHeaders->applyFiltersOnMsg();
1714 void KMMainWidget::slotCheckVacation()
1716 updateVactionScripStatus(
false );
1717 if ( !kmkernel->askToGoOnline() )
1720 Vacation *vac =
new Vacation( TQT_TQOBJECT(
this),
true );
1721 connect( vac, TQT_SIGNAL(scriptActive(
bool)), TQT_SLOT(updateVactionScripStatus(
bool)) );
1724 void KMMainWidget::slotEditVacation()
1726 if ( !kmkernel->askToGoOnline() ) {
1733 mVacation =
new Vacation( TQT_TQOBJECT(
this) );
1734 connect( mVacation, TQT_SIGNAL(scriptActive(
bool)), TQT_SLOT(updateVactionScripStatus(
bool)) );
1735 if ( mVacation->isUsable() ) {
1736 connect( mVacation, TQT_SIGNAL(result(
bool)), mVacation, TQT_SLOT(deleteLater()) );
1738 TQString msg = i18n(
"KMail's Out of Office Reply functionality relies on "
1739 "server-side filtering. You have not yet configured an "
1740 "IMAP server for this.\n"
1741 "You can do this on the \"Filtering\" tab of the IMAP "
1742 "account configuration.");
1743 KMessageBox::sorry(
this, msg, i18n(
"No Server-Side Filtering Configured") );
1750 void KMMainWidget::slotDebugSieve()
1752 #if !defined(NDEBUG)
1753 if ( mSieveDebugDialog )
1757 mSieveDebugDialog->exec();
1758 delete mSieveDebugDialog;
1763 void KMMainWidget::slotStartCertManager()
1765 TDEProcess certManagerProc;
1767 certManagerProc <<
"kleopatra";
1769 if( !certManagerProc.start( TDEProcess::DontCare ) )
1770 KMessageBox::error(
this, i18n(
"Could not start certificate manager 'kleopatra'; "
1771 "please check your installation." ),
1772 i18n(
"KMail Error" ) );
1774 kdDebug(5006) <<
"\nslotStartCertManager(): certificate manager started.\n" << endl;
1781 void KMMainWidget::slotStartWatchGnuPG()
1783 TDEProcess certManagerProc;
1784 certManagerProc <<
"kwatchgnupg";
1786 if( !certManagerProc.start( TDEProcess::DontCare ) )
1787 KMessageBox::error(
this, i18n(
"Could not start GnuPG LogViewer (kwatchgnupg); "
1788 "please check your installation." ),
1789 i18n(
"KMail Error" ) );
1793 void KMMainWidget::slotCopyMsg()
1795 KMail::KMFolderSelDlg dlg(
this, i18n(
"Copy Message to Folder"),
true );
1798 if (!dlg.exec())
return;
1799 if (!(dest = dlg.folder()))
return;
1801 mHeaders->copyMsgToFolder(dest);
1805 void KMMainWidget::slotPrintMsg()
1807 KMMessage *msg = mHeaders->currentMsg();
1812 bool htmlOverride = mMsgView ? mMsgView->htmlOverride() :
false;
1813 bool htmlLoadExtOverride = mMsgView ? mMsgView->htmlLoadExtOverride() :
false;
1814 TDEConfigGroup reader( KMKernel::config(),
"Reader" );
1815 bool useFixedFont = mMsgView ? mMsgView->isFixedFont()
1816 : reader.readBoolEntry(
"useFixedFont",
false );
1819 const HeaderStrategy *strategy;
1821 style = mMsgView->headerStyle();
1822 strategy = mMsgView->headerStrategy();
1824 style = HeaderStyle::create( reader.readEntry(
"header-style",
"fancy" ) );
1825 strategy = HeaderStrategy::create( reader.readEntry(
"header-set-displayed",
"rich" ) );
1828 KMPrintCommand *command =
1829 new KMPrintCommand(
this, msg,
1831 htmlOverride, htmlLoadExtOverride,
1832 useFixedFont, overrideEncoding() );
1834 command->setOverrideFont( mMsgView->cssHelper()->bodyFont( mMsgView->isFixedFont(),
true ) );
1840 void KMMainWidget::setupForwardActions()
1842 disconnect( mForwardActionMenu, TQT_SIGNAL( activated() ), 0, 0 );
1843 mForwardActionMenu->remove( mForwardInlineAction );
1844 mForwardActionMenu->remove( mForwardAttachedAction );
1846 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
1847 mForwardActionMenu->insert( mForwardInlineAction, 0 );
1848 mForwardActionMenu->insert( mForwardAttachedAction, 1 );
1849 mForwardInlineAction->setShortcut( Key_F );
1850 mForwardAttachedAction->setShortcut( SHIFT+Key_F );
1851 connect( mForwardActionMenu, TQT_SIGNAL(activated()), TQT_TQOBJECT(
this),
1852 TQT_SLOT(slotForwardInlineMsg()) );
1855 mForwardActionMenu->insert( mForwardAttachedAction, 0 );
1856 mForwardActionMenu->insert( mForwardInlineAction, 1 );
1857 mForwardInlineAction->setShortcut( SHIFT+Key_F );
1858 mForwardAttachedAction->setShortcut( Key_F );
1859 connect( mForwardActionMenu, TQT_SIGNAL(activated()), TQT_TQOBJECT(
this),
1860 TQT_SLOT(slotForwardAttachedMsg()) );
1865 void KMMainWidget::slotConfigChanged()
1868 setupForwardActions();
1869 setupForwardingActionsList();
1873 void KMMainWidget::slotSaveMsg()
1875 KMMessage *msg = mHeaders->currentMsg();
1878 KMSaveMsgCommand *saveCommand =
new KMSaveMsgCommand(
this,
1879 *mHeaders->selectedMsgs() );
1881 if (saveCommand->url().isEmpty())
1884 saveCommand->start();
1888 void KMMainWidget::slotOpenMsg()
1890 KMOpenMsgCommand *openCommand =
new KMOpenMsgCommand(
this, 0, overrideEncoding() );
1892 openCommand->start();
1896 void KMMainWidget::slotSaveAttachments()
1898 KMMessage *msg = mHeaders->currentMsg();
1901 KMSaveAttachmentsCommand *saveCommand =
new KMSaveAttachmentsCommand(
this,
1902 *mHeaders->selectedMsgs() );
1903 saveCommand->start();
1906 void KMMainWidget::slotOnlineStatus()
1910 if ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Online ) {
1912 kmkernel->stopNetworkJobs();
1914 kmkernel->resumeNetworkJobs();
1915 slotCheckVacation();
1919 void KMMainWidget::slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type )
1921 if ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Online )
1922 actionCollection()->action(
"online_status" )->setText( i18n(
"Work Offline") );
1924 actionCollection()->action(
"online_status" )->setText( i18n(
"Work Online") );
1929 void KMMainWidget::slotSendQueued()
1931 if ( !kmkernel->askToGoOnline() ) {
1935 kmkernel->msgSender()->sendQueued();
1939 void KMMainWidget::slotSendQueuedVia(
int item )
1941 if ( !kmkernel->askToGoOnline() ) {
1946 TQString customTransport = availTransports[ item ];
1948 kmkernel->msgSender()->sendQueued( customTransport );
1952 void KMMainWidget::slotViewChange()
1954 if(mBodyPartsMenu->isItemChecked(mBodyPartsMenu->idAt(0)))
1956 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(0),
false);
1957 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(1),
true);
1959 else if(mBodyPartsMenu->isItemChecked(mBodyPartsMenu->idAt(1)))
1961 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(1),
false);
1962 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(0),
true);
1970 void KMMainWidget::folderSelectedUnread(
KMFolder* aFolder )
1972 folderSelected( aFolder,
true );
1973 slotChangeCaption( mFolderTree->currentItem() );
1977 void KMMainWidget::folderSelected()
1979 folderSelected( mFolder );
1982 if ( mFolder && mFolder->folderType() == KMFolderTypeImap )
1983 mFolder->close(
"mainwidget");
1987 void KMMainWidget::folderSelected(
KMFolder* aFolder,
bool forceJumpToUnread )
1992 mMsgView->clear(
true);
1994 if ( mFolder && mFolder->folderType() == KMFolderTypeImap && !mFolder->noContent() )
1996 KMFolderImap *imap =
static_cast<KMFolderImap*
>(mFolder->storage());
1997 if ( mFolder->needsCompacting() && imap->autoExpunge() )
1998 imap->expungeFolder(imap,
true);
2008 bool newFolder = ( (
KMFolder*)mFolder != aFolder );
2009 bool isNewImapFolder = aFolder && aFolder->
folderType() == KMFolderTypeImap && newFolder;
2011 || ( !isNewImapFolder && mShowBusySplashTimer )
2012 || ( newFolder && mShowingOfflineScreen && !( isNewImapFolder && kmkernel->isOffline() ) ) ) {
2014 mMsgView->enableMsgDisplay();
2015 mMsgView->clear(
true );
2017 if( mSearchAndHeaders && mHeaders )
2018 mSearchAndHeaders->show();
2019 mShowingOfflineScreen =
false;
2023 delete mShowBusySplashTimer;
2024 mShowBusySplashTimer = 0;
2027 writeFolderConfig();
2029 disconnect( mFolder, TQT_SIGNAL( changed() ),
2030 this, TQT_SLOT( updateMarkAsReadAction() ) );
2031 disconnect( mFolder, TQT_SIGNAL( msgHeaderChanged(
KMFolder*,
int ) ),
2032 this, TQT_SLOT( updateMarkAsReadAction() ) );
2033 disconnect( mFolder, TQT_SIGNAL( msgAdded(
int ) ),
2034 this, TQT_SLOT( updateMarkAsReadAction() ) );
2035 disconnect( mFolder, TQT_SIGNAL( msgRemoved(
KMFolder * ) ),
2036 this, TQT_SLOT( updateMarkAsReadAction() ) );
2041 if ( aFolder && aFolder->
folderType() == KMFolderTypeImap )
2043 if ( kmkernel->isOffline() ) {
2047 KMFolderImap *imap =
static_cast<KMFolderImap*
>(aFolder->storage());
2048 if ( newFolder && !mFolder->noContent() )
2050 imap->open(
"mainwidget");
2052 imap->setSelected(
true );
2053 connect( imap, TQT_SIGNAL( folderComplete( KMFolderImap*,
bool ) ),
2054 this, TQT_SLOT( folderSelected() ) );
2055 imap->getAndCheckFolder();
2056 mHeaders->setFolder( 0 );
2058 mForceJumpToUnread = forceJumpToUnread;
2062 mShowBusySplashTimer =
new TQTimer(
this );
2063 connect( mShowBusySplashTimer, TQT_SIGNAL( timeout() ), TQT_TQOBJECT(
this), TQT_SLOT( slotShowBusySplash() ) );
2064 mShowBusySplashTimer->start( GlobalSettings::self()->folderLoadingTimeout(),
true );
2068 disconnect( imap, TQT_SIGNAL( folderComplete( KMFolderImap*,
bool ) ),
2069 this, TQT_SLOT( folderSelected() ) );
2070 forceJumpToUnread = mForceJumpToUnread;
2075 connect( mFolder, TQT_SIGNAL( changed() ),
2076 this, TQT_SLOT( updateMarkAsReadAction() ) );
2077 connect( mFolder, TQT_SIGNAL( msgHeaderChanged(
KMFolder*,
int ) ),
2078 this, TQT_SLOT( updateMarkAsReadAction() ) );
2079 connect( mFolder, TQT_SIGNAL( msgAdded(
int ) ),
2080 this, TQT_SLOT( updateMarkAsReadAction() ) );
2081 connect( mFolder, TQT_SIGNAL( msgRemoved(
KMFolder *) ),
2082 this, TQT_SLOT( updateMarkAsReadAction() ) );
2087 mMsgView->setHtmlOverride(mFolderHtmlPref);
2088 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
2090 mHeaders->setFolder( mFolder, forceJumpToUnread );
2091 updateMessageActions();
2098 void KMMainWidget::slotShowBusySplash()
2100 if ( mReaderWindowActive )
2102 mMsgView->displayBusyPage();
2104 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
2105 mSearchAndHeaders->hide();
2109 void KMMainWidget::showOfflinePage()
2111 if ( !mReaderWindowActive )
return;
2112 mShowingOfflineScreen =
true;
2114 mMsgView->displayOfflinePage();
2116 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
2117 mSearchAndHeaders->hide();
2121 void KMMainWidget::slotMsgSelected(
KMMessage *msg)
2123 if ( msg && msg->parent() && !msg->
isComplete() )
2128 mMsgView->setWaitingForSerNum( msg->getMsgSerNum() );
2131 disconnect( mJob, 0, mMsgView, 0 );
2134 mJob = msg->parent()->createJob( msg, FolderJob::tGetMessage, 0,
2135 "STRUCTURE", mMsgView->attachmentStrategy() );
2136 connect(mJob, TQT_SIGNAL(messageRetrieved(
KMMessage*)),
2137 mMsgView, TQT_SLOT(slotMessageArrived(
KMMessage*)));
2140 mMsgView->setMsg(msg);
2143 mMsgView->setHtmlOverride(mFolderHtmlPref);
2144 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
2145 mMsgView->setDecryptMessageOverwrite(
false );
2146 mMsgView->setShowSignatureDetails(
false );
2150 void KMMainWidget::slotMsgChanged()
2152 mHeaders->msgChanged();
2156 void KMMainWidget::slotSelectFolder(
KMFolder* folder)
2158 TQListViewItem* item = mFolderTree->indexOfFolder(folder);
2160 mFolderTree->ensureItemVisible( item );
2161 mFolderTree->doFolderSelected( item );
2166 void KMMainWidget::slotSelectMessage(
KMMessage* msg)
2168 int idx = mFolder->find(msg);
2170 mHeaders->setCurrentMsg(idx);
2172 mMsgView->setMsg(msg);
2174 slotMsgActivated(msg);
2179 void KMMainWidget::slotReplaceMsgByUnencryptedVersion()
2181 kdDebug(5006) <<
"KMMainWidget::slotReplaceMsgByUnencryptedVersion()" << endl;
2182 KMMessage* oldMsg = mHeaders->currentMsg();
2184 kdDebug(5006) <<
"KMMainWidget - old message found" << endl;
2186 kdDebug(5006) <<
"KMMainWidget - extra unencrypted message found" << endl;
2190 TQString msgId( oldMsg->
msgId() );
2191 TQString prefix(
"DecryptedMsg.");
2192 int oldIdx = msgId.find(prefix, 0,
false);
2193 if( -1 == oldIdx ) {
2194 int leftAngle = msgId.findRev(
'<' );
2195 msgId = msgId.insert( (-1 == leftAngle) ? 0 : ++leftAngle, prefix );
2200 TQCharRef c = msgId[ oldIdx+2 ];
2206 newMsg->setMsgId( msgId );
2207 mMsgView->setIdOfLastViewedMessage( msgId );
2210 kdDebug(5006) <<
"KMMainWidget - adding unencrypted message to folder" << endl;
2211 mFolder->addMsg( newMsg );
2214 int newMsgIdx = mFolder->find( newMsg );
2215 Q_ASSERT( newMsgIdx != -1 );
2217 mFolder->unGetMsg( newMsgIdx );
2218 int idx = mFolder->find( oldMsg );
2219 Q_ASSERT( idx != -1 );
2222 mHeaders->setCurrentItemByIndex( newMsgIdx );
2225 kdDebug(5006) <<
"KMMainWidget - deleting encrypted message" << endl;
2226 mFolder->take( idx );
2229 kdDebug(5006) <<
"KMMainWidget - updating message actions" << endl;
2230 updateMessageActions();
2232 kdDebug(5006) <<
"KMMainWidget - done." << endl;
2234 kdDebug(5006) <<
"KMMainWidget - NO EXTRA UNENCRYPTED MESSAGE FOUND" << endl;
2236 kdDebug(5006) <<
"KMMainWidget - PANIC: NO OLD MESSAGE FOUND" << endl;
2240 void KMMainWidget::slotSetThreadStatusNew()
2242 mHeaders->setThreadStatus(KMMsgStatusNew);
2246 void KMMainWidget::slotSetThreadStatusUnread()
2248 mHeaders->setThreadStatus(KMMsgStatusUnread);
2252 void KMMainWidget::slotSetThreadStatusFlag()
2254 mHeaders->setThreadStatus(KMMsgStatusFlag,
true);
2258 void KMMainWidget::slotSetThreadStatusRead()
2260 mHeaders->setThreadStatus(KMMsgStatusRead);
2264 void KMMainWidget::slotSetThreadStatusTodo()
2266 mHeaders->setThreadStatus(KMMsgStatusTodo,
true);
2270 void KMMainWidget::slotSetThreadStatusWatched()
2272 mHeaders->setThreadStatus(KMMsgStatusWatched,
true);
2273 if (mWatchThreadAction->isChecked()) {
2274 mIgnoreThreadAction->setChecked(
false);
2279 void KMMainWidget::slotSetThreadStatusIgnored()
2281 mHeaders->setThreadStatus(KMMsgStatusIgnored,
true);
2282 if (mIgnoreThreadAction->isChecked()) {
2283 mWatchThreadAction->setChecked(
false);
2288 void KMMainWidget::slotNextMessage() { mHeaders->nextMessage(); }
2289 void KMMainWidget::slotNextUnreadMessage()
2291 if ( !mHeaders->nextUnreadMessage() )
2292 if ( GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders )
2293 mFolderTree->nextUnreadFolder(
true);
2295 void KMMainWidget::slotNextImportantMessage() {
2298 void KMMainWidget::slotPrevMessage() { mHeaders->prevMessage(); }
2299 void KMMainWidget::slotPrevUnreadMessage()
2301 if ( !mHeaders->prevUnreadMessage() )
2302 if ( GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders )
2303 mFolderTree->prevUnreadFolder();
2305 void KMMainWidget::slotPrevImportantMessage() {
2309 void KMMainWidget::slotDisplayCurrentMessage()
2311 if ( mHeaders->currentMsg() )
2312 slotMsgActivated( mHeaders->currentMsg() );
2316 void KMMainWidget::slotMsgActivated(
KMMessage *msg)
2320 FolderJob *job = msg->parent()->createJob( msg );
2321 connect( job, TQT_SIGNAL( messageRetrieved(
KMMessage* ) ),
2322 TQT_SLOT( slotMsgActivated(
KMMessage* ) ) );
2327 if (kmkernel->folderIsDraftOrOutbox( mFolder ) ) {
2328 mMsgActions->editCurrentMessage();
2331 if ( kmkernel->folderIsTemplates( mFolder ) ) {
2337 KMReaderMainWin *win =
new KMReaderMainWin( mFolderHtmlPref, mFolderHtmlLoadExtPref );
2338 TDEConfigGroup reader( KMKernel::config(),
"Reader" );
2339 bool useFixedFont = mMsgView ? mMsgView->isFixedFont()
2340 : reader.readBoolEntry(
"useFixedFont",
false );
2341 win->setUseFixedFont( useFixedFont );
2343 newMessage->setParent( msg->parent() );
2346 win->showMsg( overrideEncoding(), newMessage );
2351 void KMMainWidget::slotMarkAll()
2353 mHeaders->selectAll(
true );
2357 void KMMainWidget::slotMsgPopup(
KMMessage&,
const KURL &aUrl,
const TQPoint& aPoint)
2359 TDEPopupMenu * menu =
new TDEPopupMenu;
2360 updateMessageMenu();
2363 bool urlMenuAdded =
false;
2365 if (!aUrl.isEmpty())
2367 if (aUrl.protocol() ==
"mailto")
2370 mMsgView->mailToComposeAction()->plug( menu );
2371 mMsgView->mailToReplyAction()->plug( menu );
2372 mMsgView->mailToForwardAction()->plug( menu );
2374 menu->insertSeparator();
2375 mMsgView->addAddrBookAction()->plug( menu );
2376 mMsgView->openAddrBookAction()->plug( menu );
2377 mMsgView->copyURLAction()->plug( menu );
2378 mMsgView->startImChatAction()->plug( menu );
2380 mMsgView->startImChatAction()->setEnabled( kmkernel->imProxy()->initialize() );
2384 mMsgView->urlOpenAction()->plug( menu );
2385 mMsgView->addBookmarksAction()->plug( menu );
2386 mMsgView->urlSaveAsAction()->plug( menu );
2387 mMsgView->copyURLAction()->plug( menu );
2389 if ( aUrl.protocol() ==
"im" )
2394 mMsgView->startImChatAction()->plug( menu );
2398 kdDebug( 0 ) << k_funcinfo <<
" URL is: " << aUrl << endl;
2402 if(mMsgView && !mMsgView->copyText().isEmpty()) {
2404 menu->insertSeparator();
2405 mMsgActions->replyMenu()->plug(menu);
2406 menu->insertSeparator();
2408 mMsgView->copyAction()->plug( menu );
2409 mMsgView->selectAllAction()->plug( menu );
2410 }
else if ( !urlMenuAdded )
2414 if (!mHeaders->currentMsg())
2421 if ( mFolder->isTemplates() ) {
2422 mUseAction->plug( menu );
2424 mMsgActions->replyMenu()->plug( menu );
2425 mForwardActionMenu->plug( menu );
2427 editAction()->plug(menu);
2428 menu->insertSeparator();
2430 mCopyActionMenu->plug( menu );
2431 mMoveActionMenu->plug( menu );
2433 menu->insertSeparator();
2435 mMsgActions->messageStatusMenu()->plug( menu );
2436 menu->insertSeparator();
2438 viewSourceAction()->plug(menu);
2440 mMsgView->toggleFixFontAction()->plug(menu);
2442 menu->insertSeparator();
2443 mPrintAction->plug( menu );
2444 mSaveAsAction->plug( menu );
2445 mSaveAttachmentsAction->plug( menu );
2447 menu->insertSeparator();
2448 if( mFolder->isTrash() )
2449 mDeleteAction->plug( menu );
2451 mTrashAction->plug( menu );
2453 menu->insertSeparator();
2454 mMsgActions->createTodoAction()->plug( menu );
2456 TDEAcceleratorManager::manage(menu);
2457 menu->exec(aPoint, 0);
2462 void KMMainWidget::getAccountMenu()
2464 TQStringList actList;
2467 actList = kmkernel->acctMgr()->getAccounts();
2468 TQStringList::Iterator it;
2470 for(it = actList.begin(); it != actList.end() ; ++it,
id++)
2471 mActMenu->insertItem((*it).replace(
"&",
"&&"), id);
2475 void KMMainWidget::getTransportMenu()
2477 TQStringList availTransports;
2481 TQStringList::Iterator it;
2483 for(it = availTransports.begin(); it != availTransports.end() ; ++it,
id++)
2484 mSendMenu->insertItem((*it).replace(
"&",
"&&"), id);
2488 void KMMainWidget::updateCustomTemplateMenus()
2490 if ( !mCustomTemplateActions.isEmpty() ) {
2491 TQPtrList<TDEAction>::iterator ait = mCustomTemplateActions.begin();
2492 for ( ; ait != mCustomTemplateActions.end() ; ++ait ) {
2493 (*ait)->unplugAll();
2496 mCustomTemplateActions.clear();
2499 delete mCustomReplyActionMenu;
2500 delete mCustomReplyAllActionMenu;
2501 delete mCustomForwardActionMenu;
2503 delete mCustomReplyMapper;
2504 delete mCustomReplyAllMapper;
2505 delete mCustomForwardMapper;
2507 mCustomForwardActionMenu =
2508 new TDEActionMenu( i18n(
"Forward With Custom Template"),
2509 "mail_custom_forward",
2510 actionCollection(),
"custom_forward" );
2511 TQSignalMapper *mCustomForwardMapper =
new TQSignalMapper( TQT_TQOBJECT(
this) );
2512 connect( mCustomForwardMapper, TQT_SIGNAL( mapped(
int ) ),
2513 TQT_TQOBJECT(
this), TQT_SLOT( slotCustomForwardMsg(
int ) ) );
2514 mForwardActionMenu->insert( mCustomForwardActionMenu );
2516 mCustomReplyActionMenu =
2517 new TDEActionMenu( i18n(
"Reply With Custom Template"),
"mail_custom_reply",
2518 actionCollection(),
"custom_reply" );
2519 TQSignalMapper *mCustomReplyMapper =
new TQSignalMapper( TQT_TQOBJECT(
this) );
2520 connect( mCustomReplyMapper, TQT_SIGNAL( mapped(
int ) ),
2521 TQT_TQOBJECT(
this), TQT_SLOT( slotCustomReplyToMsg(
int ) ) );
2522 mMsgActions->replyMenu()->insert( mCustomReplyActionMenu );
2524 mCustomReplyAllActionMenu =
2525 new TDEActionMenu( i18n(
"Reply to All With Custom Template"),
2526 "mail_custom_reply_all",
2527 actionCollection(),
"custom_reply_all" );
2528 TQSignalMapper *mCustomReplyAllMapper =
new TQSignalMapper( TQT_TQOBJECT(
this) );
2529 connect( mCustomReplyAllMapper, TQT_SIGNAL( mapped(
int ) ),
2530 TQT_TQOBJECT(
this), TQT_SLOT( slotCustomReplyAllToMsg(
int ) ) );
2531 mMsgActions->replyMenu()->insert( mCustomReplyAllActionMenu );
2533 mCustomTemplates.clear();
2535 TQStringList list = GlobalSettingsBase::self()->customTemplates();
2536 TQStringList::iterator it = list.begin();
2541 for ( ; it != list.end(); ++it ) {
2542 CTemplates t( *it );
2543 mCustomTemplates.append( *it );
2546 switch ( t.type() ) {
2547 case CustomTemplates::TReply:
2548 action =
new TDEAction( (*it).replace(
"&",
"&&" ),
2549 TDEShortcut( t.shortcut() ),
2554 mCustomReplyMapper->setMapping( action, idx );
2555 mCustomReplyActionMenu->insert( action, idx );
2556 mCustomTemplateActions.append( action );
2559 case CustomTemplates::TReplyAll:
2560 action =
new TDEAction( (*it).replace(
"&",
"&&" ),
2561 TDEShortcut( t.shortcut() ),
2562 mCustomReplyAllMapper,
2566 mCustomReplyAllMapper->setMapping( action, idx );
2567 mCustomReplyAllActionMenu->insert( action, idx );
2568 mCustomTemplateActions.append( action );
2571 case CustomTemplates::TForward:
2572 action =
new TDEAction( (*it).replace(
"&",
"&&" ),
2573 TDEShortcut( t.shortcut() ),
2574 mCustomForwardMapper,
2578 mCustomForwardMapper->setMapping( action, idx );
2579 mCustomForwardActionMenu->insert( action, idx );
2580 mCustomTemplateActions.append( action );
2583 case CustomTemplates::TUniversal:
2584 action =
new TDEAction( (*it).replace(
"&",
"&&" ),
2585 TDEShortcut::null(),
2590 mCustomReplyMapper->setMapping( action, idx );
2591 mCustomReplyActionMenu->insert( action, idx );
2592 mCustomTemplateActions.append( action );
2594 action =
new TDEAction( (*it).replace(
"&",
"&&" ),
2595 TDEShortcut::null(),
2596 mCustomReplyAllMapper,
2600 mCustomReplyAllMapper->setMapping( action, idx );
2601 mCustomReplyAllActionMenu->insert( action, idx );
2602 mCustomTemplateActions.append( action );
2604 action =
new TDEAction( (*it).replace(
"&",
"&&" ),
2605 TDEShortcut::null(),
2606 mCustomForwardMapper,
2610 mCustomForwardMapper->setMapping( action, idx );
2611 mCustomForwardActionMenu->insert( action, idx );
2612 mCustomTemplateActions.append( action );
2620 mCustomReplyActionMenu->popupMenu()->insertItem( i18n(
"(no custom templates)" ), 0 );
2621 mCustomReplyActionMenu->popupMenu()->setItemEnabled( 0,
false );
2622 mCustomReplyActionMenu->setEnabled(
false);
2625 mCustomReplyAllActionMenu->popupMenu()->insertItem( i18n(
"(no custom templates)" ), 0 );
2626 mCustomReplyAllActionMenu->popupMenu()->setItemEnabled( 0,
false );
2627 mCustomReplyAllActionMenu->setEnabled(
false);
2630 mCustomForwardActionMenu->popupMenu()->insertItem( i18n(
"(no custom templates)" ), 0 );
2631 mCustomForwardActionMenu->popupMenu()->setItemEnabled( 0,
false );
2632 mCustomForwardActionMenu->setEnabled(
false);
2639 void KMMainWidget::setupActions()
2642 mMsgActions->setMessageView( mMsgView );
2645 mSaveAsAction =
new TDEAction( i18n(
"Save &As..."),
"document-save",
2646 TDEStdAccel::shortcut(TDEStdAccel::Save),
2647 TQT_TQOBJECT(
this), TQT_SLOT(slotSaveMsg()), actionCollection(),
"file_save_as" );
2649 mOpenAction = KStdAction::open( TQT_TQOBJECT(
this), TQT_SLOT( slotOpenMsg() ),
2650 actionCollection() );
2652 (void)
new TDEAction( i18n(
"&Compact All Folders"), 0,
2653 TQT_TQOBJECT(
this), TQT_SLOT(slotCompactAll()),
2654 actionCollection(),
"compact_all_folders" );
2656 (void)
new TDEAction( i18n(
"&Expire All Folders"), 0,
2657 TQT_TQOBJECT(
this), TQT_SLOT(slotExpireAll()),
2658 actionCollection(),
"expire_all_folders" );
2660 (void)
new TDEAction( i18n(
"&Refresh Local IMAP Cache"),
"refresh",
2661 TQT_TQOBJECT(
this), TQT_SLOT(slotInvalidateIMAPFolders()),
2662 actionCollection(),
"file_invalidate_imap_cache" );
2664 (void)
new TDEAction( i18n(
"Empty All &Trash Folders"), 0,
2666 actionCollection(),
"empty_trash" );
2668 (void)
new TDEAction( i18n(
"Check &Mail"),
"mail_get", CTRL+Key_L,
2669 TQT_TQOBJECT(
this), TQT_SLOT(slotCheckMail()),
2670 actionCollection(),
"check_mail" );
2672 mFavoritesCheckMailAction =
new TDEAction( i18n(
"Check Mail in Favorite Folders"),
2673 "mail_get", CTRL+SHIFT+Key_L, 0, 0,
2674 actionCollection(),
"favorite_check_mail" );
2675 if ( mFavoriteFolderView )
2676 connect( mFavoritesCheckMailAction, TQT_SIGNAL(activated()), mFavoriteFolderView, TQT_SLOT(checkMail()) );
2678 TDEActionMenu *actActionMenu =
new
2679 TDEActionMenu( i18n(
"Check Mail &In"),
"mail_get", actionCollection(),
2681 actActionMenu->setDelayed(
true);
2683 connect(actActionMenu,TQT_SIGNAL(activated()),
this,TQT_SLOT(slotCheckMail()));
2685 mActMenu = actActionMenu->popupMenu();
2686 connect(mActMenu,TQT_SIGNAL(activated(
int)),
this,TQT_SLOT(slotCheckOneAccount(
int)));
2687 connect(mActMenu,TQT_SIGNAL(aboutToShow()),
this,TQT_SLOT(getAccountMenu()));
2689 (void)
new TDEAction( i18n(
"&Send Queued Messages"),
"mail-send", 0, TQT_TQOBJECT(
this),
2690 TQT_SLOT(slotSendQueued()), actionCollection(),
"send_queued");
2692 (void)
new TDEAction( i18n(
"Online Status (unknown)"),
"online_status", 0, TQT_TQOBJECT(
this),
2693 TQT_SLOT(slotOnlineStatus()), actionCollection(),
"online_status");
2695 TDEActionMenu *sendActionMenu =
new
2696 TDEActionMenu( i18n(
"Send Queued Messages Via"),
"mail_send_via", actionCollection(),
2697 "send_queued_via" );
2698 sendActionMenu->setDelayed(
true);
2700 mSendMenu = sendActionMenu->popupMenu();
2701 connect(mSendMenu,TQT_SIGNAL(activated(
int)), TQT_TQOBJECT(
this), TQT_SLOT(slotSendQueuedVia(
int)));
2702 connect(mSendMenu,TQT_SIGNAL(aboutToShow()),
this,TQT_SLOT(getTransportMenu()));
2706 if (parent()->inherits(
"KMMainWin")) {
2707 act =
new TDEAction( i18n(
"&Address Book..."),
"contents", 0, TQT_TQOBJECT(
this),
2708 TQT_SLOT(slotAddrBook()), actionCollection(),
"addressbook" );
2709 if (TDEStandardDirs::findExe(
"kaddressbook").isEmpty()) act->setEnabled(
false);
2712 act =
new TDEAction( i18n(
"Certificate Manager..."),
"pgp-keys", 0, TQT_TQOBJECT(
this),
2713 TQT_SLOT(slotStartCertManager()), actionCollection(),
"tools_start_certman");
2715 if (TDEStandardDirs::findExe(
"kleopatra").isEmpty()) act->setEnabled(
false);
2717 act =
new TDEAction( i18n(
"GnuPG Log Viewer..."),
"pgp-keys", 0, TQT_TQOBJECT(
this),
2718 TQT_SLOT(slotStartWatchGnuPG()), actionCollection(),
"tools_start_kwatchgnupg");
2720 if (TDEStandardDirs::findExe(
"kwatchgnupg").isEmpty()) act->setEnabled(
false);
2722 act =
new TDEAction( i18n(
"&Import Messages..."),
"document-open", 0, TQT_TQOBJECT(
this),
2723 TQT_SLOT(slotImport()), actionCollection(),
"import" );
2724 if (TDEStandardDirs::findExe(
"kmailcvt").isEmpty()) act->setEnabled(
false);
2726 #if !defined(NDEBUG)
2727 (void)
new TDEAction( i18n(
"&Debug Sieve..."),
2728 "idea", 0, TQT_TQOBJECT(
this), TQT_SLOT(slotDebugSieve()),
2729 actionCollection(),
"tools_debug_sieve" );
2732 if ( GlobalSettings::allowOutOfOfficeSettings() ) {
2733 (void)
new TDEAction( i18n(
"Edit \"Out of Office\" Replies..."),
2734 "configure", 0, TQT_TQOBJECT(
this), TQT_SLOT(slotEditVacation()),
2735 actionCollection(),
"tools_edit_vacation" );
2739 (void)
new TDEAction( i18n(
"Filter &Log Viewer..."), 0, TQT_TQOBJECT(
this),
2740 TQT_SLOT(slotFilterLogViewer()), actionCollection(),
"filter_log_viewer" );
2742 (void)
new TDEAction( i18n(
"&Anti-Spam Wizard..."), 0, TQT_TQOBJECT(
this),
2743 TQT_SLOT(slotAntiSpamWizard()), actionCollection(),
"antiSpamWizard" );
2744 (void)
new TDEAction( i18n(
"&Anti-Virus Wizard..."), 0, TQT_TQOBJECT(
this),
2745 TQT_SLOT(slotAntiVirusWizard()), actionCollection(),
"antiVirusWizard" );
2748 mTrashAction =
new TDEAction( KGuiItem( i18n(
"&Move to Trash"),
"edittrash",
2749 i18n(
"Move message to trashcan") ),
2750 Key_Delete, TQT_TQOBJECT(
this), TQT_SLOT(slotTrashMsg()),
2751 actionCollection(),
"move_to_trash" );
2757 mDeleteAction =
new TDEAction( i18n(
"&Delete"),
"edit-delete", SHIFT+Key_Delete, TQT_TQOBJECT(
this),
2758 TQT_SLOT(slotDeleteMsg()), actionCollection(),
"delete" );
2759 mDeleteAction->plugAccel( actionCollection()->tdeaccel() );
2761 mTrashThreadAction =
new TDEAction( KGuiItem( i18n(
"M&ove Thread to Trash"),
"edittrash",
2762 i18n(
"Move thread to trashcan") ),
2763 CTRL+Key_Delete, TQT_TQOBJECT(
this), TQT_SLOT(slotTrashThread()),
2764 actionCollection(),
"move_thread_to_trash" );
2766 mDeleteThreadAction =
new TDEAction( i18n(
"Delete T&hread"),
"edit-delete", CTRL+SHIFT+Key_Delete, TQT_TQOBJECT(
this),
2767 TQT_SLOT(slotDeleteThread()), actionCollection(),
"delete_thread" );
2770 (void)
new TDEAction( i18n(
"&Find Messages..."),
"mail_find", Key_S, TQT_TQOBJECT(
this),
2771 TQT_SLOT(slotRequestFullSearchFromQuickSearch()), actionCollection(),
"search_messages" );
2773 mFindInMessageAction =
new TDEAction( i18n(
"&Find in Message..."),
"edit-find", TDEStdAccel::shortcut(TDEStdAccel::Find), TQT_TQOBJECT(
this),
2774 TQT_SLOT(slotFind()), actionCollection(),
"find_in_messages" );
2776 (void)
new TDEAction( i18n(
"Select &All Messages"), TDEStdAccel::selectAll(), TQT_TQOBJECT(
this),
2777 TQT_SLOT(slotMarkAll()), actionCollection(),
"mark_all_messages" );
2780 mNewFolderAction =
new TDEAction( i18n(
"&New Folder..."),
"folder-new", 0, TQT_TQOBJECT(mFolderTree),
2781 TQT_SLOT(addChildFolder()), actionCollection(),
"new_folder" );
2783 mModifyFolderAction =
new TDEAction( i18n(
"&Properties"),
"configure", 0, TQT_TQOBJECT(
this),
2784 TQT_SLOT(slotModifyFolder()), actionCollection(),
"modify" );
2786 mFolderMailingListPropertiesAction =
new TDEAction( i18n(
"&Mailing List Management..."),
2787 0, TQT_TQOBJECT(
this), TQT_SLOT( slotFolderMailingListProperties() ),
2788 actionCollection(),
"folder_mailinglist_properties" );
2790 mFolderShortCutCommandAction =
new TDEAction( i18n(
"&Assign Shortcut..."),
"configure_shortcuts",
2791 0, TQT_TQOBJECT(
this), TQT_SLOT( slotFolderShortcutCommand() ), actionCollection(),
2792 "folder_shortcut_command" );
2795 mMarkAllAsReadAction =
new TDEAction( i18n(
"Mark All Messages as &Read"),
"goto", 0, TQT_TQOBJECT(
this),
2796 TQT_SLOT(slotMarkAllAsRead()), actionCollection(),
"mark_all_as_read" );
2798 mExpireFolderAction =
new TDEAction(i18n(
"&Expiration Settings"), 0, TQT_TQOBJECT(
this), TQT_SLOT(slotExpireFolder()),
2799 actionCollection(),
"expire");
2801 mCompactFolderAction =
new TDEAction( i18n(
"&Compact Folder"), 0, TQT_TQOBJECT(
this),
2802 TQT_SLOT(slotCompactFolder()), actionCollection(),
"compact" );
2804 mRefreshFolderAction =
new TDEAction( i18n(
"Check Mail &in This Folder"),
"reload",
2805 TDEStdAccel::shortcut( TDEStdAccel::Reload ), TQT_TQOBJECT(
this),
2806 TQT_SLOT(slotRefreshFolder()),
2807 actionCollection(),
"refresh_folder" );
2808 mTroubleshootFolderAction = 0;
2810 mEmptyFolderAction =
new TDEAction(
"foo" ,
"edittrash", 0, TQT_TQOBJECT(
this),
2811 TQT_SLOT(slotEmptyFolder()), actionCollection(),
"empty" );
2813 mRemoveFolderAction =
new TDEAction(
"foo" ,
"edit-delete", 0, TQT_TQOBJECT(
this),
2814 TQT_SLOT(slotRemoveFolder()), actionCollection(),
"delete_folder" );
2816 mArchiveFolderAction =
new TDEAction( i18n(
"&Archive Folder..." ),
"document-save", 0, TQT_TQOBJECT(
this),
2817 TQT_SLOT( slotArchiveFolder() ), actionCollection(),
2820 mPreferHtmlAction =
new TDEToggleAction( i18n(
"Prefer &HTML to Plain Text"), 0, TQT_TQOBJECT(
this),
2821 TQT_SLOT(slotOverrideHtml()), actionCollection(),
"prefer_html" );
2823 mPreferHtmlLoadExtAction =
new TDEToggleAction( i18n(
"Load E&xternal References"), 0, TQT_TQOBJECT(
this),
2824 TQT_SLOT(slotOverrideHtmlLoadExt()), actionCollection(),
"prefer_html_external_refs" );
2826 mThreadMessagesAction =
new TDEToggleAction( i18n(
"&Thread Messages"), 0, TQT_TQOBJECT(
this),
2827 TQT_SLOT(slotOverrideThread()), actionCollection(),
"thread_messages" );
2829 mThreadBySubjectAction =
new TDEToggleAction( i18n(
"Thread Messages also by &Subject"), 0, TQT_TQOBJECT(
this),
2830 TQT_SLOT(slotToggleSubjectThreading()), actionCollection(),
"thread_messages_by_subject" );
2832 new TDEAction( i18n(
"Copy Folder"),
"edit-copy", SHIFT+CTRL+Key_C, TQT_TQOBJECT(folderTree()),
2833 TQT_SLOT(copyFolder()), actionCollection(),
"copy_folder" );
2834 new TDEAction( i18n(
"Cut Folder"),
"edit-cut", SHIFT+CTRL+Key_X, TQT_TQOBJECT(folderTree()),
2835 TQT_SLOT(cutFolder()), actionCollection(),
"cut_folder" );
2836 new TDEAction( i18n(
"Paste Folder"),
"edit-paste", SHIFT+CTRL+Key_V, TQT_TQOBJECT(folderTree()),
2837 TQT_SLOT(pasteFolder()), actionCollection(),
"paste_folder" );
2839 new TDEAction( i18n(
"Copy Messages"),
"edit-copy", ALT+CTRL+Key_C, TQT_TQOBJECT(headers()),
2840 TQT_SLOT(copyMessages()), actionCollection(),
"copy_messages" );
2841 new TDEAction( i18n(
"Cut Messages"),
"edit-cut", ALT+CTRL+Key_X, TQT_TQOBJECT(headers()),
2842 TQT_SLOT(cutMessages()), actionCollection(),
"cut_messages" );
2843 new TDEAction( i18n(
"Paste Messages"),
"edit-paste", ALT+CTRL+Key_V, TQT_TQOBJECT(headers()),
2844 TQT_SLOT(pasteMessages()), actionCollection(),
"paste_messages" );
2847 (void)
new TDEAction( i18n(
"&New Message..."),
"mail-message-new", TDEStdAccel::shortcut(TDEStdAccel::New), TQT_TQOBJECT(
this),
2848 TQT_SLOT(slotCompose()), actionCollection(),
"new_message" );
2850 new TDEActionMenu( i18n(
"New Message From &Template"),
"document-new",
2851 actionCollection(),
"new_from_template" );
2852 mTemplateMenu->setDelayed(
true );
2853 connect( mTemplateMenu->popupMenu(), TQT_SIGNAL( aboutToShow() ), TQT_TQOBJECT(
this),
2854 TQT_SLOT( slotShowNewFromTemplate() ) );
2855 connect( mTemplateMenu->popupMenu(), TQT_SIGNAL( activated(
int) ), TQT_TQOBJECT(
this),
2856 TQT_SLOT( slotNewFromTemplate(
int) ) );
2858 TDEAction* newToML =
new TDEAction( i18n(
"New Message t&o Mailing-List..."),
"mail_post_to",
2859 CTRL+SHIFT+Key_N, TQT_TQOBJECT(
this),
2860 TQT_SLOT(slotPostToML()), actionCollection(),
"post_message" );
2861 newToML->plugAccel( actionCollection()->tdeaccel() );
2863 mForwardActionMenu =
new TDEActionMenu( i18n(
"Message->",
"&Forward"),
2864 "mail-forward", actionCollection(),
2865 "message_forward" );
2867 mForwardInlineAction =
new TDEAction( i18n(
"&Inline..."),
2868 "mail-forward", 0, TQT_TQOBJECT(
this),
2869 TQT_SLOT(slotForwardInlineMsg()),
2871 "message_forward_inline" );
2873 mForwardAttachedAction =
new TDEAction( i18n(
"Message->Forward->",
"As &Attachment..."),
2874 "mail-forward", 0, TQT_TQOBJECT(
this),
2875 TQT_SLOT(slotForwardAttachedMsg()),
2877 "message_forward_as_attachment" );
2879 mForwardDigestAction =
new TDEAction( i18n(
"Message->Forward->",
"As Di&gest..."),
2880 "mail-forward", 0, TQT_TQOBJECT(
this),
2881 TQT_SLOT(slotForwardDigestMsg()),
2883 "message_forward_as_digest" );
2885 mRedirectAction =
new TDEAction( i18n(
"Message->Forward->",
"&Redirect..."),
2886 "mail-forward", Key_E, TQT_TQOBJECT(
this),
2887 TQT_SLOT(slotRedirectMsg()),
2889 "message_forward_redirect" );
2892 setupForwardActions();
2894 mForwardActionMenu->insert( mForwardDigestAction );
2895 mForwardActionMenu->insert( mRedirectAction );
2897 mSendAgainAction =
new TDEAction( i18n(
"Send A&gain..."), 0, TQT_TQOBJECT(
this),
2898 TQT_SLOT(slotResendMsg()), actionCollection(),
"send_again" );
2902 mFilterMenu =
new TDEActionMenu( i18n(
"&Create Filter"),
"filter", actionCollection(),
"create_filter" );
2903 connect( mFilterMenu, TQT_SIGNAL(activated()), TQT_TQOBJECT(
this),
2904 TQT_SLOT(slotFilter()) );
2905 mSubjectFilterAction =
new TDEAction( i18n(
"Filter on &Subject..."), 0, TQT_TQOBJECT(
this),
2906 TQT_SLOT(slotSubjectFilter()),
2907 actionCollection(),
"subject_filter");
2908 mFilterMenu->insert( mSubjectFilterAction );
2910 mFromFilterAction =
new TDEAction( i18n(
"Filter on &From..."), 0, TQT_TQOBJECT(
this),
2911 TQT_SLOT(slotFromFilter()),
2912 actionCollection(),
"from_filter");
2913 mFilterMenu->insert( mFromFilterAction );
2915 mToFilterAction =
new TDEAction( i18n(
"Filter on &To..."), 0, TQT_TQOBJECT(
this),
2916 TQT_SLOT(slotToFilter()),
2917 actionCollection(),
"to_filter");
2918 mFilterMenu->insert( mToFilterAction );
2920 mListFilterAction =
new TDEAction( i18n(
"Filter on Mailing-&List..."), 0, TQT_TQOBJECT(
this),
2921 TQT_SLOT(slotMailingListFilter()), actionCollection(),
2923 mFilterMenu->insert( mListFilterAction );
2925 mPrintAction = KStdAction::print (TQT_TQOBJECT(
this), TQT_SLOT(slotPrintMsg()), actionCollection());
2927 mUseAction =
new TDEAction( i18n(
"New Message From &Template"),
"document-new",
2928 Key_N, TQT_TQOBJECT(
this), TQT_SLOT( slotUseTemplate() ),
2929 actionCollection(),
"use_template" );
2930 mUseAction->plugAccel( actionCollection()->tdeaccel() );
2933 mThreadStatusMenu =
new TDEActionMenu ( i18n(
"Mark &Thread" ),
2934 actionCollection(),
"thread_status" );
2936 mMarkThreadAsReadAction =
new TDEAction(KGuiItem(i18n(
"Mark Thread as &Read"),
"kmmsgread",
2937 i18n(
"Mark all messages in the selected thread as read")),
2938 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSetThreadStatusRead()),
2939 actionCollection(),
"thread_read");
2940 mThreadStatusMenu->insert( mMarkThreadAsReadAction );
2942 mMarkThreadAsNewAction =
new TDEAction(KGuiItem(i18n(
"Mark Thread as &New"),
"kmmsgnew",
2943 i18n(
"Mark all messages in the selected thread as new")),
2944 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSetThreadStatusNew()),
2945 actionCollection(),
"thread_new");
2946 mThreadStatusMenu->insert( mMarkThreadAsNewAction );
2948 mMarkThreadAsUnreadAction =
new TDEAction(KGuiItem(i18n(
"Mark Thread as &Unread"),
"kmmsgunseen",
2949 i18n(
"Mark all messages in the selected thread as unread")),
2950 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSetThreadStatusUnread()),
2951 actionCollection(),
"thread_unread");
2952 mThreadStatusMenu->insert( mMarkThreadAsUnreadAction );
2954 mThreadStatusMenu->insert(
new TDEActionSeparator( TQT_TQOBJECT(
this) ) );
2957 mToggleThreadFlagAction =
new TDEToggleAction(i18n(
"Mark Thread as &Important"),
"mail_flag",
2958 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSetThreadStatusFlag()),
2959 actionCollection(),
"thread_flag");
2960 mToggleThreadFlagAction->setCheckedState( i18n(
"Remove &Important Thread Mark") );
2961 mThreadStatusMenu->insert( mToggleThreadFlagAction );
2963 mToggleThreadTodoAction =
new TDEToggleAction(i18n(
"Mark Thread as &Action Item"),
"mail_todo",
2964 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSetThreadStatusTodo()),
2965 actionCollection(),
"thread_todo");
2966 mToggleThreadTodoAction->setCheckedState( i18n(
"Remove &Action Item Thread Mark") );
2967 mThreadStatusMenu->insert( mToggleThreadTodoAction );
2970 mWatchThreadAction =
new TDEToggleAction(i18n(
"&Watch Thread"),
"kmmsgwatched",
2971 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSetThreadStatusWatched()),
2972 actionCollection(),
"thread_watched");
2974 mIgnoreThreadAction =
new TDEToggleAction(i18n(
"&Ignore Thread"),
"mail_ignore",
2975 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSetThreadStatusIgnored()),
2976 actionCollection(),
"thread_ignored");
2978 mThreadStatusMenu->insert(
new TDEActionSeparator( TQT_TQOBJECT(
this) ) );
2979 mThreadStatusMenu->insert( mWatchThreadAction );
2980 mThreadStatusMenu->insert( mIgnoreThreadAction );
2982 mSaveAttachmentsAction =
new TDEAction( i18n(
"Save A&ttachments..."),
"attach",
2983 0, TQT_TQOBJECT(
this), TQT_SLOT(slotSaveAttachments()),
2984 actionCollection(),
"file_save_attachments" );
2986 mMoveActionMenu =
new TDEActionMenu( i18n(
"&Move To" ),
2987 actionCollection(),
"move_to" );
2989 mCopyActionMenu =
new TDEActionMenu( i18n(
"&Copy To" ),
2990 actionCollection(),
"copy_to" );
2992 mApplyAllFiltersAction =
new TDEAction( i18n(
"Appl&y All Filters"),
"filter",
2993 CTRL+Key_J, TQT_TQOBJECT(
this),
2994 TQT_SLOT(slotApplyFilters()),
2995 actionCollection(),
"apply_filters" );
2997 mApplyFilterActionsMenu =
new TDEActionMenu( i18n(
"A&pply Filter" ),
2999 "apply_filter_actions" );
3003 TDEActionMenu * unreadMenu =
3004 new TDEActionMenu( i18n(
"View->",
"&Unread Count"),
3005 actionCollection(),
"view_unread" );
3006 unreadMenu->setToolTip( i18n(
"Choose how to display the count of unread messages") );
3008 mUnreadColumnToggle =
new TDERadioAction( i18n(
"View->Unread Count",
"View in &Separate Column"), 0, TQT_TQOBJECT(
this),
3009 TQT_SLOT(slotToggleUnread()),
3010 actionCollection(),
"view_unread_column" );
3011 mUnreadColumnToggle->setExclusiveGroup(
"view_unread_group" );
3012 unreadMenu->insert( mUnreadColumnToggle );
3014 mUnreadTextToggle =
new TDERadioAction( i18n(
"View->Unread Count",
"View After &Folder Name"), 0, TQT_TQOBJECT(
this),
3015 TQT_SLOT(slotToggleUnread()),
3016 actionCollection(),
"view_unread_text" );
3017 mUnreadTextToggle->setExclusiveGroup(
"view_unread_group" );
3018 unreadMenu->insert( mUnreadTextToggle );
3021 mTotalColumnToggle =
new TDEToggleAction( i18n(
"View->",
"&Total Column"), 0, TQT_TQOBJECT(
this),
3022 TQT_SLOT(slotToggleTotalColumn()),
3023 actionCollection(),
"view_columns_total" );
3024 mTotalColumnToggle->setToolTip( i18n(
"Toggle display of column showing the "
3025 "total number of messages in folders.") );
3026 mSizeColumnToggle =
new TDEToggleAction( i18n(
"View->",
"&Size Column"), 0, TQT_TQOBJECT(
this),
3027 TQT_SLOT(slotToggleSizeColumn()),
3028 actionCollection(),
"view_columns_size" );
3029 mSizeColumnToggle->setToolTip( i18n(
"Toggle display of column showing the "
3030 "total size of messages in folders.") );
3032 (void)
new TDEAction( KGuiItem( i18n(
"View->",
"&Expand Thread"), TQString(),
3033 i18n(
"Expand the current thread") ),
3034 Key_Period, TQT_TQOBJECT(
this),
3035 TQT_SLOT(slotExpandThread()),
3036 actionCollection(),
"expand_thread" );
3038 (void)
new TDEAction( KGuiItem( i18n(
"View->",
"&Collapse Thread"), TQString(),
3039 i18n(
"Collapse the current thread") ),
3040 Key_Comma, TQT_TQOBJECT(
this),
3041 TQT_SLOT(slotCollapseThread()),
3042 actionCollection(),
"collapse_thread" );
3044 (void)
new TDEAction( KGuiItem( i18n(
"View->",
"Ex&pand All Threads"), TQString(),
3045 i18n(
"Expand all threads in the current folder") ),
3046 CTRL+Key_Period, TQT_TQOBJECT(
this),
3047 TQT_SLOT(slotExpandAllThreads()),
3048 actionCollection(),
"expand_all_threads" );
3050 (void)
new TDEAction( KGuiItem( i18n(
"View->",
"C&ollapse All Threads"), TQString(),
3051 i18n(
"Collapse all threads in the current folder") ),
3052 CTRL+Key_Comma, TQT_TQOBJECT(
this),
3053 TQT_SLOT(slotCollapseAllThreads()),
3054 actionCollection(),
"collapse_all_threads" );
3056 mViewSourceAction =
new TDEAction( i18n(
"&View Source"), Key_V, TQT_TQOBJECT(
this),
3057 TQT_SLOT(slotShowMsgSrc()), actionCollection(),
3060 TDEAction* dukeOfMonmoth =
new TDEAction( i18n(
"&Display Message"), Key_Return, TQT_TQOBJECT(
this),
3061 TQT_SLOT( slotDisplayCurrentMessage() ), actionCollection(),
3062 "display_message" );
3063 dukeOfMonmoth->plugAccel( actionCollection()->tdeaccel() );
3066 new TDEAction( KGuiItem( i18n(
"&Next Message"), TQString(),
3067 i18n(
"Go to the next message") ),
3068 "N;Right", TQT_TQOBJECT(
this), TQT_SLOT(slotNextMessage()),
3069 actionCollection(),
"go_next_message" );
3071 new TDEAction( KGuiItem( i18n(
"Next &Unread Message"),
3072 TQApplication::reverseLayout() ?
"go-previous" :
"go-next",
3073 i18n(
"Go to the next unread message") ),
3074 Key_Plus, TQT_TQOBJECT(
this), TQT_SLOT(slotNextUnreadMessage()),
3075 actionCollection(),
"go_next_unread_message" );
3084 new TDEAction( KGuiItem( i18n(
"&Previous Message"), TQString(),
3085 i18n(
"Go to the previous message") ),
3086 "P;Left", TQT_TQOBJECT(
this), TQT_SLOT(slotPrevMessage()),
3087 actionCollection(),
"go_prev_message" );
3089 new TDEAction( KGuiItem( i18n(
"Previous Unread &Message"),
3090 TQApplication::reverseLayout() ?
"go-next" :
"go-previous",
3091 i18n(
"Go to the previous unread message") ),
3092 Key_Minus, TQT_TQOBJECT(
this), TQT_SLOT(slotPrevUnreadMessage()),
3093 actionCollection(),
"go_prev_unread_message" );
3103 new TDEAction( KGuiItem( i18n(
"Next Unread &Folder"), TQString(),
3104 i18n(
"Go to the next folder with unread messages") ),
3105 ALT+Key_Plus, TQT_TQOBJECT(
this), TQT_SLOT(slotNextUnreadFolder()),
3106 actionCollection(),
"go_next_unread_folder" );
3107 TDEShortcut shortcut = action->shortcut();
3108 shortcut.append( KKey( CTRL+Key_Plus ) );
3109 action->setShortcut( shortcut );
3112 new TDEAction( KGuiItem( i18n(
"Previous Unread F&older"), TQString(),
3113 i18n(
"Go to the previous folder with unread messages") ),
3114 ALT+Key_Minus, TQT_TQOBJECT(
this), TQT_SLOT(slotPrevUnreadFolder()),
3115 actionCollection(),
"go_prev_unread_folder" );
3116 shortcut = action->shortcut();
3117 shortcut.append( KKey( CTRL+Key_Minus ) );
3118 action->setShortcut( shortcut );
3120 new TDEAction( KGuiItem( i18n(
"Go->",
"Next Unread &Text"), TQString(),
3121 i18n(
"Go to the next unread text"),
3122 i18n(
"Scroll down current message. "
3123 "If at end of current message, "
3124 "go to next unread message.") ),
3125 Key_Space, TQT_TQOBJECT(
this), TQT_SLOT(slotReadOn()),
3126 actionCollection(),
"go_next_unread_text" );
3129 mToggleShowQuickSearchAction =
new TDEToggleAction(i18n(
"Show Quick Search"), TQString(),
3130 0, TQT_TQOBJECT(
this), TQT_SLOT(slotToggleShowQuickSearch()),
3131 actionCollection(),
"show_quick_search");
3132 mToggleShowQuickSearchAction->setChecked( GlobalSettings::self()->quickSearchActive() );
3133 mToggleShowQuickSearchAction->setWhatsThis(
3134 i18n( GlobalSettings::self()->quickSearchActiveItem()->whatsThis().utf8() ) );
3136 (void)
new TDEAction( i18n(
"Configure &Filters..."), 0, TQT_TQOBJECT(
this),
3137 TQT_SLOT(slotFilter()), actionCollection(),
"filter" );
3138 (void)
new TDEAction( i18n(
"Configure &POP Filters..."), 0, TQT_TQOBJECT(
this),
3139 TQT_SLOT(slotPopFilter()), actionCollection(),
"popFilter" );
3140 (void)
new TDEAction( i18n(
"Manage &Sieve Scripts..."), 0, TQT_TQOBJECT(
this),
3141 TQT_SLOT(slotManageSieveScripts()), actionCollection(),
"sieveFilters" );
3143 (void)
new TDEAction( KGuiItem( i18n(
"KMail &Introduction"), 0,
3144 i18n(
"Display KMail's Welcome Page") ),
3145 0, TQT_TQOBJECT(
this), TQT_SLOT(slotIntro()),
3146 actionCollection(),
"help_kmail_welcomepage" );
3150 (void)
new TDEAction( i18n(
"Configure &Notifications..."),
3151 "knotify", 0, TQT_TQOBJECT(
this),
3152 TQT_SLOT(slotEditNotifications()), actionCollection(),
3153 "kmail_configure_notifications" );
3155 (void)
new TDEAction( i18n(
"&Configure KMail..."),
3156 "configure", 0, kmkernel,
3157 TQT_SLOT(slotShowConfigurationDialog()), actionCollection(),
3158 "kmail_configure_kmail" );
3160 KStdAction::undo(TQT_TQOBJECT(
this), TQT_SLOT(slotUndo()), actionCollection(),
"kmail_undo");
3162 KStdAction::tipOfDay( TQT_TQOBJECT(
this), TQT_SLOT( slotShowTip() ), actionCollection() );
3164 menutimer =
new TQTimer(
this,
"menutimer" );
3165 connect( menutimer, TQT_SIGNAL( timeout() ), TQT_SLOT( updateMessageActions() ) );
3166 connect( kmkernel->undoStack(),
3167 TQT_SIGNAL( undoStackChanged() ), TQT_TQOBJECT(
this), TQT_SLOT( slotUpdateUndo() ));
3169 initializeIMAPActions(
false );
3170 updateMessageActions();
3171 updateCustomTemplateMenus();
3175 void KMMainWidget::setupForwardingActionsList()
3177 TQPtrList<TDEAction> mForwardActionList;
3178 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
3179 mGUIClient->unplugActionList(
"forward_action_list" );
3180 mForwardActionList.append( mForwardInlineAction );
3181 mForwardActionList.append( mForwardAttachedAction );
3182 mForwardActionList.append( mForwardDigestAction );
3183 mForwardActionList.append( mRedirectAction );
3184 mGUIClient->plugActionList(
"forward_action_list", mForwardActionList );
3186 mGUIClient->unplugActionList(
"forward_action_list" );
3187 mForwardActionList.append( mForwardAttachedAction );
3188 mForwardActionList.append( mForwardInlineAction );
3189 mForwardActionList.append( mForwardDigestAction );
3190 mForwardActionList.append( mRedirectAction );
3191 mGUIClient->plugActionList(
"forward_action_list", mForwardActionList );
3196 void KMMainWidget::slotEditNotifications()
3198 if(kmkernel->xmlGuiInstance())
3199 KNotifyDialog::configure(
this, 0, kmkernel->xmlGuiInstance()->aboutData());
3201 KNotifyDialog::configure(
this);
3204 void KMMainWidget::slotEditKeys()
3206 KKeyDialog::configure( actionCollection(),
3212 void KMMainWidget::slotReadOn()
3217 if ( !mMsgView->atBottom() ) {
3218 mMsgView->slotJumpDown();
3221 slotNextUnreadMessage();
3224 void KMMainWidget::slotNextUnreadFolder() {
3225 if ( !mFolderTree )
return;
3226 mFolderTree->nextUnreadFolder();
3229 void KMMainWidget::slotPrevUnreadFolder() {
3230 if ( !mFolderTree )
return;
3231 mFolderTree->prevUnreadFolder();
3234 void KMMainWidget::slotExpandThread()
3236 mHeaders->slotExpandOrCollapseThread(
true );
3239 void KMMainWidget::slotCollapseThread()
3241 mHeaders->slotExpandOrCollapseThread(
false );
3244 void KMMainWidget::slotExpandAllThreads()
3246 mHeaders->slotExpandOrCollapseAllThreads(
true );
3249 void KMMainWidget::slotCollapseAllThreads()
3251 mHeaders->slotExpandOrCollapseAllThreads(
false );
3255 void KMMainWidget::slotShowMsgSrc()
3258 mMsgView->setUpdateAttachment(
false );
3259 KMMessage *msg = mHeaders->currentMsg();
3262 KMCommand *command =
new KMShowMsgSrcCommand(
this, msg,
3264 ? mMsgView->isFixedFont()
3271 void KMMainWidget::moveSelectedToFolder(
int menuId )
3273 if (mMenuToFolder[menuId])
3274 mHeaders->moveMsgToFolder( mMenuToFolder[menuId] );
3279 void KMMainWidget::copySelectedToFolder(
int menuId )
3281 if (mMenuToFolder[menuId])
3282 mHeaders->copyMsgToFolder( mMenuToFolder[menuId] );
3287 void KMMainWidget::updateMessageMenu()
3289 mMenuToFolder.clear();
3290 folderTree()->folderToPopupMenu( KMFolderTree::MoveMessage, TQT_TQOBJECT(
this),
3291 &mMenuToFolder, mMoveActionMenu->popupMenu() );
3292 folderTree()->folderToPopupMenu( KMFolderTree::CopyMessage, TQT_TQOBJECT(
this),
3293 &mMenuToFolder, mCopyActionMenu->popupMenu() );
3294 updateMessageActions();
3297 void KMMainWidget::startUpdateMessageActionsTimer()
3300 menutimer->start( 20,
true );
3303 void KMMainWidget::updateMessageActions()
3306 TQPtrList<TQListViewItem> selectedItems;
3309 for (TQListViewItem *item = mHeaders->firstChild(); item; item = item->itemBelow())
3310 if (item->isSelected() )
3311 selectedItems.append(item);
3312 if ( selectedItems.isEmpty() && mFolder->count() )
3315 count = selectedItems.count();
3316 mMsgActions->setCurrentMessage( mHeaders->currentMsg() );
3317 mMsgActions->setSelectedSernums( mHeaders->selectedSernums() );
3318 mMsgActions->setSelectedVisibleSernums( mHeaders->selectedVisibleSernums() );
3320 mMsgActions->setCurrentMessage( 0 );
3323 updateListFilterAction();
3325 bool allSelectedInCommonThread =
false;
3326 if ( mHeaders->isThreaded() && count > 1 ) {
3327 allSelectedInCommonThread =
true;
3328 for ( TQPtrListIterator<TQListViewItem> it( selectedItems ) ;
3329 it.current() ; ++ it ) {
3330 TQListViewItem * item = *it;
3331 if ( item->parent()==0 && item->childCount()==0 ) {
3332 allSelectedInCommonThread =
false;
3337 else if ( mHeaders->isThreaded() && count == 1 ) {
3338 allSelectedInCommonThread =
true;
3341 TQListViewItem *curItemParent = mHeaders->currentItem();
3342 bool parent_thread = 0;
3343 if ( curItemParent && curItemParent->firstChild() != 0 ) parent_thread = 1;
3345 bool mass_actions = count >= 1;
3346 bool thread_actions = mass_actions && allSelectedInCommonThread &&
3347 mHeaders->isThreaded();
3348 bool flags_available = GlobalSettings::self()->allowLocalFlags() || !(mFolder ? mFolder->isReadOnly() :
true);
3349 mThreadStatusMenu->setEnabled( thread_actions );
3352 mWatchThreadAction->setEnabled( thread_actions && flags_available );
3353 mIgnoreThreadAction->setEnabled( thread_actions && flags_available );
3354 mMarkThreadAsNewAction->setEnabled( thread_actions );
3355 mMarkThreadAsReadAction->setEnabled( thread_actions );
3356 mMarkThreadAsUnreadAction->setEnabled( thread_actions );
3357 mToggleThreadTodoAction->setEnabled( thread_actions && flags_available );
3358 mToggleThreadFlagAction->setEnabled( thread_actions && flags_available );
3359 mTrashThreadAction->setEnabled( thread_actions && mFolder->canDeleteMessages() );
3360 mDeleteThreadAction->setEnabled( thread_actions && mFolder->canDeleteMessages() );
3362 if (mFolder && mHeaders && mHeaders->currentMsg()) {
3363 if (thread_actions) {
3364 mToggleThreadTodoAction->setChecked(mHeaders->currentMsg()->isTodo());
3365 mToggleThreadFlagAction->setChecked(mHeaders->currentMsg()->isImportant());
3366 mWatchThreadAction->setChecked( mHeaders->currentMsg()->isWatched());
3367 mIgnoreThreadAction->setChecked( mHeaders->currentMsg()->isIgnored());
3371 mMoveActionMenu->setEnabled( mass_actions && mFolder->canDeleteMessages() );
3372 mMoveMsgToFolderAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
3373 mCopyActionMenu->setEnabled( mass_actions );
3374 mTrashAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
3375 mDeleteAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
3376 mFindInMessageAction->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ) );
3377 mForwardInlineAction->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ));
3378 mForwardAttachedAction->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ) );
3379 mForwardDigestAction->setEnabled( ( count > 1 || parent_thread ) && !kmkernel->folderIsTemplates( mFolder ) );
3381 forwardMenu()->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ));
3383 bool single_actions = count == 1;
3384 mUseAction->setEnabled( single_actions &&
3385 kmkernel->folderIsTemplates( mFolder ) );
3386 filterMenu()->setEnabled( single_actions );
3387 redirectAction()->setEnabled( single_actions && !kmkernel->folderIsTemplates( mFolder ) );
3388 printAction()->setEnabled( single_actions );
3389 viewSourceAction()->setEnabled( single_actions );
3391 mSendAgainAction->setEnabled( single_actions
3392 && ( ( mHeaders->currentMsg() && mHeaders->currentMsg()->isSent() )
3393 || ( mFolder && mHeaders->currentMsg() &&
3394 kmkernel->folderIsSentMailFolder( mFolder ) ) ) );
3395 mSaveAsAction->setEnabled( mass_actions );
3396 bool mails = mFolder && mFolder->count();
3397 bool enable_goto_unread = mails
3398 || (GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders);
3399 actionCollection()->action(
"go_next_message" )->setEnabled( mails );
3400 actionCollection()->action(
"go_next_unread_message" )->setEnabled( enable_goto_unread );
3401 actionCollection()->action(
"go_prev_message" )->setEnabled( mails );
3402 actionCollection()->action(
"go_prev_unread_message" )->setEnabled( enable_goto_unread );
3403 actionCollection()->action(
"send_queued" )->setEnabled( kmkernel->outboxFolder()->count() > 0 );
3404 actionCollection()->action(
"send_queued_via" )->setEnabled( kmkernel->outboxFolder()->count() > 0 );
3405 slotUpdateOnlineStatus( static_cast<GlobalSettingsBase::EnumNetworkState::type>( GlobalSettings::self()->networkState() ) );
3406 if (action(
"edit_undo" ))
3407 action(
"edit_undo" )->setEnabled( mHeaders->canUndo() );
3412 if((aIdx = mHeaders->currentItemIndex()) <= -1)
3414 if(!(msg = mFolder->getMsg(aIdx)))
3417 if ((
KMFolder*)mFolder == kmkernel->outboxFolder())
3421 mApplyAllFiltersAction->setEnabled(count);
3422 mApplyFilterActionsMenu->setEnabled(count);
3426 void KMMainWidget::updateMarkAsReadAction()
3428 mMarkAllAsReadAction->setEnabled( mFolder && (mFolder->countUnread() > 0) );
3432 void KMMainWidget::updateFolderMenu()
3434 bool folderWithContent = mFolder && !mFolder->noContent();
3435 bool multiFolder = folderTree()->selectedFolders().count() > 1;
3436 mModifyFolderAction->setEnabled( folderWithContent && !multiFolder );
3437 mFolderMailingListPropertiesAction->setEnabled( folderWithContent && !multiFolder );
3438 mCompactFolderAction->setEnabled( folderWithContent && !multiFolder );
3441 bool imap = mFolder && mFolder->folderType() == KMFolderTypeImap;
3442 bool cachedImap = mFolder && mFolder->folderType() == KMFolderTypeCachedImap;
3444 bool knownImapPath = cachedImap && !
static_cast<KMFolderCachedImap*
>( mFolder->storage() )->imapPath().isEmpty();
3445 mRefreshFolderAction->setEnabled( folderWithContent && ( imap
3446 || ( cachedImap && knownImapPath ) ) && !multiFolder );
3447 if ( mTroubleshootFolderAction )
3448 mTroubleshootFolderAction->setEnabled( folderWithContent && ( cachedImap && knownImapPath ) && !multiFolder );
3450 mEmptyFolderAction->setEnabled( folderWithContent &&
3451 ( mFolder->count() > 0 ) && mFolder->canDeleteMessages() &&
3453 mEmptyFolderAction->setText( ( mFolder && kmkernel->folderIsTrash( mFolder ) ) ?
3454 i18n(
"E&mpty Trash" ) :
3455 i18n(
"&Move All Messages to Trash" ) );
3457 mRemoveFolderAction->setEnabled( mFolder &&
3458 !mFolder->isSystemFolder() &&
3459 mFolder->canDeleteMessages() &&
3460 !multiFolder && !mFolder->noContent() &&
3461 !mFolder->mailCheckInProgress() );
3462 mRemoveFolderAction->setText( mFolder &&
3463 mFolder->folderType() == KMFolderTypeSearch ?
3464 i18n(
"&Delete Search" ) :
3465 i18n(
"&Delete Folder" ) );
3467 if ( mArchiveFolderAction )
3468 mArchiveFolderAction->setEnabled( mFolder && !multiFolder );
3469 mExpireFolderAction->setEnabled( mFolder && mFolder->isAutoExpire() && !multiFolder && mFolder->canDeleteMessages() );
3470 updateMarkAsReadAction();
3472 mPreferHtmlAction->setEnabled( mHeaders->folder() ?
true : false );
3473 mPreferHtmlLoadExtAction->setEnabled( mHeaders->folder() && (mHtmlPref ? !mFolderHtmlPref : mFolderHtmlPref) ?
true :
false );
3474 mThreadMessagesAction->setEnabled( mHeaders->folder() ?
true : false );
3476 mPreferHtmlAction->setChecked( mHtmlPref ? !mFolderHtmlPref : mFolderHtmlPref );
3477 mPreferHtmlLoadExtAction->setChecked( mHtmlLoadExtPref ? !mFolderHtmlLoadExtPref : mFolderHtmlLoadExtPref );
3478 mThreadMessagesAction->setChecked(
3479 mThreadPref ? !mFolderThreadPref : mFolderThreadPref );
3480 mThreadBySubjectAction->setEnabled(
3481 mHeaders->folder() ? ( mThreadMessagesAction->isChecked()) :
false );
3482 mThreadBySubjectAction->setChecked( mFolderThreadSubjPref );
3484 mNewFolderAction->setEnabled( !multiFolder && ( mFolder && mFolder->folderType() != KMFolderTypeSearch ));
3485 mRemoveDuplicatesAction->setEnabled( !multiFolder && mFolder && mFolder->canDeleteMessages() );
3486 mFolderShortCutCommandAction->setEnabled( !multiFolder );
3491 static TQString fmt(
long n) {
3494 if(n > 1024*1024*1024)
3495 sprintf(buf,
"%0.2f GB", ((
double)n)/1024.0/1024.0/1024.0);
3496 else if(n > 1024*1024)
3497 sprintf(buf,
"%0.2f MB", ((
double)n)/1024.0/1024.0);
3499 sprintf(buf,
"%0.2f KB", ((
double)n)/1024.0);
3501 sprintf(buf,
"%ld Byte", n);
3502 return TQString(buf);
3506 void KMMainWidget::slotMemInfo() {
3511 TQString s = TQString(
"\nMALLOC - Info\n\n"
3512 "Number of mmapped regions : %1\n"
3513 "Memory allocated in use : %2\n"
3514 "Memory allocated, not used: %3\n"
3515 "Memory total allocated : %4\n"
3516 "Max. freeable memory : %5\n")
3517 .arg(mi.hblks).arg(fmt(mi.uordblks)).arg(fmt(mi.fordblks))
3518 .arg(fmt(mi.arena)).arg(fmt(mi.keepcost));
3519 KMessageBox::information(0, s,
"Malloc information", s);
3525 void KMMainWidget::slotIntro()
3527 if ( !mMsgView )
return;
3529 mMsgView->clear(
true );
3531 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
3532 mSearchAndHeaders->hide();
3535 mMsgView->displayAboutPage();
3540 void KMMainWidget::slotShowStartupFolder()
3542 if ( mFolderTree ) {
3543 mFolderTree->reload();
3544 mFolderTree->readConfig();
3546 mFolderTree->cleanupConfigFile();
3549 connect( kmkernel->filterMgr(), TQT_SIGNAL( filterListUpdated() ),
3550 this, TQT_SLOT( initializeFilterActions() ));
3553 initializeFilterActions();
3556 initializeFolderShortcutActions();
3559 if ( kmkernel->firstStart() ||
3560 GlobalSettings::self()->previousNewFeaturesMD5() != newFeaturesMD5 ) {
3561 GlobalSettings::self()->setPreviousNewFeaturesMD5( newFeaturesMD5 );
3567 if ( !mStartupFolder.isEmpty() ) {
3569 startup = kmkernel->findFolderById( mStartupFolder );
3572 startup = kmkernel->inboxFolder();
3574 if ( mFolderTree ) {
3575 mFolderTree->showFolder( startup );
3579 void KMMainWidget::slotShowTip()
3581 KTipDialog::showTip(
this, TQString(),
true );
3585 void KMMainWidget::slotChangeCaption(TQListViewItem * i)
3590 for ( TQListViewItem * item = i ; item ; item = item->parent() )
3591 names.prepend( item->text(0) );
3592 emit captionChangeRequest( names.join(
"/" ) );
3596 void KMMainWidget::removeDuplicates()
3601 mHeaders->setFolder(0);
3602 TQMap< TQString, TQValueList<int> > idMD5s;
3603 TQValueList<int> redundantIds;
3604 TQValueList<int>::Iterator kt;
3605 mFolder->
open(
"removedups");
3606 for (
int i = mFolder->count() - 1; i >= 0; --i) {
3607 TQString
id = (*mFolder)[i]->msgIdMD5();
3608 if ( !
id.isEmpty() ) {
3609 TQString subjMD5 = (*mFolder)[i]->strippedSubjectMD5();
3611 if ( idMD5s.contains(
id) )
3612 other = idMD5s[
id].first();
3614 idMD5s[id].append( i );
3615 if ( other != -1 ) {
3616 TQString otherSubjMD5 = (*mFolder)[other]->strippedSubjectMD5();
3617 if (otherSubjMD5 == subjMD5)
3618 idMD5s[id].append( i );
3622 TQMap< TQString, TQValueList<int> >::Iterator it;
3623 for ( it = idMD5s.begin(); it != idMD5s.end() ; ++it ) {
3624 TQValueList<int>::Iterator jt;
3625 bool finished =
false;
3626 for ( jt = (*it).begin(); jt != (*it).end() && !finished; ++jt )
3627 if (!((*mFolder)[*jt]->isUnread())) {
3629 (*it).prepend( *jt );
3632 for ( jt = (*it).begin(), ++jt; jt != (*it).end(); ++jt )
3633 redundantIds.append( *jt );
3635 qHeapSort( redundantIds );
3636 kt = redundantIds.end();
3637 int numDuplicates = 0;
3638 if (kt != redundantIds.begin())
do {
3639 mFolder->removeMsg( *(--kt) );
3642 while (kt != redundantIds.begin());
3644 mFolder->close(
"removedups");
3645 mHeaders->setFolder(oFolder);
3647 if ( numDuplicates )
3648 msg = i18n(
"Removed %n duplicate message.",
3649 "Removed %n duplicate messages.", numDuplicates );
3651 msg = i18n(
"No duplicate messages found.");
3652 BroadcastStatus::instance()->setStatusMsg( msg );
3657 void KMMainWidget::slotUpdateUndo()
3659 if (actionCollection()->action(
"edit_undo" ))
3660 actionCollection()->action(
"edit_undo" )->setEnabled( mHeaders->canUndo() );
3665 void KMMainWidget::clearFilterActions()
3667 if ( !mFilterTBarActions.isEmpty() ) {
3668 if ( mGUIClient->factory() )
3669 mGUIClient->unplugActionList(
"toolbar_filter_actions" );
3670 mFilterTBarActions.clear();
3672 mApplyFilterActionsMenu->popupMenu()->clear();
3673 if ( !mFilterMenuActions.isEmpty() ) {
3674 if ( mGUIClient->factory() )
3675 mGUIClient->unplugActionList(
"menu_filter_actions" );
3676 mFilterMenuActions.clear();
3678 mFilterCommands.clear();
3682 void KMMainWidget::initializeFolderShortcutActions()
3688 bool old = actionCollection()->isAutoConnectShortcuts();
3690 actionCollection()->setAutoConnectShortcuts(
true );
3691 TQValueList< TQGuardedPtr< KMFolder > > folders = kmkernel->allFolders();
3692 TQValueList< TQGuardedPtr< KMFolder > >::Iterator it = folders.begin();
3693 while ( it != folders.end() ) {
3696 slotShortcutChanged( folder );
3698 actionCollection()->setAutoConnectShortcuts( old );
3703 void KMMainWidget::initializeFilterActions()
3705 TQString filterName, normalizedName;
3706 KMMetaFilterActionCommand *filterCommand;
3707 TDEAction *filterAction = 0;
3709 clearFilterActions();
3710 mApplyAllFiltersAction->plug(mApplyFilterActionsMenu->popupMenu());
3711 bool addedSeparator =
false;
3712 TQValueListConstIterator<KMFilter*> it = kmkernel->filterMgr()->filters().constBegin();
3713 for ( ;it != kmkernel->filterMgr()->filters().constEnd(); ++it ) {
3714 if (!(*it)->isEmpty() && (*it)->configureShortcut()) {
3715 filterName = TQString(
"Filter %1").arg((*it)->name());
3716 normalizedName = filterName.replace(
" ",
"_");
3717 if (action(normalizedName.utf8()))
3719 filterCommand =
new KMMetaFilterActionCommand(*it, mHeaders,
this);
3720 mFilterCommands.append(filterCommand);
3721 TQString as = i18n(
"Filter %1").arg((*it)->name());
3722 TQString icon = (*it)->icon();
3723 if ( icon.isEmpty() )
3725 filterAction =
new TDEAction(as, icon, (*it)->shortcut(), filterCommand,
3726 TQT_SLOT(start()), actionCollection(),
3727 normalizedName.local8Bit());
3728 if(!addedSeparator) {
3729 mApplyFilterActionsMenu->popupMenu()->insertSeparator();
3730 addedSeparator = !addedSeparator;
3731 mFilterMenuActions.append(
new TDEActionSeparator());
3733 filterAction->plug( mApplyFilterActionsMenu->popupMenu() );
3734 mFilterMenuActions.append(filterAction);
3735 if ( (*it)->configureToolbar() )
3736 mFilterTBarActions.append(filterAction);
3739 if ( !mFilterMenuActions.isEmpty() && mGUIClient->factory() )
3740 mGUIClient->plugActionList(
"menu_filter_actions", mFilterMenuActions );
3741 if ( !mFilterTBarActions.isEmpty() && mGUIClient->factory() ) {
3742 mFilterTBarActions.prepend( mToolbarActionSeparator );
3743 mGUIClient->plugActionList(
"toolbar_filter_actions", mFilterTBarActions );
3747 void KMMainWidget::slotFolderRemoved(
KMFolder *folder )
3749 mFolderShortcutCommands.remove( folder->
idString() );
3753 void KMMainWidget::initializeIMAPActions(
bool setState )
3755 bool hasImapAccount =
false;
3756 for( KMAccount *a = kmkernel->acctMgr()->first(); a;
3757 a = kmkernel->acctMgr()->next() ) {
3758 if ( a->type() ==
"cachedimap" ) {
3759 hasImapAccount =
true;
3763 if ( hasImapAccount == ( mTroubleshootFolderAction != 0 ) )
3766 KXMLGUIFactory* factory = mGUIClient->factory();
3768 factory->removeClient( mGUIClient );
3770 if ( !mTroubleshootFolderAction ) {
3771 mTroubleshootFolderAction =
new TDEAction( i18n(
"&Troubleshoot IMAP Cache..."),
"wizard", 0,
3772 TQT_TQOBJECT(
this), TQT_SLOT(slotTroubleshootFolder()), actionCollection(),
"troubleshoot_folder" );
3776 delete mTroubleshootFolderAction ;
3777 mTroubleshootFolderAction = 0;
3781 factory->addClient( mGUIClient );
3784 bool KMMainWidget::shortcutIsValid(
const TDEShortcut &sc )
const
3786 TDEActionPtrList actions = actionCollection()->actions();
3787 TDEActionPtrList::Iterator it( actions.begin() );
3788 for ( ; it != actions.end(); it++ ) {
3789 if ( (*it)->shortcut() == sc )
return false;
3794 void KMMainWidget::slotShortcutChanged(
KMFolder *folder )
3797 mFolderShortcutCommands.remove( folder->
idString() );
3798 if ( folder->shortcut().isNull() )
3801 FolderShortcutCommand *c =
new FolderShortcutCommand(
this, folder );
3802 mFolderShortcutCommands.insert( folder->
idString(), c );
3804 TQString actionlabel = TQString(
"FolderShortcut %1").arg( folder->
prettyURL() );
3805 TQString actionname = TQString(
"FolderShortcut %1").arg( folder->
idString() );
3806 TQString normalizedName = actionname.replace(
" ",
"_");
3808 new TDEAction(actionlabel, folder->shortcut(), c, TQT_SLOT(start()),
3809 actionCollection(), normalizedName.local8Bit());
3810 action->setIcon( folder->unreadIconPath() );
3811 c->setAction( action );
3815 TQString KMMainWidget::findCurrentImapPath()
3818 if (!mFolder)
return startPath;
3819 if (mFolder->folderType() == KMFolderTypeImap)
3821 startPath =
static_cast<KMFolderImap*
>(mFolder->storage())->imapPath();
3822 }
else if (mFolder->folderType() == KMFolderTypeCachedImap)
3824 startPath =
static_cast<KMFolderCachedImap*
>(mFolder->storage())->imapPath();
3830 ImapAccountBase* KMMainWidget::findCurrentImapAccountBase()
3832 ImapAccountBase* account = 0;
3833 if (!mFolder)
return account;
3834 if (mFolder->folderType() == KMFolderTypeImap)
3836 account =
static_cast<KMFolderImap*
>(mFolder->storage())->account();
3837 }
else if (mFolder->folderType() == KMFolderTypeCachedImap)
3839 account =
static_cast<KMFolderCachedImap*
>(mFolder->storage())->account();
3845 void KMMainWidget::slotSubscriptionDialog()
3847 if ( !kmkernel->askToGoOnline() )
3849 ImapAccountBase* account = findCurrentImapAccountBase();
3850 if ( !account )
return;
3851 const TQString startPath = findCurrentImapPath();
3854 SubscriptionDialog * dialog =
3855 new SubscriptionDialog(
this, i18n(
"Subscription"), account, startPath);
3856 if ( dialog->exec() ) {
3858 if (mFolder->folderType() == KMFolderTypeImap)
3859 static_cast<KMFolderImap*>(mFolder->storage())->account()->listDirectory();
3864 void KMMainWidget::slotLocalSubscriptionDialog()
3866 ImapAccountBase* account = findCurrentImapAccountBase();
3867 if ( !account )
return;
3869 const TQString startPath = findCurrentImapPath();
3871 LocalSubscriptionDialog *dialog =
3872 new LocalSubscriptionDialog(
this, i18n(
"Local Subscription"), account, startPath);
3873 if ( dialog->exec() ) {
3875 if (mFolder->folderType() == KMFolderTypeImap)
3876 static_cast<KMFolderImap*>(mFolder->storage())->account()->listDirectory();
3881 void KMMainWidget::slotFolderTreeColumnsChanged()
3883 mTotalColumnToggle->setChecked( mFolderTree->isTotalActive() );
3884 mUnreadColumnToggle->setChecked( mFolderTree->isUnreadActive() );
3885 mSizeColumnToggle->setChecked( mFolderTree->isSizeActive() );
3886 mUnreadTextToggle->setChecked( !mFolderTree->isUnreadActive() );
3889 void KMMainWidget::toggleSystemTray()
3891 if ( !mSystemTray && GlobalSettings::self()->systemTrayEnabled() ) {
3894 else if ( mSystemTray && !GlobalSettings::self()->systemTrayEnabled() ) {
3896 kdDebug(5006) <<
"deleting systray" << endl;
3903 mSystemTray->setMode( GlobalSettings::self()->systemTrayPolicy() );
3907 void KMMainWidget::slotAntiSpamWizard()
3909 AntiSpamWizard wiz( AntiSpamWizard::AntiSpam,
this, folderTree() );
3914 void KMMainWidget::slotAntiVirusWizard()
3916 AntiSpamWizard wiz( AntiSpamWizard::AntiVirus,
this, folderTree() );
3921 void KMMainWidget::slotFilterLogViewer()
3928 void KMMainWidget::updateFileMenu()
3930 TQStringList actList = kmkernel->acctMgr()->getAccounts();
3932 actionCollection()->action(
"check_mail")->setEnabled( actList.size() > 0 );
3933 actionCollection()->action(
"check_mail_in")->setEnabled( actList.size() > 0 );
3934 actionCollection()->action(
"favorite_check_mail")->setEnabled( actList.size() > 0 );
3939 void KMMainWidget::setAccelsEnabled(
bool enabled )
3941 actionCollection()->tdeaccel()->setEnabled( enabled );
3952 TQString KMMainWidget::overrideEncoding()
const
3955 return mMsgView->overrideEncoding();
3957 return GlobalSettings::self()->overrideCharacterEncoding();
3960 void KMMainWidget::slotCreateTodo()
3962 KMMessage *msg = mHeaders->currentMsg();
3965 KMCommand *command =
new CreateTodoCommand(
this, msg );
3969 void KMMainWidget::setupFolderView()
3971 if ( GlobalSettings::self()->enableFavoriteFolderView() ) {
3972 mFolderView = mFolderViewSplitter;
3973 mFolderTree->reparent( mFolderViewSplitter, 0, TQPoint( 0, 0 ) );
3974 mFolderViewSplitter->show();
3975 mFavoriteFolderView->show();
3977 mFolderView = mFolderTree;
3978 mFolderViewSplitter->hide();
3979 mFavoriteFolderView->hide();
3981 mFolderView->reparent( mFolderViewParent, 0, TQPoint( 0, 0 ) );
3982 mFolderViewParent->moveToFirst( mFolderView );
3983 mFolderTree->show();
3987 void KMMainWidget::slotRequestFullSearchFromQuickSearch()
3990 #ifdef HAVE_INDEXLIB
3993 assert( mSearchWin );
3996 int status = mQuickSearchLine->currenStatus();
3997 if ( status != 0 ) {
4000 mSearchWin->setSearchPattern( pattern );
4003 void KMMainWidget::updateVactionScripStatus(
bool active)
4005 mVacationIndicatorActive = active;
4007 mVacationScriptIndicator->setText( i18n(
"Out of office reply active") );
4008 mVacationScriptIndicator->setPaletteBackgroundColor( TQt::yellow );
4009 mVacationScriptIndicator->setCursor( TQCursor( TQt::PointingHandCursor ) );
4010 mVacationScriptIndicator->show();
4012 mVacationScriptIndicator->hide();