24 #include "pluginmanager.h"
28 #include <ksettings/dialog.h>
29 #include <kplugininfo.h>
30 #include <tdeapplication.h>
31 #include <tdeconfig.h>
33 #include <klibloader.h>
34 #include <kstdaction.h>
35 #include <tdelistbox.h>
36 #include <kiconloader.h>
37 #include <kstandarddirs.h>
38 #include <tdeshortcut.h>
39 #include <tdelocale.h>
40 #include <kstatusbar.h>
42 #include <tdepopupmenu.h>
43 #include <tdeshortcut.h>
44 #include <kcmultidialog.h>
45 #include <tdeaction.h>
46 #include <tdestdaccel.h>
49 #include <tqwidgetstack.h>
55 Core::Core( TQWidget *parent,
const char *name )
57 TDEMainWindow( parent, name ), m_currentEditor( 0 )
62 setInstance(
new TDEInstance(
"komposer" ) );
65 setXMLFile(
"komposerui.rc" );
70 setAutoSaveSettings();
83 Core::addEditor( Komposer::Editor *editor )
85 if ( editor->widget() ) {
86 m_stack->addWidget( editor->widget() );
87 m_stack->raiseWidget( editor->widget() );
88 editor->widget()->show();
89 m_currentEditor = editor;
94 guiFactory()->addClient( editor );
98 Core::addPlugin( Komposer::Plugin *plugin )
101 guiFactory()->addClient( plugin );
105 Core::slotPluginLoaded( Plugin *plugin )
107 kdDebug() <<
"Plugin loaded "<<endl;
109 Editor *editor =
dynamic_cast<Editor*
>( plugin );
118 Core::slotAllPluginsLoaded()
120 TQValueList<KPluginInfo*> plugins = m_pluginManager->availablePlugins();
121 kdDebug()<<
"Number of available plugins is "<< plugins.count() <<endl;
122 for ( TQValueList<KPluginInfo*>::iterator it = plugins.begin(); it != plugins.end(); ++it ) {
123 KPluginInfo *i = ( *it );
124 kdDebug()<<
"\tAvailable plugin "<< i->pluginName()
125 <<
", comment = "<< i->comment() <<endl;
128 if ( !m_stack->visibleWidget() ) {
129 m_pluginManager->loadPlugin(
"komposer_defaulteditor", PluginManager::LoadAsync );
135 Core::slotActivePartChanged( KParts::Part *part )
142 kdDebug() <<
"Part activated: " << part <<
" with stack id. "
143 << m_stack->id( part->widget() )<< endl;
149 Core::selectEditor( Komposer::Editor *editor )
154 KParts::Part *part = editor->part();
158 TQPtrList<KParts::Part> *partList =
const_cast<TQPtrList<KParts::Part>*
>(
159 m_partManager->parts() );
160 if ( partList->find( part ) == -1 )
163 m_partManager->setActivePart( part );
164 TQWidget *view = part->widget();
167 kdDebug()<<
"Raising view "<<view<<endl;
170 m_stack->raiseWidget( view );
173 m_currentEditor = editor;
178 Core::selectEditor(
const TQString &editorName )
203 kdDebug()<<
"exit"<<endl;
204 m_pluginManager->shutdown();
208 Core::slotPreferences()
211 m_dlg =
new KSettings::Dialog(
this );
219 TQHBox *topWidget =
new TQHBox(
this );
220 setCentralWidget( topWidget );
221 m_stack =
new TQWidgetStack( topWidget );
227 m_pluginManager =
new PluginManager(
this );
228 connect( m_pluginManager, TQ_SIGNAL(pluginLoaded(Plugin*)),
229 TQ_SLOT(slotPluginLoaded(Plugin*)) );
230 connect( m_pluginManager, TQ_SIGNAL(allPluginsLoaded()),
231 TQ_SLOT(slotAllPluginsLoaded()) );
234 m_pluginManager->loadAllPlugins();
235 kdDebug()<<
"Loading"<<endl;
239 Core::initConnections()
241 connect( kapp, TQ_SIGNAL(shutDown()),
242 TQ_SLOT(slotQuit()) );
246 Core::createActions()
248 KStdAction::close(
this, TQ_SLOT(slotClose()), actionCollection() );
250 (void)
new TDEAction( i18n(
"&Send" ),
"mail-send", CTRL+Key_Return,
251 this, TQ_SLOT(slotSendNow()), actionCollection(),
254 (void)
new TDEAction( i18n(
"&Queue" ),
"queue", 0,
255 this, TQ_SLOT(slotSendLater()),
256 actionCollection(),
"send_alternative" );
258 (void)
new TDEAction( i18n(
"Save in &Drafts Folder" ),
"document-save", 0,
259 this, TQ_SLOT(slotSaveDraft()),
260 actionCollection(),
"save_in_drafts" );
261 (void)
new TDEAction( i18n(
"&Insert File..." ),
"document-open", 0,
262 this, TQ_SLOT(slotInsertFile()),
263 actionCollection(),
"insert_file" );
264 (void)
new TDEAction( i18n(
"&Address Book" ),
"contents",0,
265 this, TQ_SLOT(slotAddrBook()),
266 actionCollection(),
"addressbook" );
267 (void)
new TDEAction( i18n(
"&New Composer" ),
"mail-message-new",
268 TDEStdAccel::shortcut( TDEStdAccel::New ),
269 this, TQ_SLOT(slotNewComposer()),
270 actionCollection(),
"new_composer" );
272 (void)
new TDEAction( i18n(
"&Attach File..." ),
"attach",
273 0,
this, TQ_SLOT(slotAttachFile()),
274 actionCollection(),
"attach_file" );
290 Core::slotSendLater()
296 Core::slotSaveDraft()
302 Core::slotInsertFile()
314 Core::slotNewComposer()
320 Core::slotAttachFile()
326 Core::send(
int how )
332 Core::addAttachment(
const KURL &url,
const TQString &comment )
338 Core::setBody(
const TQString &body )
340 m_currentEditor->setText( body );
344 Core::addAttachment(
const TQString &name,
345 const TQCString &cte,
346 const TQByteArray &data,
347 const TQCString &type,
348 const TQCString &subType,
349 const TQCString ¶mAttr,
350 const TQString ¶mValue,
351 const TQCString &contDisp )
DCOP interface for mail composer window.