File indexing completed on 2024-05-19 05:01:19
0001 /* 0002 This file is part of the KDE project. 0003 0004 SPDX-FileCopyrightText: 2021 Stefano Crocco <posta@stefanocrocco.it> 0005 0006 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0007 */ 0008 0009 #ifndef SPELLCHECKERMANAGER_H 0010 #define SPELLCHECKERMANAGER_H 0011 0012 #include <QObject> 0013 #include <QMap> 0014 #include <QDateTime> 0015 0016 #include <Sonnet/Speller> 0017 0018 class QMenu; 0019 class KActionCollection; 0020 class QWidget; 0021 class WebEnginePage; 0022 class QWebEngineProfile; 0023 0024 class SpellCheckerManager : public QObject 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 SpellCheckerManager(QWebEngineProfile *profile, QObject *parent=nullptr); 0030 ~SpellCheckerManager(); 0031 0032 QMenu *spellCheckingMenu(const QStringList &suggestions, KActionCollection *coll, WebEnginePage *page); 0033 0034 public slots: 0035 void updateConfiguration(bool spellCheckingEnabled); 0036 0037 private: 0038 void removeLanguage(const QString &lang); 0039 void addLanguage(const QString &lang); 0040 void detectDictionaries(); 0041 static QString dictionaryDir(); 0042 0043 private slots: 0044 void spellCheckingToggled(bool on); 0045 0046 private: 0047 QString m_dictionaryDir; 0048 QMap<QString, QString> m_dicts; 0049 QStringList m_enabledDicts; 0050 Sonnet::Speller m_speller; 0051 QWebEngineProfile *m_profile; 0052 }; 0053 0054 #endif // SPELLCHECKERMANAGER_H