make package and mainScript part of ScriptEngine

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796106
This commit is contained in:
Aaron J. Seigo 2008-04-12 15:23:15 +00:00
parent 8e45bf56db
commit 99c036a212
4 changed files with 54 additions and 3 deletions

View File

@ -17,9 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include "runnerscript.h" #include "plasma/scripting/runnerscript.h"
#include "abstractrunner.h" #include "plasma/abstractrunner.h"
#include "plasma/package.h"
namespace Plasma namespace Plasma
{ {
@ -62,6 +63,20 @@ void RunnerScript::exec(const Plasma::SearchContext *search, const Plasma::Searc
Q_UNUSED(action) Q_UNUSED(action)
} }
const Package* RunnerScript::package() const
{
return 0;
}
QString RunnerScript::mainScript() const
{
if (!package()) {
return QString();
} else {
return package()->filePath("mainscript");
}
}
} // Plasma namespace } // Plasma namespace
#include "runnerscript.moc" #include "runnerscript.moc"

View File

@ -70,6 +70,19 @@ public:
*/ */
virtual void exec(const Plasma::SearchContext *search, const Plasma::SearchMatch *action); virtual void exec(const Plasma::SearchContext *search, const Plasma::SearchMatch *action);
protected Q_SLOTS:
/**
* @return absolute path to the main script file for this plasmoid
*/
QString mainScript() const;
/**
* @return the Package associated with this plasmoid which can
* be used to request resources, such as images and
* interface files.
*/
const Package* package() const;
private: private:
class Private; class Private;
Private * const d; Private * const d;

View File

@ -51,6 +51,16 @@ bool ScriptEngine::init()
return true; return true;
} }
const Package* ScriptEngine::package() const
{
return 0;
}
QString ScriptEngine::mainScript() const
{
return QString();
}
QStringList knownLanguages(ComponentTypes types) QStringList knownLanguages(ComponentTypes types)
{ {
QString constraintTemplate = "'%1' in [X-Plasma-ComponentTypes]"; QString constraintTemplate = "'%1' in [X-Plasma-ComponentTypes]";

View File

@ -70,8 +70,21 @@ public:
*/ */
virtual bool init(); virtual bool init();
protected Q_SLOTS:
/**
* @return absolute path to the main script file for this plasmoid
*/
virtual QString mainScript() const;
/**
* @return the Package associated with this plasmoid which can
* be used to request resources, such as images and
* interface files.
*/
virtual const Package* package() const;
private: private:
class Private; class Private;
Private * const d; Private * const d;
}; };