Alkimia API

alkwebpage.h
1/*
2 SPDX-FileCopyrightText: 2018, 2024 Ralf Habacker ralf.habacker @freenet.de
3
4 This file is part of libalkimia.
5
6 SPDX-License-Identifier: LGPL-2.1-or-later
7*/
8
9#ifndef ALKWEBPAGE_H
10#define ALKWEBPAGE_H
11
12#include <alkimia/alk_export.h>
13
14#include <QObject>
15
16class QUrl;
17
18#if defined(BUILD_WITH_WEBENGINE)
19
20#include <QWebEnginePage>
21
22/**
23 * The AlkWebPage class provides an object for loading
24 * web documents in order to offer functionality such
25 * as AlkWebView in a widgetless environment.
26 *
27 * @author Ralf Habacker ralf.habacker @freenet.de
28 */
29class ALK_EXPORT AlkWebPage : public QWebEnginePage
30{
31 Q_OBJECT
32public:
33 explicit AlkWebPage(QWidget *parent = nullptr);
34 virtual ~AlkWebPage();
35
36 void load(const QUrl &url, const QString &acceptLanguage);
38 QStringList getAllElements(const QString &symbol);
39 QString getFirstElement(const QString &symbol);
40 /// Set timeout [ms] for AlkWebPage::toHtml()
41 void setTimeout(int timeout = -1);
42 int timeout();
43
44Q_SIGNALS:
45 void loadRedirectedTo(const QUrl &url);
46
47private:
48 class Private;
49 Private *d;
50
51 bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override;
52};
53
54#elif defined(BUILD_WITH_WEBKIT)
55
56#include <QWebPage>
57
58/**
59 * The AlkWebPage class provides an object for loading
60 * web documents in order to offer functionality such
61 * as AlkWebView in a widgetless environment.
62 *
63 * @author Ralf Habacker ralf.habacker @freenet.de
64 */
65class ALK_EXPORT AlkWebPage : public QWebPage
66{
67 Q_OBJECT
68public:
69 explicit AlkWebPage(QObject *parent = nullptr);
70 virtual ~AlkWebPage();
71
72 void load(const QUrl &url, const QString &acceptLanguage);
73 void setHtml(const QString &data);
75 QStringList getAllElements(const QString &symbol);
76 QString getFirstElement(const QString &symbol);
77 void setTimeout(int timeout = -1) { Q_UNUSED(timeout) }
78 int timeout() { return -1; }
79
80Q_SIGNALS:
81 void loadRedirectedTo(const QUrl&);
82
83private:
84 class Private;
85 Private *d;
86};
87
88#else
89
90#include <QTextBrowser>
91
92/**
93 * The AlkWebPage class provides an object to load
94 * and view web documents to provide functionality
95 * like AlkWebView in a widget-less environment.
96 *
97 * @author Ralf Habacker ralf.habacker @freenet.de
98 */
99class ALK_EXPORT AlkWebPage : public QTextBrowser
100{
101 Q_OBJECT
102public:
103 explicit AlkWebPage(QWidget *parent = nullptr);
104 virtual ~AlkWebPage();
105
106 void load(const QUrl &url, const QString &acceptLanguage);
107 void setUrl(const QUrl &url);
108 QStringList getAllElements(const QString &symbol);
109 QString getFirstElement(const QString &symbol);
110 void setTimeout(int timeout = -1) { Q_UNUSED(timeout) }
111 int timeout() { return -1; }
112
113Q_SIGNALS:
114 void loadStarted();
115 void loadFinished(bool);
116 void loadRedirectedTo(const QUrl&);
117
118private:
119 class Private;
120 Private *d;
121 QVariant loadResource(int type, const QUrl &name) override;
122};
123#endif
124
125#endif // ALKWEBPAGE_H
The AlkWebPage class provides an object to load and view web documents to provide functionality like ...
Definition alkwebpage.h:100
QAction * load(const QObject *recvr, const char *slot, QObject *parent)
Trait::String toHtml(std::shared_ptr< Document< Trait > > doc, bool wrapInBodyTag=true, const typename Trait::String &hrefForRefBackImage={}, bool wrapInArticle=true)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.