KTextAddons

richtextbrowser.h
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "textcustomeditor_export.h"
10#include <QTextBrowser>
11
13class QMenu;
14namespace TextCustomEditor
15{
16/**
17 * @brief The RichTextBrowser class
18 * @author Laurent Montel <montel@kde.org>
19 */
20class TEXTCUSTOMEDITOR_EXPORT RichTextBrowser : public QTextBrowser
21{
22 Q_OBJECT
23 Q_PROPERTY(bool searchSupport READ searchSupport WRITE setSearchSupport)
24 Q_PROPERTY(bool textToSpeechSupport READ textToSpeechSupport WRITE setTextToSpeechSupport)
25 Q_PROPERTY(bool webShortcutSupport READ webShortcutSupport WRITE setWebShortcutSupport)
26public:
27 explicit RichTextBrowser(QWidget *parent = nullptr);
28 ~RichTextBrowser() override;
29 enum SupportFeature {
30 None = 0,
31 Search = 1,
32 TextToSpeech = 4,
33 AllowWebShortcut = 16,
34 };
35 Q_DECLARE_FLAGS(SupportFeatures, SupportFeature)
36
37 void setSearchSupport(bool b);
38 [[nodiscard]] bool searchSupport() const;
39
40 [[nodiscard]] bool textToSpeechSupport() const;
41 void setTextToSpeechSupport(bool b);
42
43 void setWebShortcutSupport(bool b);
44 [[nodiscard]] bool webShortcutSupport() const;
45
46 void setDefaultFontSize(int val);
47 [[nodiscard]] int zoomFactor() const;
48
49public Q_SLOTS:
50 void slotDisplayMessageIndicator(const QString &message);
51 void slotSpeakText();
52 void slotZoomReset();
53
54protected:
55 virtual void addExtraMenuEntry(QMenu *menu, QPoint pos);
56 void contextMenuEvent(QContextMenuEvent *event) override;
57 bool event(QEvent *ev) override;
58 void keyPressEvent(QKeyEvent *event) override;
59 void wheelEvent(QWheelEvent *e) override;
60
61 QMenu *mousePopupMenu(QPoint pos);
62
63Q_SIGNALS:
64 void say(const QString &text);
65 void findText();
66
67private:
68 TEXTCUSTOMEDITOR_NO_EXPORT void slotUndoableClear();
69
70 TEXTCUSTOMEDITOR_NO_EXPORT bool handleShortcut(QKeyEvent *event);
71 TEXTCUSTOMEDITOR_NO_EXPORT bool overrideShortcut(QKeyEvent *event);
72 TEXTCUSTOMEDITOR_NO_EXPORT void deleteWordBack();
73 TEXTCUSTOMEDITOR_NO_EXPORT void deleteWordForward();
74 TEXTCUSTOMEDITOR_NO_EXPORT void moveLineUpDown(bool moveUp);
75 TEXTCUSTOMEDITOR_NO_EXPORT void moveCursorBeginUpDown(bool moveUp);
76 TEXTCUSTOMEDITOR_NO_EXPORT void regenerateColorScheme();
77 TEXTCUSTOMEDITOR_NO_EXPORT void updateReadOnlyColor();
78 class RichTextBrowserPrivate;
79 std::unique_ptr<RichTextBrowserPrivate> const d;
80};
81}
The RichTextBrowser class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:29:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.