diff --git a/QCodeEditor/resources/languages/qml.xml b/QCodeEditor/resources/languages/qml.xml index ed20ea9b..20d520de 100644 --- a/QCodeEditor/resources/languages/qml.xml +++ b/QCodeEditor/resources/languages/qml.xml @@ -129,5 +129,6 @@ ParamList TcpHub QMiniMp3 + CodeLoader diff --git a/codeloader.cpp b/codeloader.cpp index f1cff1bc..97abf51f 100644 --- a/codeloader.cpp +++ b/codeloader.cpp @@ -383,6 +383,25 @@ bool CodeLoader::lispUpload(QString codeStr, QString editorPath) return lispUpload(vb); } +bool CodeLoader::lispUploadFromPath(QString path) +{ + QFile f(path); + if (f.open(QIODevice::ReadOnly)) { + QFileInfo fi(f); + VByteArray lispData = lispPackImports(f.readAll(), fi.canonicalPath()); + f.close(); + + if (!lispData.isEmpty()) { + bool ok = lispErase(lispData.size() + 100); + if (ok) { + return lispUpload(lispData); + } + } + } + + return false; +} + bool CodeLoader::lispStream(VByteArray vb, qint8 mode) { if (!mVesc->isPortConnected()) { diff --git a/codeloader.h b/codeloader.h index b28c53d2..31de0e70 100644 --- a/codeloader.h +++ b/codeloader.h @@ -39,6 +39,7 @@ class CodeLoader : public QObject QPair > > lispUnpackImports(QByteArray data); bool lispUpload(VByteArray vb); bool lispUpload(QString codeStr, QString editorPath = QDir::currentPath()); + Q_INVOKABLE bool lispUploadFromPath(QString path); bool lispStream(VByteArray vb, qint8 mode); QString lispRead(QWidget *parent, QString &lispPath);