diff options
Diffstat (limited to 'src/subwindow/subwindow.cpp')
-rw-r--r-- | src/subwindow/subwindow.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
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<Session::WebView> 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<TabData>(); } +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); } |