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 HELPVIEWER_H
5#define HELPVIEWER_H
6
7#include <QtCore/qglobal.h>
8#include <QtCore/QUrl>
9
10#include <QtGui/QFont>
11#include <QtGui/QTextDocument>
12
13#include <QtWidgets/QWidget>
14
15QT_BEGIN_NAMESPACE
16
17class HelpViewerPrivate;
18
19class HelpViewer : public QWidget
20{
21 Q_OBJECT
22public:
23 enum FindFlag {
24 FindBackward = 0x01,
25 FindCaseSensitively = 0x02
26 };
27 Q_DECLARE_FLAGS(FindFlags, FindFlag)
28
29 HelpViewer(qreal zoom, QWidget *parent = nullptr);
30 ~HelpViewer() override;
31
32 QFont viewerFont() const;
33 void setViewerFont(const QFont &font);
34
35 void scaleUp();
36 void scaleDown();
37
38 void resetScale();
39 qreal scale() const;
40
41 QString title() const;
42
43 QUrl source() const;
44 void reload();
45 void setSource(const QUrl &url);
46
47 void print(QPagedPaintDevice *printer);
48
49 QString selectedText() const;
50 bool isForwardAvailable() const;
51 bool isBackwardAvailable() const;
52
53 bool findText(const QString &text, FindFlags flags, bool incremental,
54 bool fromSearch);
55
56 static bool isLocalUrl(const QUrl &url);
57 static bool canOpenPage(const QString &url);
58 static QString mimeFromUrl(const QUrl &url);
59 static bool launchWithExternalApp(const QUrl &url);
60
61 // implementation detail, not a part of the interface
62 bool eventFilter(QObject *src, QEvent *event) override;
63
64public slots:
65#if QT_CONFIG(clipboard)
66 void copy();
67#endif
68 void home();
69 void forward();
70 void backward();
71
72signals:
73 void titleChanged();
74 void copyAvailable(bool yes);
75 void sourceChanged(const QUrl &url);
76 void forwardAvailable(bool enabled);
77 void backwardAvailable(bool enabled);
78 void highlighted(const QUrl &link);
79 void printRequested();
80 void loadFinished();
81private:
82 void doSetSource(const QUrl &url, bool reload);
83
84 HelpViewerPrivate *d;
85};
86
87QT_END_NAMESPACE
88
89#endif // HELPVIEWER_H
90

source code of qttools/src/assistant/assistant/helpviewer.h