Commit f45aa1fd authored by Simon Depiets's avatar Simon Depiets
Browse files

Only check LT for source and HTML escaping

parent aa6653e6
......@@ -470,7 +470,7 @@ bool TsStorage::isPlural(const DocPosition& pos) const
void TsStorage::setApproved(const DocPosition& pos, bool approved)
{
targetInsert(pos, QString()); //adds <taget> if needed
targetInsert(pos, QString()); //adds <target> if needed
QDomElement target = unitForPos(pos.entry).firstChildElement(names[TargetTag]); //asking directly to bypass plural state detection
if (target.attribute(attrnames[TypeAttr]) == attrvalues[ObsoleteVal])
return;
......
......@@ -80,6 +80,7 @@ void LanguageToolResultJob::start()
QNetworkRequest request(QUrl::fromUserInput(mUrl));
addRequestAttribute(request);
const QByteArray ba = "text=" + mText.toUtf8() + "&language=" + mLanguage.toLatin1();
//qCWarning(LOKALIZE_LOG) << "Sending LT query" << ba;
QNetworkReply *reply = mNetworkAccessManager->post(request, ba);
connect(reply, &QNetworkReply::finished, this, &LanguageToolResultJob::slotCheckGrammarFinished);
connect(mNetworkAccessManager, &QNetworkAccessManager::finished, this, &LanguageToolResultJob::slotFinish);
......
......@@ -135,10 +135,10 @@ TranslationUnitTextEdit::TranslationUnitTextEdit(Catalog* catalog, DocPosition::
if (part == DocPosition::Target) {
connect(document(), &QTextDocument::contentsChange, this, &TranslationUnitTextEdit::contentsChanged);
connect(this, &KTextEdit::cursorPositionChanged, this, &TranslationUnitTextEdit::emitCursorPositionChanged);
connect(m_languageToolTimer, &QTimer::timeout, this, &TranslationUnitTextEdit::launchLanguageTool);
}
connect(catalog, QOverload<>::of(&Catalog::signalFileLoaded), this, &TranslationUnitTextEdit::fileLoaded);
//connect (Project::instance(), &Project::configChanged, this, &TranslationUnitTextEdit::projectConfigChanged);
connect(m_languageToolTimer, &QTimer::timeout, this, &TranslationUnitTextEdit::launchLanguageTool);
m_languageToolTimer->setSingleShot(true);
}
......@@ -924,8 +924,6 @@ void insertContent(QTextCursor& cursor, const CatalogString& catStr, const Catal
return text;
}
void TranslationUnitTextEdit::emitCursorPositionChanged() {
emit cursorPositionChanged(textCursor().columnNumber());
}
......@@ -1171,10 +1169,11 @@ void insertContent(QTextCursor& cursor, const CatalogString& catStr, const Catal
void TranslationUnitTextEdit::launchLanguageTool() {
if (toPlainText().length() == 0)
return;
LanguageToolResultJob *job = new LanguageToolResultJob(this);
job->setUrl(LanguageToolManager::self()->languageToolCheckPath());
job->setNetworkAccessManager(LanguageToolManager::self()->networkAccessManager());
job->setText(toPlainText());
job->setText(toPlainText().toHtmlEscaped().replace(QStringLiteral("%"), QStringLiteral("%25")));
job->setLanguage(m_catalog->targetLangCode());
connect(job, &LanguageToolResultJob::finished, this, &TranslationUnitTextEdit::slotLanguageToolFinished);
connect(job, &LanguageToolResultJob::error, this, &TranslationUnitTextEdit::slotLanguageToolError);
......
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