aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webview.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/webview.h')
-rw-r--r--src/webengine/webview.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/webengine/webview.h b/src/webengine/webview.h
index 5748691..a9c6866 100644
--- a/src/webengine/webview.h
+++ b/src/webengine/webview.h
@@ -11,10 +11,10 @@
#include "webpage.h"
#include <QWebEngineView>
+#include <functional>
#include <session.hpp>
class WebProfile;
-class SubWindow;
class WebViewContextMenu;
class WebView final : public QWebEngineView
{
@@ -25,8 +25,10 @@ class WebView final : public QWebEngineView
explicit WebView(QWidget *parent = nullptr);
public:
- explicit WebView(WebProfile *profile = nullptr, QWidget *parent = nullptr);
- explicit WebView(const Session::WebView &data, QWidget *parent = nullptr);
+ typedef std::function<WebView *(QWebEnginePage::WebWindowType)> cb_createWindow_t;
+
+ WebView(WebProfile *profile, cb_createWindow_t cb, QWidget *parent = nullptr);
+ WebView(const Session::WebView &data, cb_createWindow_t cb, QWidget *parent = nullptr);
~WebView() = default;
[[nodiscard]] WebProfile *profile() const
@@ -37,7 +39,10 @@ public:
[[nodiscard]] Session::WebView serialize() const;
- bool isLoaded() const;
+ bool isLoaded() const
+ {
+ return m_loaded;
+ }
public slots:
void search(const QString &term);
@@ -46,11 +51,14 @@ signals:
void newBookmark(const QString &title, const QUrl &url);
protected:
- WebView *createWindow(QWebEnginePage::WebWindowType type) override;
+ WebView *createWindow(QWebEnginePage::WebWindowType type) override
+ {
+ return cb_createWindow ? cb_createWindow(type) : nullptr;
+ }
void contextMenuEvent(QContextMenuEvent *event) override;
private:
- SubWindow *m_parentWindow = nullptr;
+ cb_createWindow_t cb_createWindow;
WebProfile *m_profile = nullptr;
bool m_loaded = false;