From 5b7653188b7f6b5418573042bc2f109ad76775db Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 30 Jan 2018 16:02:54 +0100 Subject: [PATCH] Track parent tab for WebTab when opening new tabs --- src/lib/webengine/webpage.cpp | 3 +++ src/lib/webtab/tabbedwebview.cpp | 6 ++++-- src/lib/webtab/webtab.cpp | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/webengine/webpage.cpp b/src/lib/webengine/webpage.cpp index 449dd10c7..a1e5672a9 100644 --- a/src/lib/webengine/webpage.cpp +++ b/src/lib/webengine/webpage.cpp @@ -623,6 +623,9 @@ QWebEnginePage* WebPage::createWindow(QWebEnginePage::WebWindowType type) int index = window->tabWidget()->addView(QUrl(), pos); TabbedWebView* view = window->weView(index); view->setPage(new WebPage); + if (tView) { + view->webTab()->setParentTab(tView->webTab()); + } // Workaround focus issue when creating tab if (pos.testFlag(Qz::NT_SelectedTab)) { QPointer pview = view; diff --git a/src/lib/webtab/tabbedwebview.cpp b/src/lib/webtab/tabbedwebview.cpp index 743113618..03aa85a96 100644 --- a/src/lib/webtab/tabbedwebview.cpp +++ b/src/lib/webtab/tabbedwebview.cpp @@ -165,8 +165,10 @@ void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags { if (m_window) { int index = m_window->tabWidget()->addView(QUrl(), position); - m_window->weView(index)->webTab()->locationBar()->showUrl(req.url()); - m_window->weView(index)->load(req); + TabbedWebView *view = m_window->weView(index); + view->webTab()->setParentTab(webTab()); + view->webTab()->locationBar()->showUrl(req.url()); + view->load(req); } } diff --git a/src/lib/webtab/webtab.cpp b/src/lib/webtab/webtab.cpp index 4a4165e00..a3120a559 100644 --- a/src/lib/webtab/webtab.cpp +++ b/src/lib/webtab/webtab.cpp @@ -284,6 +284,9 @@ void WebTab::detach() Q_ASSERT(m_window); Q_ASSERT(m_tabBar); + // Remove parent tab + setParentTab(nullptr); + // Remove icon from tab m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), nullptr); m_tabIcon->setParent(this);