KPimTextEdit

richtextcomposeremailquotehighlighter.h
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kpimtextedit_export.h"
10#include <memory>
11#include <sonnet/highlighter.h>
12namespace KPIMTextEdit
13{
14class RichTextComposer;
15/**
16 * @short A highlighter for email quoting.
17 *
18 * @author Laurent Montel <montel@kde.org>
19 */
20class RichTextComposer;
21class KPIMTEXTEDIT_EXPORT RichTextComposerEmailQuoteHighlighter : public Sonnet::Highlighter
22{
23 Q_OBJECT
24public:
25 /**
26 * Constructor. See setQuoteColor() for the parameters.
27 * FIXME: Default colors don't obey color scheme
28 */
29 explicit RichTextComposerEmailQuoteHighlighter(RichTextComposer *textEdit,
30 const QColor &normalColor = Qt::black,
31 const QColor &quoteDepth1 = QColor(0x00, 0x80, 0x00),
32 const QColor &quoteDepth2 = QColor(0x00, 0x80, 0x00),
33 const QColor &quoteDepth3 = QColor(0x00, 0x80, 0x00),
34 const QColor &misspelledColor = Qt::red);
35
36 ~RichTextComposerEmailQuoteHighlighter() override;
37
38 /**
39 * Sets the colors used for highlighting quoted text and spelling mistakes.
40 *
41 * @param quoteDepth1 color for text quoted 1 level deep
42 * @param quoteDepth2 color for text quoted 2 level deep
43 * @param quoteDepth3 color for text quoted 3 level deep
44 * @param misspelledColor color in which misspelled words will be underlined
45 * @param normalColor will be ignored, only provided for KNode
46 * compatibility.
47 */
48 void setQuoteColor(const QColor &normalColor,
49 const QColor &quoteDepth1,
50 const QColor &quoteDepth2,
51 const QColor &quoteDepth3,
52 const QColor &misspelledColor = Qt::red);
53
54 /**
55 * Turns spellcheck highlighting on or off.
56 *
57 * @param on if true, spelling mistakes will be highlighted
58 */
59 void toggleSpellHighlighting(bool on);
60
61 /**
62 * Reimplemented to highlight quote blocks.
63 */
64 void highlightBlock(const QString &text) override;
65
66protected:
67 /**
68 * Reimplemented, the base version sets the text color to black, which
69 * is not what we want. We do nothing, the format is already reset by
70 * Qt.
71 * @param start the beginning of text
72 * @param count the amount of characters to set
73 */
74 void unsetMisspelled(int start, int count) override;
75
76 /**
77 * Reimplemented to set the color of the misspelled word to a color
78 * defined by setQuoteColor().
79 */
80 void setMisspelled(int start, int count) override;
81
82private:
83 class RichTextComposerEmailQuoteHighlighterPrivate;
84 std::unique_ptr<RichTextComposerEmailQuoteHighlighterPrivate> const d;
85};
86}
Q_SCRIPTABLE Q_NOREPLY void start()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.