Add convert function to script
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QDebug>
|
||||
#include "loadrunable.h"
|
||||
#include "rawimage.h"
|
||||
#include "loadrunable.h"
|
||||
|
||||
namespace Script
|
||||
{
|
||||
@@ -11,6 +12,7 @@ namespace Script
|
||||
ScriptEngine::ScriptEngine(QObject *parent) : QObject(parent)
|
||||
, _jsEngine(new QJSEngine(this))
|
||||
, _database(new Database(this))
|
||||
, _pool(new QThreadPool(this))
|
||||
{
|
||||
QJSValue engine = _jsEngine->newQObject(this);
|
||||
_jsEngine->globalObject().setProperty("engine", engine);
|
||||
@@ -64,6 +66,24 @@ bool ScriptEngine::isMarked(const File *file) const
|
||||
return _database->isMarked(file->absoluteFilePath());
|
||||
}
|
||||
|
||||
bool ScriptEngine::convert(File *file, QString &outpath, QJSValue ¶ms)
|
||||
{
|
||||
QString format = params.toString();
|
||||
QString path;
|
||||
QDir dir(_outputDir);
|
||||
QFileInfo info(outpath);
|
||||
QString suffix = info.suffix();
|
||||
if(info.isAbsolute())
|
||||
path = info.absolutePath();
|
||||
else
|
||||
path = dir.absoluteFilePath(outpath);
|
||||
|
||||
info.setFile(path);
|
||||
//qDebug() << info.absolutePath() + "/" + info.completeBaseName() + "." + format.toLower();
|
||||
_pool->start(new ConvertRunable(file->absoluteFilePath(), info.absolutePath() + "/" + info.completeBaseName() + "." + format.toLower(), format));
|
||||
return true;
|
||||
}
|
||||
|
||||
QJSValue ScriptEngine::newObject()
|
||||
{
|
||||
return _jsEngine->newObject();
|
||||
|
||||
Reference in New Issue
Block a user