Commit e2b5341c authored by Laurent Montel's avatar Laurent Montel 😁

Add networkmanager

parent a2ce969f
......@@ -19,8 +19,11 @@
#include "languagetoolmanager.h"
#include <QNetworkAccessManager>
LanguagetoolManager::LanguagetoolManager(QObject *parent)
: QObject(parent)
, mNetworkAccessManager(new QNetworkAccessManager(this))
{
}
......@@ -35,3 +38,8 @@ LanguagetoolManager *LanguagetoolManager::self()
static LanguagetoolManager s_self;
return &s_self;
}
QNetworkAccessManager *LanguagetoolManager::networkAccessManager() const
{
return mNetworkAccessManager;
}
......@@ -22,7 +22,7 @@
#include <QObject>
#include "libkmaillanguagetool_export.h"
class QNetworkAccessManager;
class LIBKMAILLANGUAGETOOL_EXPORT LanguagetoolManager : public QObject
{
Q_OBJECT
......@@ -30,6 +30,10 @@ public:
explicit LanguagetoolManager(QObject *parent = nullptr);
~LanguagetoolManager();
static LanguagetoolManager *self();
QNetworkAccessManager *networkAccessManager() const;
private:
QNetworkAccessManager *mNetworkAccessManager = nullptr;
};
#endif // LANGUAGETOOLMANAGER_H
......@@ -20,6 +20,8 @@
#include "languagetoolresultjob.h"
#include "liblanguagetool_debug.h"
#include <QNetworkAccessManager>
LanguagetoolResultJob::LanguagetoolResultJob(QObject *parent)
: QObject(parent)
{
......@@ -33,8 +35,10 @@ LanguagetoolResultJob::~LanguagetoolResultJob()
bool LanguagetoolResultJob::canStart() const
{
//TODO
return false;
if (!mNetworkAccessManager) {
return false;
}
return true;
}
void LanguagetoolResultJob::start()
......@@ -43,4 +47,25 @@ void LanguagetoolResultJob::start()
qCWarning(LIBLANGUAGE_PLUGIN_LOG) << "Impossible to start language tool";
return;
}
//TODO
}
QStringList LanguagetoolResultJob::arguments() const
{
return mArguments;
}
void LanguagetoolResultJob::setArguments(const QStringList &arguments)
{
mArguments = arguments;
}
QNetworkAccessManager *LanguagetoolResultJob::networkAccessManager() const
{
return mNetworkAccessManager;
}
void LanguagetoolResultJob::setNetworkAccessManager(QNetworkAccessManager *networkAccessManager)
{
mNetworkAccessManager = networkAccessManager;
}
......@@ -21,7 +21,7 @@
#define LANGUAGETOOLRESULTJOB_H
#include <QObject>
class QNetworkAccessManager;
class LanguagetoolResultJob : public QObject
{
Q_OBJECT
......@@ -30,6 +30,19 @@ public:
~LanguagetoolResultJob();
bool canStart() const;
void start();
Q_REQUIRED_RESULT QStringList arguments() const;
void setArguments(const QStringList &arguments);
QNetworkAccessManager *networkAccessManager() const;
void setNetworkAccessManager(QNetworkAccessManager *networkAccessManager);
Q_SIGNALS:
void finished(const QString &result);
void error();
private:
Q_DISABLE_COPY(LanguagetoolResultJob)
QStringList mArguments;
QNetworkAccessManager *mNetworkAccessManager = nullptr;
};
#endif // LANGUAGETOOLRESULTJOB_H
......@@ -19,7 +19,8 @@
#include "grammarresulttextedit.h"
#include "languagetoolresultwidget.h"
#include <QHBoxLayout>
#include "languagetoolparser.h"
#include "languagetoolresultjob.h"
#include <QJsonDocument>
#include <QTextEdit>
......
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