1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

WebTab: Don't add pinned tabs to tab tree

This commit is contained in:
David Rosca 2018-01-31 19:08:17 +01:00
parent e57fb65c95
commit fa19d97dc4
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
4 changed files with 35 additions and 15 deletions

View File

@ -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)) {

View File

@ -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);
}

View File

@ -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;

View File

@ -131,6 +131,7 @@ signals:
private:
void titleWasChanged(const QString &title);
void resizeEvent(QResizeEvent *event) override;
void removeFromTabTree();
QVBoxLayout* m_layout;
QSplitter* m_splitter;