Console line with simple auto completion
This commit is contained in:
+87
-4
@@ -13,6 +13,7 @@
|
|||||||
#include <QChart>
|
#include <QChart>
|
||||||
#include <QChartView>
|
#include <QChartView>
|
||||||
#include <QLineSeries>
|
#include <QLineSeries>
|
||||||
|
#include <QCompleter>
|
||||||
#include "scriptengine.h"
|
#include "scriptengine.h"
|
||||||
#include "chartgraph.h"
|
#include "chartgraph.h"
|
||||||
|
|
||||||
@@ -110,6 +111,35 @@ BatchProcessing::BatchProcessing(Database *database, QWidget *parent) : QDialog(
|
|||||||
|
|
||||||
_textColor = _ui->log->palette().text().color();
|
_textColor = _ui->log->palette().text().color();
|
||||||
|
|
||||||
|
_engine = new Script::ScriptEngine(_database, this);
|
||||||
|
connect(_engine, &Script::ScriptEngine::newMessage, this, &BatchProcessing::newMessage);
|
||||||
|
QStringList apiList;
|
||||||
|
apiList << "core.log" << "core.mark" << "core.unmark" << "core.isMarked" << "core.getObjects" << "core.setMaxthread";
|
||||||
|
apiList << "core.sync" << "core.getString" << "core.getInt" << "core.getFloat" << "core.question" << "core.plot";
|
||||||
|
apiList << "fileName" << "absoluteFileName";
|
||||||
|
_completerModel = new QStringListModel(this);
|
||||||
|
_completerModel->setStringList(apiList);
|
||||||
|
_completer = new QCompleter(_completerModel, this);
|
||||||
|
_ui->consoleLineEdit->setCompleter(_completer);
|
||||||
|
connect(_ui->executeButton, &QPushButton::clicked, _ui->consoleLineEdit, &QLineEdit::returnPressed);
|
||||||
|
connect(_ui->consoleLineEdit, &QLineEdit::returnPressed, [this](){
|
||||||
|
if(!_completer->popup()->isVisible())
|
||||||
|
{
|
||||||
|
QString program = _ui->consoleLineEdit->text();
|
||||||
|
QJSValue val = _engine->eval(program);
|
||||||
|
_ui->consoleLineEdit->addLine();
|
||||||
|
qDebug() << val.toString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(_ui->consoleLineEdit, &QLineEdit::textEdited, [this](const QString &text){
|
||||||
|
QStringList comp = _engine->complete(text);
|
||||||
|
qDebug() << comp;
|
||||||
|
_completerModel->setStringList(comp);
|
||||||
|
});
|
||||||
|
|
||||||
|
_ui->addFilesButton->setAutoDefault(false);
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
_ui->outputPath->setText(settings.value("batchprocessing/outputpath", QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first()).toString());
|
_ui->outputPath->setText(settings.value("batchprocessing/outputpath", QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first()).toString());
|
||||||
}
|
}
|
||||||
@@ -143,6 +173,15 @@ void BatchProcessing::closeEvent(QCloseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BatchProcessing::refreshPaths()
|
||||||
|
{
|
||||||
|
QStringList paths;
|
||||||
|
for(int i=0; i<_ui->pathsList->count(); i++)
|
||||||
|
paths.append(_ui->pathsList->item(i)->text());
|
||||||
|
_paths = scanDirectories(paths);
|
||||||
|
_engine->setParams("", _paths, _ui->outputPath->text());
|
||||||
|
}
|
||||||
|
|
||||||
void BatchProcessing::addFiles()
|
void BatchProcessing::addFiles()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@@ -152,6 +191,7 @@ void BatchProcessing::addFiles()
|
|||||||
_ui->pathsList->addItems(files);
|
_ui->pathsList->addItems(files);
|
||||||
settings.setValue("batchprocessing/inputpath", QFileInfo(files.first()).absolutePath());
|
settings.setValue("batchprocessing/inputpath", QFileInfo(files.first()).absolutePath());
|
||||||
}
|
}
|
||||||
|
refreshPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchProcessing::addDir()
|
void BatchProcessing::addDir()
|
||||||
@@ -163,6 +203,7 @@ void BatchProcessing::addDir()
|
|||||||
_ui->pathsList->addItem(dir);
|
_ui->pathsList->addItem(dir);
|
||||||
settings.setValue("batchprocessing/inputpath", dir);
|
settings.setValue("batchprocessing/inputpath", dir);
|
||||||
}
|
}
|
||||||
|
refreshPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchProcessing::addMarked()
|
void BatchProcessing::addMarked()
|
||||||
@@ -174,17 +215,20 @@ void BatchProcessing::addMarked()
|
|||||||
if(info.exists() && info.isReadable())
|
if(info.exists() && info.isReadable())
|
||||||
_ui->pathsList->addItem(file);
|
_ui->pathsList->addItem(file);
|
||||||
};
|
};
|
||||||
|
refreshPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchProcessing::removePath()
|
void BatchProcessing::removePath()
|
||||||
{
|
{
|
||||||
for(auto &item : _ui->pathsList->selectedItems())
|
for(auto &item : _ui->pathsList->selectedItems())
|
||||||
delete item;
|
delete item;
|
||||||
|
refreshPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchProcessing::removeAllPaths()
|
void BatchProcessing::removeAllPaths()
|
||||||
{
|
{
|
||||||
_ui->pathsList->clear();
|
_ui->pathsList->clear();
|
||||||
|
refreshPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchProcessing::browse()
|
void BatchProcessing::browse()
|
||||||
@@ -208,9 +252,6 @@ void BatchProcessing::runScript()
|
|||||||
_engineThread = new Script::ScriptEngineThread(_database, this);
|
_engineThread = new Script::ScriptEngineThread(_database, this);
|
||||||
connect(_engineThread, &Script::ScriptEngineThread::newMessage, this, &BatchProcessing::newMessage);
|
connect(_engineThread, &Script::ScriptEngineThread::newMessage, this, &BatchProcessing::newMessage);
|
||||||
connect(_engineThread, &Script::ScriptEngineThread::finished, this, &BatchProcessing::scriptFinished);
|
connect(_engineThread, &Script::ScriptEngineThread::finished, this, &BatchProcessing::scriptFinished);
|
||||||
QStringList paths;
|
|
||||||
for(int i=0; i<_ui->pathsList->count(); i++)
|
|
||||||
paths.append(_ui->pathsList->item(i)->text());
|
|
||||||
|
|
||||||
QFileInfo outDir(_ui->outputPath->text());
|
QFileInfo outDir(_ui->outputPath->text());
|
||||||
if(outDir.exists() && outDir.isWritable())
|
if(outDir.exists() && outDir.isWritable())
|
||||||
@@ -221,7 +262,7 @@ void BatchProcessing::runScript()
|
|||||||
else
|
else
|
||||||
script = ":/scripts/" + script;
|
script = ":/scripts/" + script;
|
||||||
|
|
||||||
_engineThread->setParams(script, scanDirectories(paths), _ui->outputPath->text());
|
_engineThread->setParams(script, _paths, _ui->outputPath->text());
|
||||||
_engineThread->start();
|
_engineThread->start();
|
||||||
_ui->startButton->setEnabled(false);
|
_ui->startButton->setEnabled(false);
|
||||||
_ui->stopButton->setEnabled(true);
|
_ui->stopButton->setEnabled(true);
|
||||||
@@ -329,6 +370,48 @@ void BatchProcessing::plot(const QVariant &graph)
|
|||||||
chart->plot(graph);
|
chart->plot(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConsoleLine::ConsoleLine(QWidget *parent) : QLineEdit(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleLine::addLine()
|
||||||
|
{
|
||||||
|
QString line = text();
|
||||||
|
clear();
|
||||||
|
if(_history.size() && _history.last() == line)return;
|
||||||
|
|
||||||
|
_history.append(line);
|
||||||
|
if(_history.size() > 100)_history.removeFirst();
|
||||||
|
_currentLine = _history.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleLine::keyReleaseEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if(event->key() == Qt::Key_Up)
|
||||||
|
{
|
||||||
|
_currentLine--;
|
||||||
|
if(_currentLine < 0)
|
||||||
|
{
|
||||||
|
_currentLine = -1;
|
||||||
|
clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setText(_history.at(_currentLine));
|
||||||
|
}
|
||||||
|
else if(event->key() == Qt::Key_Down)
|
||||||
|
{
|
||||||
|
_currentLine++;
|
||||||
|
if(_currentLine >= _history.size())
|
||||||
|
{
|
||||||
|
_currentLine = _history.size();
|
||||||
|
clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setText(_history.at(_currentLine));
|
||||||
|
}
|
||||||
|
else QLineEdit::keyReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void openDir(const QString &path)
|
void openDir(const QString &path)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
|
#include <QStringListModel>
|
||||||
|
#include <QCompleter>
|
||||||
|
#include <QLineEdit>
|
||||||
#include "scriptengine.h"
|
#include "scriptengine.h"
|
||||||
|
|
||||||
namespace Ui { class BatchProcessing; }
|
namespace Ui { class BatchProcessing; }
|
||||||
@@ -16,8 +19,12 @@ class BatchProcessing : public QDialog
|
|||||||
QString _scriptBasePath;
|
QString _scriptBasePath;
|
||||||
QFileSystemWatcher _fileWatcher;
|
QFileSystemWatcher _fileWatcher;
|
||||||
Script::ScriptEngineThread *_engineThread = nullptr;
|
Script::ScriptEngineThread *_engineThread = nullptr;
|
||||||
|
Script::ScriptEngine *_engine = nullptr;
|
||||||
QColor _textColor;
|
QColor _textColor;
|
||||||
Database *_database;
|
Database *_database;
|
||||||
|
QStringListModel *_completerModel = nullptr;
|
||||||
|
QCompleter *_completer = nullptr;
|
||||||
|
QList<QPair<QString, QString>> _paths;
|
||||||
private slots:
|
private slots:
|
||||||
void scanScriptDir();
|
void scanScriptDir();
|
||||||
public:
|
public:
|
||||||
@@ -25,6 +32,7 @@ public:
|
|||||||
~BatchProcessing();
|
~BatchProcessing();
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
void refreshPaths();
|
||||||
public slots:
|
public slots:
|
||||||
void addFiles();
|
void addFiles();
|
||||||
void addDir();
|
void addDir();
|
||||||
@@ -47,6 +55,18 @@ public slots:
|
|||||||
void plot(const QVariant &graph);
|
void plot(const QVariant &graph);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ConsoleLine : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ConsoleLine(QWidget *parent = nullptr);
|
||||||
|
void addLine();
|
||||||
|
void keyReleaseEvent(QKeyEvent *event) override;
|
||||||
|
private:
|
||||||
|
int _currentLine = 0;
|
||||||
|
QStringList _history;
|
||||||
|
};
|
||||||
|
|
||||||
void openDir(const QString &path);
|
void openDir(const QString &path);
|
||||||
|
|
||||||
#endif // BATCHPROCESSING_H
|
#endif // BATCHPROCESSING_H
|
||||||
|
|||||||
+63
-33
@@ -43,6 +43,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add files</string>
|
<string>Add files</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -50,6 +53,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add directories</string>
|
<string>Add directories</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -57,6 +63,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add marked</string>
|
<string>Add marked</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -64,6 +73,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remove</string>
|
<string>Remove</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -71,6 +83,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remove all</string>
|
<string>Remove all</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -98,6 +113,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Browse</string>
|
<string>Browse</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -129,6 +147,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open scripts</string>
|
<string>Open scripts</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -171,23 +192,30 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<widget class="ConsoleLine" name="consoleLineEdit">
|
||||||
<property name="orientation">
|
<property name="placeholderText">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string>Console</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
</widget>
|
||||||
<size>
|
</item>
|
||||||
<width>40</width>
|
<item>
|
||||||
<height>20</height>
|
<widget class="QPushButton" name="executeButton">
|
||||||
</size>
|
<property name="text">
|
||||||
|
<string>Execute</string>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="startButton">
|
<widget class="QPushButton" name="startButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Start script</string>
|
<string>Start script</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -198,12 +226,8 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Stop script</string>
|
<string>Stop script</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="autoDefault">
|
||||||
</item>
|
<bool>false</bool>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="closeButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Close</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -211,23 +235,29 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>ConsoleLine</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>batchprocessing.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>pathsList</tabstop>
|
||||||
|
<tabstop>addFilesButton</tabstop>
|
||||||
|
<tabstop>addDirButton</tabstop>
|
||||||
|
<tabstop>addMarkedButton</tabstop>
|
||||||
|
<tabstop>removeButton</tabstop>
|
||||||
|
<tabstop>removeAllButton</tabstop>
|
||||||
|
<tabstop>browseButton</tabstop>
|
||||||
|
<tabstop>openScriptsButton</tabstop>
|
||||||
|
<tabstop>scriptsList</tabstop>
|
||||||
|
<tabstop>consoleLineEdit</tabstop>
|
||||||
|
<tabstop>startButton</tabstop>
|
||||||
|
<tabstop>stopButton</tabstop>
|
||||||
|
<tabstop>outputPath</tabstop>
|
||||||
|
<tabstop>log</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>closeButton</sender>
|
|
||||||
<signal>released()</signal>
|
|
||||||
<receiver>BatchProcessing</receiver>
|
|
||||||
<slot>close()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>973</x>
|
|
||||||
<y>745</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>511</x>
|
|
||||||
<y>383</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
+65
-5
@@ -4,6 +4,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
#include <QJSValueIterator>
|
||||||
#include "loadrunable.h"
|
#include "loadrunable.h"
|
||||||
#include "rawimage.h"
|
#include "rawimage.h"
|
||||||
#include "loadimage.h"
|
#include "loadimage.h"
|
||||||
@@ -40,7 +41,7 @@ ScriptEngine::ScriptEngine(Database *database, BatchProcessing *parent)
|
|||||||
void ScriptEngine::setParams(const QString &scriptPath, const QList<QPair<QString, QString>> &paths, const QString &outputDir)
|
void ScriptEngine::setParams(const QString &scriptPath, const QList<QPair<QString, QString>> &paths, const QString &outputDir)
|
||||||
{
|
{
|
||||||
_scriptPath = scriptPath;
|
_scriptPath = scriptPath;
|
||||||
_paths = paths;
|
setPaths(paths);
|
||||||
_outputDir = outputDir + "/";
|
_outputDir = outputDir + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,14 +418,73 @@ QJSValue ScriptEngine::newArray(uint size)
|
|||||||
return _jsEngine->newArray(size);
|
return _jsEngine->newArray(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEngine::run()
|
QJSValue ScriptEngine::eval(const QString &program)
|
||||||
{
|
{
|
||||||
QJSValue jsPaths = _jsEngine->newArray(_paths.size());
|
QStringList stackTrace;
|
||||||
for(qsizetype i=0; i<_paths.size(); i++)
|
QJSValue result = _jsEngine->evaluate(program, QString(), 1, &stackTrace);
|
||||||
jsPaths.setProperty(i, _jsEngine->newQObject(new File(_paths[i].first, _paths[i].second, this)));
|
|
||||||
|
if(result.isError())
|
||||||
|
{
|
||||||
|
QString error = result.property("name").toString() + " on line " + result.property("lineNumber").toString() + " : " + result.toString();
|
||||||
|
error += "\n" + result.property("stack").toString();
|
||||||
|
emit newMessage(error, true);
|
||||||
|
}
|
||||||
|
else if(!result.isUndefined())
|
||||||
|
{
|
||||||
|
emit newMessage(result.toString(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList ScriptEngine::complete(const QString &line)
|
||||||
|
{
|
||||||
|
QStringList complete;
|
||||||
|
|
||||||
|
QJSValue globObj = _jsEngine->globalObject();
|
||||||
|
|
||||||
|
QRegularExpression reg("[a-zA-Z_][a-zA-Z0-9_]*");
|
||||||
|
auto match = reg.match(line);
|
||||||
|
if(match.hasMatch())
|
||||||
|
{
|
||||||
|
QString var = match.captured();
|
||||||
|
if(globObj.hasProperty(var))
|
||||||
|
{
|
||||||
|
complete.clear();
|
||||||
|
QJSValueIterator it(globObj.property(var));
|
||||||
|
while(it.hasNext())
|
||||||
|
{
|
||||||
|
it.next();
|
||||||
|
if((it.value().isCallable() || it.value().isObject()) && it.name() != "contructor" && it.name() != "objectNameChanged")
|
||||||
|
complete.append(var + "." + it.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QJSValueIterator it(globObj);
|
||||||
|
while(it.hasNext())
|
||||||
|
{
|
||||||
|
it.next();
|
||||||
|
complete.append(it.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return complete;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptEngine::setPaths(const QList<QPair<QString, QString> > &paths)
|
||||||
|
{
|
||||||
|
_paths = paths;
|
||||||
|
QJSValue jsPaths = _jsEngine->newArray(paths.size());
|
||||||
|
for(qsizetype i=0; i<paths.size(); i++)
|
||||||
|
jsPaths.setProperty(i, _jsEngine->newQObject(new File(paths[i].first, paths[i].second, this)));
|
||||||
|
|
||||||
_jsEngine->globalObject().setProperty("files", jsPaths);
|
_jsEngine->globalObject().setProperty("files", jsPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptEngine::run()
|
||||||
|
{
|
||||||
QFile scriptFile(_scriptPath);
|
QFile scriptFile(_scriptPath);
|
||||||
if(!scriptFile.open(QIODevice::ReadOnly))
|
if(!scriptFile.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ public:
|
|||||||
#endif // PLATESOLVER
|
#endif // PLATESOLVER
|
||||||
QJSValue newObject();
|
QJSValue newObject();
|
||||||
QJSValue newArray(uint size);
|
QJSValue newArray(uint size);
|
||||||
|
QJSValue eval(const QString &program);
|
||||||
|
QStringList complete(const QString &line);
|
||||||
|
void setPaths(const QList<QPair<QString, QString>> &paths);
|
||||||
public slots:
|
public slots:
|
||||||
void run();
|
void run();
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
Reference in New Issue
Block a user