From e9c6cdefff00daffb8b07e72c47f8e8f845ba436 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 15 Dec 2020 11:51:08 +0200 Subject: Move src/webengine to lib/webengine --- src/webengine/webview.cpp | 87 ----------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 src/webengine/webview.cpp (limited to 'src/webengine/webview.cpp') diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp deleted file mode 100644 index bc52102..0000000 --- a/src/webengine/webview.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file is part of smolbote. It's copyrighted by the contributors recorded - * in the version control history of the file, available from its original - * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "webview.h" -#include "webpage.h" -#include "webprofile.h" -#include "webprofilemanager.h" -#include "webviewcontextmenu.h" -#include -#include - -WebView::WebView(QWidget *parent) - : QWebEngineView(parent) -{ - // load status and progress - connect(this, &QWebEngineView::loadStarted, this, [this]() { - m_loaded = false; - }); - connect(this, &QWebEngineView::loadFinished, this, [this]() { - m_loaded = true; - }); - - // TODO for Qt 5.15, check for fix on QTBUG 65223 - connect(this, &QWebEngineView::loadProgress, this, [this](int progress) { - if(progress == 100) { - emit loadFinished(true); - } - }); -} - -WebView::WebView(WebProfile *profile, cb_createWindow_t cb, QWidget *parent) - : WebView(parent) -{ - cb_createWindow = cb; - setProfile(profile); -} - -WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWidget *parent) - : WebView(parent) -{ - cb_createWindow = cb; - WebProfileManager profileManager; - setProfile(profileManager.profile(webview_data.profile)); - - if(!webview_data.url.isEmpty()) - load(QUrl::fromUserInput(webview_data.url)); - else { - QByteArray copy(webview_data.history); - QDataStream historyStream(©, QIODevice::ReadOnly); - historyStream >> *history(); - } -} - -void WebView::setProfile(WebProfile *profile) -{ - m_profile = (profile == nullptr) ? WebProfile::defaultProfile() : profile; - const auto url = this->url(); - setPage(new WebPage(m_profile, this)); - this->load(url); -} - -Session::WebView WebView::serialize() const -{ - QByteArray historyData; - QDataStream historyStream(&historyData, QIODevice::WriteOnly); - historyStream << *history(); - - return { profile()->getId(), QString(), historyData }; -} - -void WebView::search(const QString &term) -{ - const QString searchUrl = m_profile->search().arg(QString(QUrl::toPercentEncoding(term))); - load(searchUrl); -} - -void WebView::contextMenuEvent(QContextMenuEvent *event) -{ - auto *menu = new WebViewContextMenu(this); - //const auto ctxdata = page()->contextMenuData(); - menu->exec(event->globalPos()); -} -- cgit v1.2.1