From e87693c54ca97ed3a6ed25f9eaae8ab223fc18b1 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 29 Apr 2020 18:49:07 +0300 Subject: 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 --- src/webengine/webview.cpp | 54 ++++++----------------------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) (limited to 'src/webengine/webview.cpp') diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index c64333e..135f25c 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -7,20 +7,16 @@ */ #include "webview.h" -#include "subwindow/subwindow.h" #include "webpage.h" #include "webprofile.h" #include "webprofilemanager.h" #include "webviewcontextmenu.h" #include -#include #include WebView::WebView(QWidget *parent) : QWebEngineView(parent) { - m_parentWindow = qobject_cast(parent); - // load status and progress connect(this, &QWebEngineView::loadStarted, this, [this]() { m_loaded = false; @@ -37,21 +33,22 @@ WebView::WebView(QWidget *parent) }); } -WebView::WebView(WebProfile *profile, QWidget *parent) +WebView::WebView(WebProfile *profile, cb_createWindow_t cb, QWidget *parent) : WebView(parent) { + cb_createWindow = cb; Q_CHECK_PTR(profile); m_profile = profile; setPage(new WebPage(profile, this)); } -WebView::WebView(const Session::WebView &data, QWidget *parent) +WebView::WebView(const Session::WebView &data, cb_createWindow_t cb, QWidget *parent) : WebView(parent) { - const auto *profileManager = WebProfileManager::instance(); - Q_CHECK_PTR(profileManager); + cb_createWindow = cb; + WebProfileManager profileManager; - auto *profile = profileManager->profile(data.profile); + auto *profile = profileManager.profile(data.profile); if(profile != nullptr) { setProfile(profile); } @@ -75,19 +72,11 @@ void WebView::setProfile(WebProfile *profile) Session::WebView WebView::serialize() const { - const auto *profileManager = WebProfileManager::instance(); - Q_CHECK_PTR(profileManager); - QByteArray historyData; QDataStream historyStream(&historyData, QIODevice::WriteOnly); historyStream << *history(); - return { profileManager->id(profile()), QString(), historyData }; -} - -bool WebView::isLoaded() const -{ - return m_loaded; + return { profile()->getId(), QString(), historyData }; } void WebView::search(const QString &term) @@ -96,35 +85,6 @@ void WebView::search(const QString &term) load(searchUrl); } -WebView *WebView::createWindow(QWebEnginePage::WebWindowType type) -{ - Q_CHECK_PTR(m_parentWindow); - - // parent Window has been found - auto index = m_parentWindow->addTab(); - WebView *view = m_parentWindow->view(index); - switch(type) { - case QWebEnginePage::WebBrowserWindow: - // a complete web browser window - break; - - case QWebEnginePage::WebBrowserTab: - // a web browser tab - m_parentWindow->setCurrentTab(index); - break; - - case QWebEnginePage::WebDialog: - // a window without decorations - break; - - case QWebEnginePage::WebBrowserBackgroundTab: - // a web browser tab, but don't swap to it - break; - } - - return view; -} - void WebView::contextMenuEvent(QContextMenuEvent *event) { auto *menu = new WebViewContextMenu(this); -- cgit v1.2.1