diff options
Diffstat (limited to 'src/webengine/webview.cpp')
-rw-r--r-- | src/webengine/webview.cpp | 54 |
1 files changed, 7 insertions, 47 deletions
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 <QContextMenuEvent> -#include <QJsonObject> #include <QWebEngineHistoryItem> WebView::WebView(QWidget *parent) : QWebEngineView(parent) { - m_parentWindow = qobject_cast<SubWindow *>(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); |