File indexing completed on 2024-04-28 16:13:27

0001 /*
0002     SPDX-FileCopyrightText: 2018 Ralf Habacker ralf.habacker @freenet.de
0003 
0004     This file is part of libalkimia.
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #ifndef ALKWEBPAGE_H
0010 #define ALKWEBPAGE_H
0011 
0012 #include <alkimia/alk_export.h>
0013 
0014 #include <QObject>
0015 
0016 class QUrl;
0017 
0018 #if defined(BUILD_WITH_WEBENGINE)
0019 
0020 #include <QWebEnginePage>
0021 
0022 class ALK_EXPORT AlkWebPage : public QWebEnginePage
0023 {
0024     Q_OBJECT
0025 public:
0026     AlkWebPage(QWidget *parent = nullptr);
0027     virtual ~AlkWebPage();
0028 
0029     QWidget *widget();
0030     void load(const QUrl &url, const QString &acceptLanguage);
0031     QString toHtml();
0032     void setContent(const QString &s);
0033     QString getFirstElement(const QString &symbol);
0034     void setWebInspectorEnabled(bool state);
0035     bool webInspectorEnabled();
0036 
0037 Q_SIGNALS:
0038     void urlChanged(const QUrl &url);
0039 
0040 private:
0041     class Private;
0042     Private *d;
0043 };
0044 
0045 #elif defined(BUILD_WITH_WEBKIT)
0046 
0047 #include <QWebView>
0048 
0049 /**
0050  * The AlkWebPage class provides an interface
0051  * to a browser component
0052  * It is used for fetching and showing web pages.
0053  *
0054  * @author Ralf Habacker ralf.habacker @freenet.de
0055  */
0056 class ALK_EXPORT AlkWebPage : public QWebView
0057 {
0058 public:
0059     AlkWebPage(QWidget *parent = nullptr);
0060     virtual ~AlkWebPage();
0061 
0062     QWidget *widget();
0063     void load(const QUrl &url, const QString &acceptLanguage);
0064     QString toHtml();
0065     QString getFirstElement(const QString &symbol);
0066     void setWebInspectorEnabled(bool enable);
0067     bool webInspectorEnabled();
0068 
0069 private:
0070     class Private;
0071     Private *d;
0072 };
0073 
0074 #else
0075 
0076 #include <QTextBrowser>
0077 
0078 /**
0079  * The AlkWebPage class provides an interface
0080  * to a browser component with javascript support
0081  * It is used for fetching and showing web pages.
0082  *
0083  * @author Ralf Habacker ralf.habacker @freenet.de
0084  */
0085 class ALK_EXPORT AlkWebPage : public QTextBrowser
0086 {
0087     Q_OBJECT
0088 public:
0089     AlkWebPage(QWidget *parent = nullptr);
0090     virtual ~AlkWebPage();
0091 
0092     QWidget *widget();
0093     void load(const QUrl &url, const QString &acceptLanguage);
0094     void setUrl(const QUrl &url);
0095     void setContent(const QString &s);
0096     QString getFirstElement(const QString &symbol);
0097     void setWebInspectorEnabled(bool enable);
0098     bool webInspectorEnabled();
0099 Q_SIGNALS:
0100     void loadStarted();
0101     void loadFinished(bool);
0102 
0103 private:
0104     class Private;
0105     Private *d;
0106 };
0107 #endif
0108 
0109 #endif // ALKWEBPAGE_H