Messagelib

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

KDE's Doxygen guidelines are available online.