[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [falkon] src/lib: WebTab: Don't add pinned tabs to tab tree
From: David Rosca <null () kde ! org>
Date: 2018-01-31 20:10:36
Message-ID: E1egyiK-0002Fo-R9 () code ! kde ! org
[Download RAW message or body]
Git commit fa19d97dc43cfb54605be00c87033af5d1b39779 by David Rosca.
Committed on 31/01/2018 at 20:03.
Pushed by drosca into branch 'master'.
WebTab: Don't add pinned tabs to tab tree
M +1 -1 src/lib/webengine/webpage.cpp
M +1 -1 src/lib/webtab/tabbedwebview.cpp
M +32 -13 src/lib/webtab/webtab.cpp
M +1 -0 src/lib/webtab/webtab.h
https://commits.kde.org/falkon/fa19d97dc43cfb54605be00c87033af5d1b39779
diff --git a/src/lib/webengine/webpage.cpp b/src/lib/webengine/webpage.cpp
index a1e5672a..b71d53bf 100644
--- a/src/lib/webengine/webpage.cpp
+++ b/src/lib/webengine/webpage.cpp
@@ -624,7 +624,7 @@ QWebEnginePage* WebPage::createWindow(QWebEnginePage::WebWindowType type)
TabbedWebView* view = window->weView(index);
view->setPage(new WebPage);
if (tView) {
- view->webTab()->setParentTab(tView->webTab());
+ tView->webTab()->addChildTab(view->webTab());
}
// Workaround focus issue when creating tab
if (pos.testFlag(Qz::NT_SelectedTab)) {
diff --git a/src/lib/webtab/tabbedwebview.cpp b/src/lib/webtab/tabbedwebview.cpp
index 03aa85a9..6ecca2a3 100644
--- a/src/lib/webtab/tabbedwebview.cpp
+++ b/src/lib/webtab/tabbedwebview.cpp
@@ -166,7 +166,7 @@ void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags
if (m_window) {
int index = m_window->tabWidget()->addView(QUrl(), position);
TabbedWebView *view = m_window->weView(index);
- view->webTab()->setParentTab(webTab());
+ webTab()->addChildTab(view->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 0883ab8e..6c9b9aec 100644
--- a/src/lib/webtab/webtab.cpp
+++ b/src/lib/webtab/webtab.cpp
@@ -277,18 +277,8 @@ void WebTab::detach()
Q_ASSERT(m_window);
Q_ASSERT(m_tabBar);
- // Remove parent tab and reparent children
- WebTab *parentTab = m_parentTab;
- const int parentIndex = parentTab ? parentTab->m_childTabs.indexOf(this) : -1;
- setParentTab(nullptr);
- int i = 0;
- while (!m_childTabs.isEmpty()) {
- WebTab *child = m_childTabs.at(0);
- child->setParentTab(nullptr);
- if (parentTab) {
- parentTab->addChildTab(child, parentIndex + i++);
- }
- }
+ // Remove from tab tree
+ removeFromTabTree();
// Remove icon from tab
m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), nullptr);
@@ -383,6 +373,10 @@ void WebTab::setPinned(bool state)
return;
}
+ if (state) {
+ removeFromTabTree();
+ }
+
m_isPinned = state;
emit pinnedChanged(m_isPinned);
}
@@ -420,7 +414,11 @@ WebTab *WebTab::parentTab() const
void WebTab::setParentTab(WebTab *tab)
{
- if (m_parentTab == tab) {
+ if (m_isPinned || m_parentTab == tab) {
+ return;
+ }
+
+ if (tab && tab->isPinned()) {
return;
}
@@ -444,6 +442,10 @@ void WebTab::setParentTab(WebTab *tab)
void WebTab::addChildTab(WebTab *tab, int index)
{
+ if (m_isPinned || !tab || tab->isPinned()) {
+ return;
+ }
+
tab->m_parentTab = this;
WebTab *tabParent = tab->m_parentTab;
@@ -582,6 +584,23 @@ void WebTab::resizeEvent(QResizeEvent *event)
m_notificationWidget->setFixedWidth(width());
}
+void WebTab::removeFromTabTree()
+{
+ WebTab *parentTab = m_parentTab;
+ const int parentIndex = parentTab ? parentTab->m_childTabs.indexOf(this) : -1;
+
+ setParentTab(nullptr);
+
+ int i = 0;
+ while (!m_childTabs.isEmpty()) {
+ WebTab *child = m_childTabs.at(0);
+ child->setParentTab(nullptr);
+ if (parentTab) {
+ parentTab->addChildTab(child, parentIndex + i++);
+ }
+ }
+}
+
bool WebTab::isCurrentTab() const
{
return m_isCurrentTab;
diff --git a/src/lib/webtab/webtab.h b/src/lib/webtab/webtab.h
index d5e7fb6d..58ed9853 100644
--- a/src/lib/webtab/webtab.h
+++ b/src/lib/webtab/webtab.h
@@ -131,6 +131,7 @@ signals:
private:
void titleWasChanged(const QString &title);
void resizeEvent(QResizeEvent *event) override;
+ void removeFromTabTree();
QVBoxLayout* m_layout;
QSplitter* m_splitter;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic