Commit 93ff2b8f authored by Laurent Montel's avatar Laurent Montel 😁

Improve job

parent 21bab554
......@@ -20,7 +20,6 @@
#include "grammalectegenerateconfigoptionjob.h"
#include "grammalecteplugin_debug.h"
#include <QProcess>
GrammalecteGenerateConfigOptionJob::GrammalecteGenerateConfigOptionJob(QObject *parent)
: QObject(parent)
{
......@@ -38,11 +37,11 @@ void GrammalecteGenerateConfigOptionJob::start()
mProcess = new QProcess(this);
mProcess->setProgram(mPythonPath);
mProcess->setArguments(QStringList() << mGrammarlecteCliPath << QStringLiteral("-lo"));
// connect(mProcess, QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished), this, &GrammalecteGenerateConfigOptionJob::slotFinished);
connect(mProcess, QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished), this, &GrammalecteGenerateConfigOptionJob::slotFinished);
// connect(mProcess, QOverload<QProcess::ProcessError>::of(&QProcess::error),
// this, &GrammalecteGenerateConfigOptionJob::receivedError);
// connect(mProcess, &QProcess::readyReadStandardError, this, &GrammalecteGenerateConfigOptionJob::receivedStdErr);
// connect(mProcess, &QProcess::readyReadStandardOutput, this, &GrammalecteGenerateConfigOptionJob::receivedStandardOutput);
connect(mProcess, &QProcess::readyReadStandardOutput, this, &GrammalecteGenerateConfigOptionJob::receivedStandardOutput);
mProcess->start();
if (!mProcess->waitForStarted()) {
qCWarning(KMAIL_EDITOR_GRAMMALECTE_PLUGIN_LOG) << "Impossible to start GrammalecteGenerateConfigOptionJob";
......@@ -83,3 +82,19 @@ void GrammalecteGenerateConfigOptionJob::setGrammarlecteCliPath(const QString &g
{
mGrammarlecteCliPath = grammarlecteCliPath;
}
void GrammalecteGenerateConfigOptionJob::receivedStandardOutput()
{
mResult += QString::fromUtf8(mProcess->readAllStandardOutput());
}
void GrammalecteGenerateConfigOptionJob::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
if (exitStatus != 0 || exitCode != 0) {
qDebug() << " ERROR :!!!!!!!!!!!!!!!!!!!!";
} else {
//TODO fixit !
Q_EMIT finished(QStringList() << mResult);
}
deleteLater();
}
......@@ -21,8 +21,9 @@
#define GRAMMALECTEGENERATECONFIGOPTIONJOB_H
#include <QObject>
#include <QProcess>
#include "libgrammalect_private_export.h"
class QProcess;
class LIBGRAMMALECTPRIVATE_TESTS_EXPORT GrammalecteGenerateConfigOptionJob : public QObject
{
Q_OBJECT
......@@ -44,6 +45,8 @@ Q_SIGNALS:
void finished(const QStringList &result);
private:
void receivedStandardOutput();
void slotFinished(int exitCode, QProcess::ExitStatus exitStatus);
QString mResult;
QString mPythonPath;
QString mGrammarlecteCliPath;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment