support finding paths from the current context
svn path=/trunk/KDE/kdebase/runtime/; revision=1171722
This commit is contained in:
parent
0c6ed54a52
commit
7a533c24fb
@ -147,9 +147,19 @@ void JavaScriptRunner::reportError(ScriptEnv *env, bool fatal)
|
|||||||
kDebug() << env->engine()->uncaughtExceptionBacktrace();
|
kDebug() << env->engine()->uncaughtExceptionBacktrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString JavaScriptRunner::filePath(const char *type, const QString &file) const
|
||||||
|
{
|
||||||
|
const QString path = m_env->filePathFromScriptContext(type, file);
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return package()->filePath(type, file);
|
||||||
|
}
|
||||||
|
|
||||||
bool JavaScriptRunner::include(const QString &script)
|
bool JavaScriptRunner::include(const QString &script)
|
||||||
{
|
{
|
||||||
const QString path = package()->filePath("scripts", script);
|
const QString path = filePath("scripts", script);
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -51,12 +51,12 @@ public:
|
|||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
bool include(const QString &script);
|
bool include(const QString &script);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void setupObjects();
|
void setupObjects();
|
||||||
void importExtensions();
|
void importExtensions();
|
||||||
void reportError(ScriptEnv *engine, bool fatal);
|
void reportError(ScriptEnv *engine, bool fatal);
|
||||||
|
QString filePath(const char *type, const QString &file) const;
|
||||||
|
|
||||||
private:
|
|
||||||
QScriptEngine *m_engine;
|
QScriptEngine *m_engine;
|
||||||
ScriptEnv *m_env;
|
ScriptEnv *m_env;
|
||||||
QScriptValue m_self;
|
QScriptValue m_self;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user