25 #include "pluginmanager.h" 29 #include <ksettings/dialog.h> 30 #include <kplugininfo.h> 31 #include <tdeapplication.h> 32 #include <tdeconfig.h> 34 #include <klibloader.h> 35 #include <kstdaction.h> 36 #include <tdelistbox.h> 37 #include <kiconloader.h> 38 #include <kstandarddirs.h> 39 #include <tdeshortcut.h> 40 #include <tdelocale.h> 41 #include <kstatusbar.h> 43 #include <tdepopupmenu.h> 44 #include <tdeshortcut.h> 45 #include <kcmultidialog.h> 46 #include <tdeaction.h> 47 #include <tdestdaccel.h> 50 #include <tqwidgetstack.h> 56 Core::Core( TQWidget *parent,
const char *name )
58 TDEMainWindow( parent, name ), m_currentEditor( 0 )
63 setInstance(
new TDEInstance(
"komposer" ) );
66 setXMLFile(
"komposerui.rc" );
71 setAutoSaveSettings();
84 Core::addEditor( Komposer::Editor *editor )
86 if ( editor->widget() ) {
87 m_stack->addWidget( editor->widget() );
88 m_stack->raiseWidget( editor->widget() );
89 editor->widget()->show();
90 m_currentEditor = editor;
95 guiFactory()->addClient( editor );
99 Core::addPlugin( Komposer::Plugin *plugin )
102 guiFactory()->addClient( plugin );
106 Core::slotPluginLoaded( Plugin *plugin )
108 kdDebug() <<
"Plugin loaded "<<endl;
110 Editor *editor =
dynamic_cast<Editor*
>( plugin );
119 Core::slotAllPluginsLoaded()
121 TQValueList<KPluginInfo*> plugins = m_pluginManager->availablePlugins();
122 kdDebug()<<
"Number of available plugins is "<< plugins.count() <<endl;
123 for ( TQValueList<KPluginInfo*>::iterator it = plugins.begin(); it != plugins.end(); ++it ) {
124 KPluginInfo *i = ( *it );
125 kdDebug()<<
"\tAvailable plugin "<< i->pluginName()
126 <<
", comment = "<< i->comment() <<endl;
129 if ( !m_stack->visibleWidget() ) {
130 m_pluginManager->loadPlugin(
"komposer_defaulteditor", PluginManager::LoadAsync );
136 Core::slotActivePartChanged( KParts::Part *part )
143 kdDebug() <<
"Part activated: " << part <<
" with stack id. " 144 << m_stack->id( part->widget() )<< endl;
150 Core::selectEditor( Komposer::Editor *editor )
155 KParts::Part *part = editor->part();
159 TQPtrList<KParts::Part> *partList =
const_cast<TQPtrList<KParts::Part>*
>(
160 m_partManager->parts() );
161 if ( partList->find( part ) == -1 )
164 m_partManager->setActivePart( part );
165 TQWidget *view = part->widget();
168 kdDebug()<<
"Raising view "<<view<<endl;
171 m_stack->raiseWidget( view );
174 m_currentEditor = editor;
179 Core::selectEditor(
const TQString &editorName )
204 kdDebug()<<
"exit"<<endl;
205 m_pluginManager->shutdown();
209 Core::slotPreferences()
212 m_dlg =
new KSettings::Dialog(
this );
220 TQHBox *topWidget =
new TQHBox(
this );
221 setCentralWidget( topWidget );
222 m_stack =
new TQWidgetStack( topWidget );
228 m_pluginManager =
new PluginManager(
this );
229 connect( m_pluginManager, TQT_SIGNAL(pluginLoaded(Plugin*)),
230 TQT_SLOT(slotPluginLoaded(Plugin*)) );
231 connect( m_pluginManager, TQT_SIGNAL(allPluginsLoaded()),
232 TQT_SLOT(slotAllPluginsLoaded()) );
235 m_pluginManager->loadAllPlugins();
236 kdDebug()<<
"Loading"<<endl;
240 Core::initConnections()
242 connect( kapp, TQT_SIGNAL(shutDown()),
243 TQT_SLOT(slotQuit()) );
247 Core::createActions()
249 KStdAction::close(
this, TQT_SLOT(slotClose()), actionCollection() );
251 (void)
new TDEAction( i18n(
"&Send" ),
"mail-send", CTRL+Key_Return,
252 this, TQT_SLOT(slotSendNow()), actionCollection(),
255 (void)
new TDEAction( i18n(
"&Queue" ),
"queue", 0,
256 this, TQT_SLOT(slotSendLater()),
257 actionCollection(),
"send_alternative" );
259 (void)
new TDEAction( i18n(
"Save in &Drafts Folder" ),
"document-save", 0,
260 this, TQT_SLOT(slotSaveDraft()),
261 actionCollection(),
"save_in_drafts" );
262 (void)
new TDEAction( i18n(
"&Insert File..." ),
"document-open", 0,
263 this, TQT_SLOT(slotInsertFile()),
264 actionCollection(),
"insert_file" );
265 (void)
new TDEAction( i18n(
"&Address Book" ),
"contents",0,
266 this, TQT_SLOT(slotAddrBook()),
267 actionCollection(),
"addressbook" );
268 (void)
new TDEAction( i18n(
"&New Composer" ),
"mail-message-new",
269 TDEStdAccel::shortcut( TDEStdAccel::New ),
270 this, TQT_SLOT(slotNewComposer()),
271 actionCollection(),
"new_composer" );
273 (void)
new TDEAction( i18n(
"&Attach File..." ),
"attach",
274 0,
this, TQT_SLOT(slotAttachFile()),
275 actionCollection(),
"attach_file" );
291 Core::slotSendLater()
297 Core::slotSaveDraft()
303 Core::slotInsertFile()
315 Core::slotNewComposer()
321 Core::slotAttachFile()
327 Core::send(
int how )
333 Core::addAttachment(
const KURL &url,
const TQString &comment )
339 Core::setBody(
const TQString &body )
341 m_currentEditor->setText( body );
345 Core::addAttachment(
const TQString &name,
346 const TQCString &cte,
347 const TQByteArray &data,
348 const TQCString &type,
349 const TQCString &subType,
350 const TQCString ¶mAttr,
351 const TQString ¶mValue,
352 const TQCString &contDisp )
DCOP interface for mail composer window.