30 #include "kmail_part.h"
32 #include "kmmainwin.h"
33 #include "kmmainwidget.h"
34 #include "kmfoldertree.h"
35 #include "kmstartup.h"
36 #include "aboutdata.h"
38 #include "accountmanager.h"
40 #include "sidebarextension.h"
41 #include "infoextension.h"
42 #include "recentaddresses.h"
43 using TDERecentAddress::RecentAddresses;
45 #include <tdeapplication.h>
46 #include <tdeparts/mainwindow.h>
47 #include <tdeparts/genericfactory.h>
48 #include <knotifyclient.h>
49 #include <dcopclient.h>
50 #include <kiconloader.h>
52 #include <kstatusbar.h>
53 #include <ksettings/dispatcher.h>
59 typedef KParts::GenericFactory< KMailPart > KMailFactory;
60 K_EXPORT_COMPONENT_FACTORY( libkmailpart, KMailFactory )
62 KMailPart::KMailPart(TQWidget *parentWidget,
const char *widgetName,
63 TQObject *parent,
const char *name,
const TQStringList &) :
64 DCOPObject(
"KMailIface"), KParts::ReadOnlyPart(parent, name),
65 mParentWidget( parentWidget )
67 kdDebug(5006) <<
"KMailPart()" << endl;
68 kdDebug(5006) <<
" InstanceName: " << kapp->instanceName() << endl;
70 setInstance(KMailFactory::instance());
72 kdDebug(5006) <<
"KMailPart()..." << endl;
73 kdDebug(5006) <<
" InstanceName: " << kapp->instanceName() << endl;
76 KMail::insertLibraryCataloguesAndIcons();
80 KNotifyClient::startDaemon();
84 kapp->dcopClient()->suspend();
89 mKMailKernel->setXmlGuiInstance( KMailFactory::instance() );
92 mKMailKernel->doSessionManagement();
95 mKMailKernel->recoverDeadLetters();
97 kmsetSignalHandler(kmsignalHandler);
98 kapp->dcopClient()->resume();
101 TQWidget *canvas =
new TQWidget(parentWidget, widgetName);
102 canvas->setFocusPolicy(TQWidget::ClickFocus);
104 TDEGlobal::iconLoader()->addAppDir(
"kmail");
108 connect(mReaderWin, TQ_SIGNAL(urlClicked(
const KURL&,
int)),
109 mReaderWin, TQ_SLOT(slotUrlClicked()));
110 TQVBoxLayout *topLayout =
new TQVBoxLayout(canvas);
111 topLayout->addWidget(mReaderWin);
112 mReaderWin->setAutoDelete(
true );
113 kmkernel->inboxFolder()->open();
114 KMMessage *msg = kmkernel->inboxFolder()->getMsg(0);
115 mReaderWin->
setMsg( msg,
true );
116 mReaderWin->setFocusPolicy(TQWidget::ClickFocus);
117 mStatusBar =
new KMailStatusBarExtension(
this);
119 TDEGlobal::iconLoader()->addAppDir(
"kmail");
120 setXMLFile(
"kmail_part.rc" );
121 kmkernel->inboxFolder()->close();
123 mainWidget =
new KMMainWidget( canvas,
"mainWidget",
this, actionCollection(),
125 TQVBoxLayout *topLayout =
new TQVBoxLayout(canvas);
126 topLayout->addWidget(mainWidget);
127 mainWidget->setFocusPolicy(TQWidget::ClickFocus);
128 mStatusBar =
new KMailStatusBarExtension(
this);
129 mStatusBar->addStatusBarItem( mainWidget->vacationScriptIndicator(), 2,
false );
131 new KParts::SideBarExtension( mainWidget->folderTree(),
136 KParts::InfoExtension *ie =
new KParts::InfoExtension(
this,
"KMailInfo" );
137 connect( mainWidget->folderTree(), TQ_SIGNAL(folderSelected(
KMFolder*)),
this, TQ_SLOT(exportFolder(
KMFolder*)) );
138 connect( mainWidget->folderTree(), TQ_SIGNAL(iconChanged(KMFolderTreeItem*)),
139 this, TQ_SLOT(slotIconChanged(KMFolderTreeItem*)) );
140 connect( mainWidget->folderTree(), TQ_SIGNAL(nameChanged(KMFolderTreeItem*)),
141 this, TQ_SLOT(slotNameChanged(KMFolderTreeItem*)) );
142 connect(
this, TQ_SIGNAL(textChanged(
const TQString&)), ie, TQ_SIGNAL(textChanged(
const TQString&)) );
143 connect(
this, TQ_SIGNAL(iconChanged(
const TQPixmap&)), ie, TQ_SIGNAL(iconChanged(
const TQPixmap&)) );
145 TDEGlobal::iconLoader()->addAppDir(
"kmail" );
146 setXMLFile(
"kmail_part.rc" );
149 KSettings::Dispatcher::self()->registerInstance( KMailFactory::instance(), mKMailKernel,
150 TQ_SLOT( slotConfigChanged() ) );
153 KMailPart::~KMailPart()
155 kdDebug(5006) <<
"Closing last KMMainWin: stopping mail check" << endl;
158 kmkernel->abortMailCheck();
159 kmkernel->acctMgr()->cancelMailCheck();
161 mainWidget->destruct();
167 TDEAboutData *KMailPart::createAboutData()
169 return new KMail::AboutData();
172 bool KMailPart::openFile()
174 kdDebug(5006) <<
"KMailPart:openFile()" << endl;
180 void KMailPart::exportFolder(
KMFolder *folder )
182 KMFolderTreeItem* fti =
static_cast< KMFolderTreeItem*
>( mainWidget->folderTree()->currentItem() );
185 emit textChanged( folder->
label() );
188 emit iconChanged( fti->normalIcon( 22 ) );
191 void KMailPart::slotIconChanged( KMFolderTreeItem *fti )
193 emit iconChanged( fti->normalIcon( 22 ) );
196 void KMailPart::slotNameChanged( KMFolderTreeItem *fti )
198 emit textChanged( fti->folder()->label() );
208 class KPartsMainWindowWithPublicizedCreateGUI :
public KParts::MainWindow
211 void createGUIPublic( KParts::Part *part ) {
218 void KMailPart::guiActivateEvent(KParts::GUIActivateEvent *e)
220 kdDebug(5006) <<
"KMailPart::guiActivateEvent" << endl;
221 KParts::ReadOnlyPart::guiActivateEvent(e);
222 mainWidget->initializeFilterActions();
223 mainWidget->initializeFolderShortcutActions();
224 mainWidget->setupForwardingActionsList();
225 mainWidget->updateVactionScripStatus();
228 void KMailPart::exit()
233 TQWidget* KMailPart::parentWidget()
const
235 return mParentWidget;
239 KMailStatusBarExtension::KMailStatusBarExtension( KMailPart *parent )
240 : KParts::StatusBarExtension( parent ), mParent( parent )
244 TDEMainWindow * KMailStatusBarExtension::mainWindow()
const
246 return static_cast<TDEMainWindow*
>( mParent->parentWidget() );
249 #include "kmail_part.moc"
virtual TQString label() const
Returns the label of the folder for visualization.
Central point of coordination in KMail.
This class implements a "reader window", that is a window used for reading or viewing messages.
virtual void setMsg(KMMessage *msg, bool force=false, bool updateOnly=false)
Set the message that shall be shown.
The account manager is responsible for creating accounts of various types via the factory method crea...