Commit 7eafb03d authored by Laurent Montel's avatar Laurent Montel 😁

Extract url info too

parent 766eb3a2
......@@ -49,7 +49,11 @@ void GrammarResultTextEdit::applyGrammarResult(const QVector<GrammarError> &info
QTextCharFormat format;
//Verify color
format.setBackground(info.color().isValid() ? info.color() : QColor(Qt::red));
format.setToolTip(info.error());
QString toolTip = info.error();
if (!info.url().isEmpty()) {
toolTip += QLatin1Char('\n') + i18n("See on: %1", info.url());
}
format.setToolTip(toolTip);
MessageComposer::PluginGrammarAction act;
act.setLength(info.length());
act.setStart(info.start());
......
......@@ -39,10 +39,16 @@ void LanguageToolGrammarError::parse(const QJsonObject &obj, int blockindex)
mSuggestions = parseSuggestion(obj);
//TODO generate specific color!
mColor = QColor(Qt::red);
const QJsonArray urlArray = obj[QStringLiteral("urls")].toArray();
if (!urlArray.isEmpty()) {
mUrl = urlArray.at(0)[QLatin1String("urls")].toString();
const QJsonObject rulesObj = obj[QStringLiteral("rule")].toObject();
if (!rulesObj.isEmpty()) {
const QJsonArray urlArray = rulesObj[QStringLiteral("urls")].toArray();
if (!urlArray.isEmpty()) {
mUrl = urlArray.at(0)[QLatin1String("value")].toString();
//qDebug() << " mUrl" << mUrl;
}
}
//TODO ???
// mRule = obj[QStringLiteral("sRuleId")].toString();
// mOption = obj[QStringLiteral("sType")].toString();
......
......@@ -72,7 +72,7 @@ void LanguageToolWidget::slotCheckGrammar()
job->setUrl(QStringLiteral("https://languagetool.org/api/v2/check"));
job->setNetworkAccessManager(mNetworkAccessManager);
job->setText(mInput->toPlainText());
job->setLanguage(QStringLiteral("en"));
job->setLanguage(QStringLiteral("fr"));
connect(job, &LanguageToolResultJob::finished, this, &LanguageToolWidget::slotResultFinished);
connect(job, &LanguageToolResultJob::error, this, &LanguageToolWidget::slotError);
job->start();
......
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