Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5b83b214 authored by Laurent Montel's avatar Laurent Montel 😁

Improve plugin

parent 0b6c3f22
......@@ -43,6 +43,7 @@ void GrammalecteResultWidget::checkGrammar()
job->setArguments(GrammalecteManager::self()->options());
job->setText(mResult->toPlainText());
connect(job, &GrammalecteResultJob::finished, this, &GrammalecteResultWidget::slotCheckGrammarFinished);
connect(job, &GrammalecteResultJob::error, this, &GrammalecteResultWidget::slotError);
job->start();
}
......@@ -54,3 +55,7 @@ void GrammalecteResultWidget::slotCheckGrammarFinished(const QString &result)
applyGrammarResult(parser.parseResult(fields));
}
void GrammalecteResultWidget::slotError()
{
//TODO
}
......@@ -36,6 +36,7 @@ public:
void checkGrammar() override;
private:
void slotCheckGrammarFinished(const QString &result);
void slotError();
};
#endif // GRAMMALECTERESULTWIDGET_H
......@@ -58,3 +58,13 @@ void LanguagetoolManager::saveSettings()
{
//TODO
}
QString LanguagetoolManager::language() const
{
return mLanguage;
}
void LanguagetoolManager::setLanguage(const QString &language)
{
mLanguage = language;
}
......@@ -37,7 +37,11 @@ public:
void loadSettings();
void saveSettings();
Q_REQUIRED_RESULT QString language() const;
void setLanguage(const QString &language);
private:
QString mLanguage;
QNetworkAccessManager *mNetworkAccessManager = nullptr;
};
......
......@@ -20,6 +20,7 @@
#include "grammarresulttextedit.h"
#include "languagetoolresultwidget.h"
#include "languagetoolparser.h"
#include "languagetoolmanager.h"
#include "languagetoolresultjob.h"
#include <QJsonDocument>
#include <QTextEdit>
......@@ -35,13 +36,25 @@ LanguagetoolResultWidget::~LanguagetoolResultWidget()
void LanguagetoolResultWidget::checkGrammar()
{
LanguagetoolResultJob *job = new LanguagetoolResultJob(this);
job->setUrl(LanguagetoolManager::self()->languageToolPath());
job->setNetworkAccessManager(LanguagetoolManager::self()->networkAccessManager());
job->setText(mResult->toPlainText());
job->setLanguage(LanguagetoolManager::self()->language());
connect(job, &LanguagetoolResultJob::finished, this, &LanguagetoolResultWidget::slotCheckGrammarFinished);
connect(job, &LanguagetoolResultJob::error, this, &LanguagetoolResultWidget::slotError);
job->start();
}
void LanguagetoolResultWidget::slotCheckGrammarFinished(const QString &result)
{
// GrammalecteParser parser;
// const QJsonDocument doc = QJsonDocument::fromJson(result.toUtf8());
// const QJsonObject fields = doc.object();
// applyGrammarResult(parser.parseResult(fields));
LanguageToolParser parser;
const QJsonDocument doc = QJsonDocument::fromJson(result.toUtf8());
const QJsonObject fields = doc.object();
applyGrammarResult(parser.parseResult(fields));
}
void LanguagetoolResultWidget::slotError()
{
//TODO
}
......@@ -36,6 +36,7 @@ public:
void checkGrammar() override;
private:
void slotCheckGrammarFinished(const QString &result);
void slotError();
};
#endif // LANGUAGETOOLRESULTWIDGET_H
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