• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • interfaces
 

interfaces

  • interfaces
  • kscript
scriptloader.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 #include "scriptloader.h"
20 
21 #include <kapplication.h>
22 #include <kparts/part.h>
23 #include <kparts/componentfactory.h>
24 #include <kglobal.h>
25 #include <klocale.h>
26 #include <kconfig.h>
27 #include <kdesktopfile.h>
28 #include <kstandarsdirs.h>
29 #include <kstdaccel.h>
30 #include <kdebug.h>
31 
32 #include <tqdir.h>
33 #include <tqfileinfo.h>
34 
35 
36 ScriptLoader::ScriptLoader(KMainWindow *parent) : TQObject (parent)
37 {
38  m_parent = parent;
39  m_scripts.clear();
40  m_theAction = new KSelectAction ( i18n("KDE Scripts"),
41  0,
42  this,
43  TQT_SLOT(runAction()),
44  m_parent->actionCollection(),
45  "scripts");
46 }
47 
48 ScriptLoader::~ScriptLoader()
49 {
50  // Clean out the list
51  m_scripts.clear();
52 }
53 
54 KSelectAction * ScriptLoader::getScripts()
55 {
56  // Get the available scripts for this application.
57  TQStringList pluginList = "";
58  // Find plugins
59  TQString searchPath = kapp->name();
60  searchPath += "/scripts/";
61  TQDir d(locate( "data", searchPath));
62  kdDebug() << "loading plugin from " << locate( "data", searchPath) << endl;
63  const QFileInfoList *fileList = d.entryInfoList("*.desktop");
64  QFileInfoListIterator it ( *fileList );
65  TQFileInfo *fi;
66  // Find all available script desktop files
67  while( (fi=it.current()))
68  {
69  // Query each desktop file
70  if(KDesktopFile::isDesktopFile(fi->absFilePath()))
71  {
72  KDesktopFile desktop((fi->absFilePath()), true);
73  kdDebug () << "Trying to load script type: " << desktop.readType() << endl;
74  KScriptInterface *tmpIface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>(desktop.readType() );
75  if( tmpIface != 0 )
76  {
77  m_scripts.append(tmpIface);
78  m_scripts.current()->setScript(desktop.readURL());
79  //if(m_parent != 0)
80  //m_scripts.current()->setParent(m_parent);
81  pluginList.append(desktop.readName());
82  }
83  else
84  kdDebug() << desktop.readName() << " could not be loaded!" << endl;
85  }
86  ++it;
87  }
88  m_theAction->clear();
89  m_theAction->setItems(pluginList);
90  return m_theAction;
91 }
92 
93 void ScriptLoader::runAction()
94 {
95  TQString scriptName = m_theAction->currentText();
96 
97 }
98 
99 void ScriptLoader::stopAction()
100 {
101 
102 }
103 
104 #include "scriptloader.moc"
KDesktopFile
KDesktopFile::isDesktopFile
static bool isDesktopFile(const TQString &path)
KDesktopFile::readType
TQString readType() const
KDesktopFile::readName
TQString readName() const
KDesktopFile::readURL
TQString readURL() const
KMainWindow
KScriptInterface
This class is the base for all script engines.
Definition: scriptinterface.h:48
KSelectAction
KSelectAction::setItems
virtual void setItems(const TQStringList &lst)
KSelectAction::clear
virtual void clear()
KSelectAction::currentText
virtual TQString currentText() const
KXMLGUIClient::actionCollection
virtual KActionCollection * actionCollection() const
ScriptLoader::runAction
void runAction()
Run the current action.
Definition: scriptloader.cpp:93
ScriptLoader::ScriptLoader
ScriptLoader(KMainWindow *parent=0)
Default Constructor.
Definition: scriptloader.cpp:36
ScriptLoader::stopAction
void stopAction()
Stop the currently running scripts operations.
Definition: scriptloader.cpp:99
ScriptLoader::getScripts
KSelectAction * getScripts()
Return the a KSelectAction with all of the scripts.
Definition: scriptloader.cpp:54
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
locate
TQString locate(const char *type, const TQString &filename, const KInstance *instance=KGlobal::instance())
klocale.h

interfaces

Skip menu "interfaces"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

interfaces

Skip menu "interfaces"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for interfaces by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |