Add SpellChecking to NeoChat

Fix #98
This commit is contained in:
Carl Schwan
2021-06-07 11:31:22 +02:00
parent 23bd73c499
commit 8f309ca958
5 changed files with 144 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
// Copyright (c) 2020 Christian Mollekopf <mollekopf@kolabsystems.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
#include <QTextDocument>
#include <QSyntaxHighlighter>
#include <Sonnet/Speller>
#include <Sonnet/GuessLanguage>
class SpellcheckHighlighter: public QSyntaxHighlighter
{
public:
SpellcheckHighlighter(QTextDocument *parent);
protected:
void highlightBlock(const QString &text) override;
private:
void autodetectLanguage(const QString &sentence);
QTextCharFormat mErrorFormat;
QTextCharFormat mQuoteFormat;
QScopedPointer<Sonnet::Speller> mSpellchecker;
QScopedPointer<Sonnet::GuessLanguage> mLanguageGuesser;
};