KPimTextEdit

plaintexteditor.h
1 /*
2  SPDX-FileCopyrightText: 2013-2020 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef PLAINTEXTEDITOR_H
8 #define PLAINTEXTEDITOR_H
9 
10 #include "kpimtextedit_export.h"
11 
12 #include <QPlainTextEdit>
13 
14 namespace Sonnet {
15 class Highlighter;
16 class SpellCheckDecorator;
17 }
18 namespace KPIMTextEdit {
23 class KPIMTEXTEDIT_EXPORT PlainTextEditor : public QPlainTextEdit
24 {
25  Q_OBJECT
26  Q_PROPERTY(bool searchSupport READ searchSupport WRITE setSearchSupport)
27  Q_PROPERTY(bool spellCheckingSupport READ spellCheckingSupport WRITE setSpellCheckingSupport)
28  Q_PROPERTY(bool textToSpeechSupport READ textToSpeechSupport WRITE setTextToSpeechSupport)
29  Q_PROPERTY(bool webShortcutSupport READ webShortcutSupport WRITE setWebShortcutSupport)
30 public:
31  explicit PlainTextEditor(QWidget *parent = nullptr);
32  ~PlainTextEditor() override;
33 
34  enum SupportFeature {
35  None = 0,
36  Search = 1,
37  SpellChecking = 2,
38  TextToSpeech = 4,
39  AllowWebShortcut = 8
40  };
41  Q_DECLARE_FLAGS(SupportFeatures, SupportFeature)
42 
43  void setSearchSupport(bool b);
44  Q_REQUIRED_RESULT bool searchSupport() const;
45 
46  Q_REQUIRED_RESULT bool spellCheckingSupport() const;
47  void setSpellCheckingSupport(bool check);
48 
49  virtual void setReadOnly(bool readOnly);
50 
51  void setTextToSpeechSupport(bool b);
52  Q_REQUIRED_RESULT bool textToSpeechSupport() const;
53 
54  void setWebShortcutSupport(bool b);
55  Q_REQUIRED_RESULT bool webShortcutSupport() const;
56 
57  virtual void createHighlighter();
58 
59  void addIgnoreWords(const QStringList &lst);
60  Q_REQUIRED_RESULT bool activateLanguageMenu() const;
61  void setActivateLanguageMenu(bool activate);
62  Q_REQUIRED_RESULT Sonnet::Highlighter *highlighter() const;
63  bool checkSpellingEnabled() const;
64  void setCheckSpellingEnabled(bool check);
65  void setSpellCheckingConfigFileName(const QString &_fileName);
66  Q_REQUIRED_RESULT QString spellCheckingConfigFileName() const;
67  const QString &spellCheckingLanguage() const;
68  void setSpellCheckingLanguage(const QString &_language);
69 public Q_SLOTS:
70  void slotDisplayMessageIndicator(const QString &message);
71  void slotCheckSpelling();
72  void slotSpeakText();
73  void slotZoomReset();
74 private Q_SLOTS:
75  void slotUndoableClear();
76  void slotSpellCheckerMisspelling(const QString &text, int pos);
77  void slotSpellCheckerCorrected(const QString &, int, const QString &);
78  void slotSpellCheckerAutoCorrect(const QString &, const QString &);
79  void slotSpellCheckerCanceled();
80  void slotSpellCheckerFinished();
81 
82  void slotLanguageSelected();
83  void slotToggleAutoSpellCheck();
84 protected:
85  virtual void addExtraMenuEntry(QMenu *menu, QPoint pos);
86 
87 protected:
88  void contextMenuEvent(QContextMenuEvent *event) override;
89  Q_REQUIRED_RESULT bool event(QEvent *ev) override;
90  void keyPressEvent(QKeyEvent *event) override;
91  Q_REQUIRED_RESULT bool overrideShortcut(QKeyEvent *event);
92  Q_REQUIRED_RESULT bool handleShortcut(QKeyEvent *event);
93  void wheelEvent(QWheelEvent *event) override;
94 
95  virtual Sonnet::SpellCheckDecorator *createSpellCheckDecorator();
96  void setHighlighter(Sonnet::Highlighter *_highLighter);
97  void focusInEvent(QFocusEvent *event) override;
98  virtual void updateHighLighter();
99  virtual void clearDecorator();
100 
101 Q_SIGNALS:
102  void findText();
103  void replaceText();
104  void spellCheckerAutoCorrect(const QString &currentWord, const QString &autoCorrectWord);
105  void checkSpellingChanged(bool);
106  void languageChanged(const QString &);
107  void spellCheckStatus(const QString &);
108  void say(const QString &text);
109 
110 private:
111  void addIgnoreWordsToHighLighter();
112  void deleteWordBack();
113  void deleteWordForward();
114  void highlightWord(int length, int pos);
115  void deleteEndOfLine();
116  void moveLineUpDown(bool moveUp);
117  void moveCursorBeginUpDown(bool moveUp);
118  class PlainTextEditorPrivate;
119  PlainTextEditorPrivate *const d;
120 };
121 }
122 #endif // PLAINTEXTEDITOR_H
The TextToSpeech class.
Definition: texttospeech.h:20
The PlainTextEditor class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 23:09:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.