status-desktop/src-cpp/dotherside/SpellChecker.h

52 lines
1.1 KiB
C
Raw Permalink Normal View History

2022-01-06 19:29:19 +00:00
#pragma once
#include <QObject>
#include <QQuickTextDocument>
#include <QSyntaxHighlighter>
#include <QVariant>
2022-01-06 19:29:19 +00:00
#ifdef Q_OS_MACOS
class Hunspell;
#endif
class QTextCodec;
class SpellChecker : public QObject
{
Q_OBJECT
Q_PROPERTY(QString lang READ lang WRITE setLang NOTIFY langChanged)
Q_PROPERTY(QString userDict READ userDict WRITE setUserDict NOTIFY userDictChanged)
public:
explicit SpellChecker(QObject* parent = nullptr);
2022-01-06 19:29:19 +00:00
~SpellChecker();
Q_INVOKABLE bool spell(const QString& word);
Q_INVOKABLE QVariantList suggest(const QString& word);
Q_INVOKABLE void ignoreWord(const QString& word);
Q_INVOKABLE void addToUserWordlist(const QString& word);
2022-01-06 19:29:19 +00:00
Q_INVOKABLE bool isInit() const;
const QString& lang() const;
void setLang(const QString& lang);
const QString& userDict() const;
void setUserDict(const QString& userDict);
signals:
void langChanged();
void userDictChanged();
private:
void initHunspell();
private:
QString m_lang;
QString m_userDict;
QQuickTextDocument* m_document;
2022-01-06 19:29:19 +00:00
#ifdef Q_OS_MACOS
Hunspell* m_hunspell;
2022-01-06 19:29:19 +00:00
#endif
QTextCodec* m_codec;
2022-01-06 19:29:19 +00:00
};