Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
helpviewerimpl.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef HELPVIEWERIMPL_H
5#define HELPVIEWERIMPL_H
6
7#include <QtCore/qglobal.h>
8#include <QtCore/QUrl>
9#include <QtCore/QVariant>
10
11#include <QtGui/QFont>
12
13#if defined(BROWSER_QTWEBKIT)
14# include <QWebView>
15#elif defined(BROWSER_QTEXTBROWSER)
16# include <QtWidgets/QTextBrowser>
17#endif
18
19#include "helpviewer.h"
20
22
23#if defined(BROWSER_QTWEBKIT)
24#define TEXTBROWSER_OVERRIDE
25class HelpViewerImpl : public QWebView
26#elif defined(BROWSER_QTEXTBROWSER)
27#define TEXTBROWSER_OVERRIDE override
28class HelpViewerImpl : public QTextBrowser
29#endif
30{
31 Q_OBJECT
32 class HelpViewerImplPrivate;
33
34public:
35 HelpViewerImpl(qreal zoom, QWidget *parent = nullptr);
36 ~HelpViewerImpl() override;
37
38 QFont viewerFont() const;
39 void setViewerFont(const QFont &font);
40
41 void scaleUp();
42 void scaleDown();
43
44 void resetScale();
45 qreal scale() const;
46
47 QString title() const;
48
49 QUrl source() const;
50 void doSetSource(const QUrl &url, QTextDocument::ResourceType type) TEXTBROWSER_OVERRIDE;
51
52 QString selectedText() const;
53 bool isForwardAvailable() const;
54 bool isBackwardAvailable() const;
55
56 bool findText(const QString &text, HelpViewer::FindFlags flags, bool incremental,
57 bool fromSearch);
58
59 static const QString AboutBlank;
60 static const QString LocalHelpFile;
61 static const QString PageNotFoundMessage;
62
63public slots:
64#if QT_CONFIG(clipboard)
65 void copy();
66#endif
67 void home() TEXTBROWSER_OVERRIDE;
68
69 void forward() TEXTBROWSER_OVERRIDE;
70 void backward() TEXTBROWSER_OVERRIDE;
71
72signals:
73 void titleChanged();
74#if !defined(BROWSER_QTEXTBROWSER)
75 // Provide signals present in QTextBrowser, QTextEdit for browsers that do not inherit QTextBrowser
76 void copyAvailable(bool yes);
77 void sourceChanged(const QUrl &url);
78 void forwardAvailable(bool enabled);
79 void backwardAvailable(bool enabled);
80 void highlighted(const QUrl &link);
81 void printRequested();
82#elif !defined(BROWSER_QTWEBKIT)
83 // Provide signals present in QWebView for browsers that do not inherit QWebView
84 void loadFinished(bool finished);
85#endif
86
87protected:
88 void keyPressEvent(QKeyEvent *e) override;
89 void wheelEvent(QWheelEvent *event) override;
90 void mousePressEvent(QMouseEvent *event) override;
91 void mouseReleaseEvent(QMouseEvent *event) override;
92 void resizeEvent(QResizeEvent *e) override;
93
94private slots:
95 void actionChanged();
96 void setLoadFinished();
97
98private:
99 bool eventFilter(QObject *obj, QEvent *event) override;
100 void contextMenuEvent(QContextMenuEvent *event) override;
101 QVariant loadResource(int type, const QUrl &name) TEXTBROWSER_OVERRIDE;
102 bool handleForwardBackwardMouseButtons(QMouseEvent *e);
103 void scrollToTextPosition(int position);
104
105private:
106 HelpViewerImplPrivate *d;
107};
108
109QT_END_NAMESPACE
110
111#endif // HELPVIEWERIMPL_H
static HelpEngineWrapper & instance()
HistoryItem currentHistoryItem() const
std::vector< HistoryItem > m_backItems
std::vector< HistoryItem > m_forwardItems
void applyZoom(int percentage)
QLiteHtmlWidget * m_viewer
void incrementZoom(int steps)
void setSourceInternal(const QUrl &url, int *vscroll=nullptr, bool reload=false)
void setViewerFont(const QFont &font)
void scaleUp()
QString title() const
void setSource(const QUrl &url)
void resetScale()
QString selectedText() const
void forward()
void scaleDown()
void reload()
bool isForwardAvailable() const
void backward()
QFont viewerFont() const
~HelpViewer() override
QUrl source() const
bool findText(const QString &text, FindFlags flags, bool incremental, bool fromSearch)
qreal scale() const
bool isBackwardAvailable() const
bool eventFilter(QObject *src, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
static QByteArray getData(const QUrl &url)
static QTextDocument::FindFlags textDocumentFlagsForFindFlags(HelpViewer::FindFlags flags)
const int kMaxHistoryItems
Combined button and popup list for selecting options.
const char * mimeType
const char * extension
#define TRACE_OBJ
Definition tracer.h:34