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/subwindow/subwindow.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/subwindow/subwindow.cpp') diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp index 8c2e3e7..588a070 100644 --- a/src/subwindow/subwindow.cpp +++ b/src/subwindow/subwindow.cpp @@ -81,10 +81,9 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags flags) SubWindow::SubWindow(const Session::SubWindow &data, QWidget *parent, Qt::WindowFlags flags) : SubWindow(parent, flags) { - const auto *profileManager = WebProfileManager::instance(); - Q_CHECK_PTR(profileManager); + WebProfileManager profileManager; - auto *profile = profileManager->profile(data.profile); + auto *profile = profileManager.profile(data.profile); if(profile != nullptr) { setProfile(profile); } @@ -96,15 +95,12 @@ SubWindow::SubWindow(const Session::SubWindow &data, QWidget *parent, Qt::Window Session::SubWindow SubWindow::serialize() const { - const auto *profileManager = WebProfileManager::instance(); - Q_CHECK_PTR(profileManager); - QVector tabs(tabCount()); for(int i = 0; i < tabCount(); ++i) { tabs[i] = view(i)->serialize(); } - return { profileManager->id(profile()), tabs }; + return { profile()->getId(), tabs }; } void SubWindow::setProfile(WebProfile *profile) @@ -131,13 +127,20 @@ SubWindow::TabData SubWindow::tabData(int index) const return tabWidget->tabBar()->tabData(index).value(); } +WebView *SubWindow::createView(QWebEnginePage::WebWindowType type) +{ + auto *view = new WebView(m_profile, std::bind(&SubWindow::createView, this, std::placeholders::_1), this); + tabWidget->addTab(view); + return view; +} + int SubWindow::addTab(const QUrl &url, WebProfile *profile) { Q_CHECK_PTR(m_profile); auto *_profile = (profile == nullptr) ? m_profile : profile; - auto *view = new WebView(_profile, this); + auto *view = new WebView(_profile, std::bind(&SubWindow::createView, this, std::placeholders::_1), this); if(url.isEmpty()) view->load(_profile->newtab()); else @@ -148,7 +151,7 @@ int SubWindow::addTab(const QUrl &url, WebProfile *profile) int SubWindow::addTab(const Session::WebView &data) { - auto *view = new WebView(data, this); + auto *view = new WebView(data, std::bind(&SubWindow::createView, this, std::placeholders::_1), this); return tabWidget->addTab(view); } -- cgit v1.2.1