| # interfaces Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# scriptloader.cpp

    00001 /* This file is part of the KDE project
    00002    Copyright (C) 2001 Ian Reinhart Geiser  (geiseri@kde.org)
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License as published by the Free Software Foundation; either
    00007    version 2 of the License, or (at your option) any later version.
    00008
    00009    This library is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012    Library General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public License
    00015    along with this library; see the file COPYING.LIB.  If not, write to
    00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, USA.
    00018 */
    00019 #include "scriptloader.h"
    00020
    00021 #include <kapplication.h>
    00022 #include <kparts/part.h>
    00023 #include <kparts/componentfactory.h>
    00024 #include <kglobal.h>
    00025 #include <klocale.h>
    00026 #include <kconfig.h>
    00027 #include <kdesktopfile.h>
    00028 #include <kstandarsdirs.h>
    00029 #include <kstdaccel.h>
    00030 #include <kdebug.h>
    00031
    00032 #include <qdir.h>
    00033 #include <qfileinfo.h>
    00034
    00035
    00036 ScriptLoader::ScriptLoader(KMainWindow *parent) : QObject (parent)
    00037 {
    00038     m_parent = parent;
    00039     m_scripts.clear();
    00040     m_theAction = new KSelectAction ( i18n("KDE Scripts"),
    00041         0,
    00042         this,
    00043         SLOT(runAction()),
    00044         m_parent->actionCollection(),
    00045         "scripts");
    00046 }
    00047
    00048 ScriptLoader::~ScriptLoader()
    00049 {
    00050     // Clean out the list
    00051     m_scripts.clear();
    00052 }
    00053
    00054 KSelectAction * ScriptLoader::getScripts()
    00055 {
    00056     // Get the available scripts for this application.
    00057     QStringList pluginList = "";
    00058     // Find plugins
    00059     QString searchPath = kapp->name();
    00060     searchPath += "/scripts/";
    00061     QDir d(locate( "data", searchPath));
    00062     kdDebug() << "loading plugin from " << locate( "data", searchPath) << endl;
    00063     const QFileInfoList *fileList = d.entryInfoList("*.desktop");
    00064     QFileInfoListIterator it ( *fileList );
    00065     QFileInfo *fi;
    00066     // Find all available script desktop files
    00067     while( (fi=it.current()))
    00068     {
    00069     // Query each desktop file
    00070         if(KDesktopFile::isDesktopFile(fi->absFilePath()))
    00071         {
    00072             KDesktopFile desktop((fi->absFilePath()), true);
    00073             kdDebug () << "Trying to load script type: " << desktop.readType() << endl;
    00074             KScriptInterface *tmpIface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>(desktop.readType() );
    00075             if( tmpIface != 0 )
    00076             {
    00077                 m_scripts.append(tmpIface);
    00078                 m_scripts.current()->setScript(desktop.readURL());
    00079                 //if(m_parent != 0)
    00080                     //m_scripts.current()->setParent(m_parent);
    00081                 pluginList.append(desktop.readName());
    00082             }
    00083             else
    00084                 kdDebug() << desktop.readName() << " could not be loaded!" << endl;
    00085         }
    00086         ++it;
    00087     }
    00088     m_theAction->clear();
    00089     m_theAction->setItems(pluginList);
    00090     return m_theAction;
    00091 }
    00092
    00093 void ScriptLoader::runAction()
    00094 {
    00095     QString scriptName = m_theAction->currentText();
    00096
    00097 }
    00098
    00099 void ScriptLoader::stopAction()
    00100 {
    00101
    00102 }
    00103
    00104 #include "scriptloader.moc"

This file is part of the documentation for interfaces Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:34:57 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003