// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; -*- /** * core.cpp * * Copyright (C) 2003 Zack Rusin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ #include "core.h" #include "pluginmanager.h" #include "editor.h" #include "plugin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace Komposer; Core::Core( TQWidget *parent, const char *name ) : KomposerIface( "KomposerIface" ), KMainWindow( parent, name ), m_currentEditor( 0 ) { initWidgets(); initCore(); initConnections(); setInstance( new KInstance( "komposer" ) ); createActions(); setXMLFile( "komposerui.rc" ); createGUI( 0 ); resize( 600, 400 ); // initial size setAutoSaveSettings(); loadSettings(); } Core::~Core() { saveSettings(); //Prefs::self()->writeConfig(); } void Core::addEditor( Komposer::Editor *editor ) { if ( editor->widget() ) { m_stack->addWidget( editor->widget() ); m_stack->raiseWidget( editor->widget() ); editor->widget()->show(); m_currentEditor = editor; } // merge the editors GUI into the main window //insertChildClient( editor ); guiFactory()->addClient( editor ); } void Core::addPlugin( Komposer::Plugin *plugin ) { //insertChildClient( plugin ); guiFactory()->addClient( plugin ); } void Core::slotPluginLoaded( Plugin *plugin ) { kdDebug() << "Plugin loaded "<( plugin ); if ( editor ) { addEditor( editor ); } else { addPlugin( plugin ); } } void Core::slotAllPluginsLoaded() { TQValueList plugins = m_pluginManager->availablePlugins(); kdDebug()<<"Number of available plugins is "<< plugins.count() <::iterator it = plugins.begin(); it != plugins.end(); ++it ) { KPluginInfo *i = ( *it ); kdDebug()<<"\tAvailable plugin "<< i->pluginName() <<", comment = "<< i->comment() <visibleWidget() ) { m_pluginManager->loadPlugin( "komposer_defaulteditor", PluginManager::LoadAsync ); } } #if 0 void Core::slotActivePartChanged( KParts::Part *part ) { if ( !part ) { createGUI( 0 ); return; } kdDebug() << "Part activated: " << part << " with stack id. " << m_stack->id( part->widget() )<< endl; createGUI( part ); } void Core::selectEditor( Komposer::Editor *editor ) { if ( !editor ) return; KParts::Part *part = editor->part(); editor->select(); TQPtrList *partList = const_cast*>( m_partManager->parts() ); if ( partList->find( part ) == -1 ) addPart( part ); m_partManager->setActivePart( part ); TQWidget *view = part->widget(); Q_ASSERT( view ); kdDebug()<<"Raising view "<raiseWidget( view ); view->show(); view->setFocus(); m_currentEditor = editor; } } void Core::selectEditor( const TQString &editorName ) { } #endif void Core::loadSettings() { //kdDebug()<<"Trying to select "<< Prefs::self()->m_activeEditor <m_activeEditor ); //m_activeEditors = Prefs::self()->m_activeEditors; } void Core::saveSettings() { //if ( m_currentEditor ) //Prefs::self()->m_activeEditor = m_currentEditor->identifier(); } void Core::slotQuit() { kdDebug()<<"exit"<shutdown(); } void Core::slotPreferences() { if ( m_dlg == 0 ) m_dlg = new KSettings::Dialog( this ); m_dlg->show(); } void Core::initWidgets() { statusBar()->show(); TQHBox *topWidget = new TQHBox( this ); setCentralWidget( topWidget ); m_stack = new TQWidgetStack( topWidget ); } void Core::initCore() { m_pluginManager = new PluginManager( this ); connect( m_pluginManager, TQT_SIGNAL(pluginLoaded(Plugin*)), TQT_SLOT(slotPluginLoaded(Plugin*)) ); connect( m_pluginManager, TQT_SIGNAL(allPluginsLoaded()), TQT_SLOT(slotAllPluginsLoaded()) ); m_pluginManager->loadAllPlugins(); kdDebug()<<"Loading"<setText( body ); } void Core::addAttachment( const TQString &name, const TQCString &cte, const TQByteArray &data, const TQCString &type, const TQCString &subType, const TQCString ¶mAttr, const TQString ¶mValue, const TQCString &contDisp ) { } #include "core.moc"