Messagelib

webenginepage.h
1 /*
2  SPDX-FileCopyrightText: 2016-2023 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "webengineviewer_export.h"
10 #include <QWebEnginePage>
11 class QWebEngineProfile;
12 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
13 class QWebEngineDownloadItem;
14 #else
15 class QWebEngineDownloadRequest;
16 #endif
17 class QPrinter;
18 namespace WebEngineViewer
19 {
20 class WebHitTest;
21 /**
22  * @brief The WebEnginePage class
23  * @author Laurent Montel <[email protected]>
24  */
25 class WEBENGINEVIEWER_EXPORT WebEnginePage : public QWebEnginePage
26 {
27  Q_OBJECT
28 public:
29  /**
30  * Constructor.
31  *
32  * A private QWebEngineProfile, only applying to this QWebEnginePage,
33  * will be created to implement browser settings. It can be accessed via
34  * @c profile(), but it should not be shared or reused unless care is
35  * taken that the profile is not deleted until all of the QWebEnginePage's
36  * belonging to it are deleted first.
37  *
38  * @param parent The parent object
39  **/
40  explicit WebEnginePage(QObject *parent = nullptr);
41 
42  /**
43  * Constructor.
44  *
45  * The specified QWebEngineProfile will be used. See the description of
46  * @c WebEnginePage(QObject *) and the API documentation of QWebEnginePage
47  * for caution regarding the lifetime of the profile.
48  *
49  * @param profile The profile to be used
50  * @param parent The parent object
51  * @deprecated Use the single argument constructor, which creates and uses
52  * a private profile.
53  **/
54 #ifndef WEBENGINEVIEWER_NO_DEPRECATED
55  explicit WEBENGINEVIEWER_DEPRECATED WebEnginePage(QWebEngineProfile *profile, QObject *parent = nullptr);
56 #endif
57 
58  /**
59  * Destructor. If there is a private QWebEngineProfile then it will also
60  * be destroyed.
61  **/
62  ~WebEnginePage() override = default;
63 
64  WebEngineViewer::WebHitTest *hitTestContent(const QPoint &pos);
65 
66 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
67  void saveHtml(QWebEngineDownloadItem *download);
68 #else
69  void saveHtml(QWebEngineDownloadRequest *download);
70 #endif
71  Q_REQUIRED_RESULT bool execPrintPreviewPage(QPrinter *printer, int timeout);
72 
73  Q_REQUIRED_RESULT QPoint mapToViewport(const QPoint &pos) const;
74 Q_SIGNALS:
75  void urlClicked(const QUrl &url);
76  void showConsoleMessage(const QString &message);
77 
78 protected:
79  bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override;
80  void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override;
81 
82 private:
83  void init();
84 };
85 }
The WebHitTest class.
Definition: webhittest.h:22
QCA_EXPORT void init()
The WebEnginePage class.
Definition: webenginepage.h:25
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:08:12 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.