aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webview.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-04-29 18:49:07 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-08 13:40:29 +0300
commite87693c54ca97ed3a6ed25f9eaae8ab223fc18b1 (patch)
tree54194ca979ac7e646ff3f10ed6d7f7753273f0be /src/webengine/webview.h
parentExpand pluginloader test coverage (diff)
downloadsmolbote-e87693c54ca97ed3a6ed25f9eaae8ab223fc18b1.tar.xz
libwebengine
Make src/webengine into a static library - Add some tests - Updated manpage - Remove WebProfileManager::id and WebProfileManager::instance - Add consumable semantics checks to WebProfileManager - Add WebProfileManager::walk Add ApplicationMenu class
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;