summaryrefslogtreecommitdiff
path: root/plugins/webengine
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/webengine')
-rw-r--r--plugins/webengine/CMakeLists.txt12
-rw-r--r--plugins/webengine/WebEngine.json4
-rw-r--r--plugins/webengine/webengineplugin.cpp13
-rw-r--r--plugins/webengine/webengineplugin.hpp23
-rw-r--r--plugins/webengine/webview.cpp25
-rw-r--r--plugins/webengine/webview.h25
6 files changed, 102 insertions, 0 deletions
diff --git a/plugins/webengine/CMakeLists.txt b/plugins/webengine/CMakeLists.txt
new file mode 100644
index 00000000..8a11bc76
--- /dev/null
+++ b/plugins/webengine/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_library(WebEnginePlugin MODULE
+ webengineplugin.cpp webengineplugin.hpp
+ webview.cpp webview.h
+ ${PROJECT_SOURCE_DIR}/src/plugins/rplugininterface.hpp
+ ${PROJECT_SOURCE_DIR}/src/plugins/rview.hpp
+)
+target_include_directories(WebEnginePlugin PRIVATE ${PROJECT_SOURCE_DIR}/src/plugins)
+target_link_libraries(WebEnginePlugin PUBLIC Qt6::Core Qt6::WebEngineWidgets)
+
+if(TESTING)
+ add_test(NAME "load_plugin WebEnginePlugin" COMMAND load_plugin $<TARGET_FILE:WebEnginePlugin>)
+endif()
diff --git a/plugins/webengine/WebEngine.json b/plugins/webengine/WebEngine.json
new file mode 100644
index 00000000..03e2112c
--- /dev/null
+++ b/plugins/webengine/WebEngine.json
@@ -0,0 +1,4 @@
+{
+ "name": "WebEngine",
+ "schemes": [ "file", "http", "https" ]
+}
diff --git a/plugins/webengine/webengineplugin.cpp b/plugins/webengine/webengineplugin.cpp
new file mode 100644
index 00000000..cf6811dc
--- /dev/null
+++ b/plugins/webengine/webengineplugin.cpp
@@ -0,0 +1,13 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================
+ * Description: WebEngine plugin View factory
+ * ============================================================ */
+
+#include "webengineplugin.hpp"
+#include "webview.h"
+
+rView *WebEnginePlugin::view(const QUrl &url) { return new WebView(url, nullptr); }
diff --git a/plugins/webengine/webengineplugin.hpp b/plugins/webengine/webengineplugin.hpp
new file mode 100644
index 00000000..3ee63ff8
--- /dev/null
+++ b/plugins/webengine/webengineplugin.hpp
@@ -0,0 +1,23 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================
+ * Description: WebEngine plugin View factory
+ * ============================================================ */
+
+#pragma once
+
+#include <rplugininterface.hpp>
+
+class WebEnginePlugin final : public RekonqPluginInterface {
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID RekonqPluginInterface_iid FILE "WebEngine.json")
+ Q_INTERFACES(RekonqPluginInterface)
+
+public:
+ WebEnginePlugin() = default;
+
+ rView *view(const QUrl &url) override;
+};
diff --git a/plugins/webengine/webview.cpp b/plugins/webengine/webview.cpp
new file mode 100644
index 00000000..1aef01e2
--- /dev/null
+++ b/plugins/webengine/webview.cpp
@@ -0,0 +1,25 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================
+ * Description: Qt WebEngine View
+ * ============================================================ */
+
+#include "webview.h"
+#include <QVBoxLayout>
+#include <QWebEngineView>
+
+WebView::WebView(const QUrl &url, QWidget *parent) : rView(url, parent), view(new QWebEngineView(this))
+{
+ auto *layout = new QVBoxLayout;
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(view);
+ setLayout(layout);
+
+ connect(view, &QWebEngineView::iconChanged, this, [this](const QIcon &icon) { emit iconChanged(icon); });
+ connect(view, &QWebEngineView::urlChanged, this, [this](const QUrl &url) { emit urlChanged(url); });
+ connect(view, &QWebEngineView::titleChanged, this, [this](const QString &title) { emit titleChanged(title); });
+ view->load(url);
+}
diff --git a/plugins/webengine/webview.h b/plugins/webengine/webview.h
new file mode 100644
index 00000000..0b8d0dae
--- /dev/null
+++ b/plugins/webengine/webview.h
@@ -0,0 +1,25 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================
+ * Description: Qt WebEngine View
+ * ============================================================ */
+
+#pragma once
+
+#include "rview.hpp"
+
+class QWebEngineView;
+
+class WebView final : public rView {
+ Q_OBJECT
+
+public:
+ explicit WebView(const QUrl &url = QUrl(), QWidget *parent = nullptr);
+ ~WebView() final = default;
+
+private:
+ QWebEngineView *view;
+};