From bad3a76a2e6c0b1317a03b2047a25c841f74e010 Mon Sep 17 00:00:00 2001 From: Razi Alavizadeh Date: Tue, 3 Oct 2017 16:12:28 +0330 Subject: [PATCH] TabManager: Don't repeat detaching tab code. --- src/lib/tabwidget/tabwidget.cpp | 19 +++++++++++++------ src/lib/tabwidget/tabwidget.h | 4 +++- src/plugins/TabManager/tabmanagerwidget.cpp | 7 +------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index eed511344..87d932116 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -653,6 +653,18 @@ void TabWidget::closeToLeft(int index) } } +void TabWidget::detachTab(WebTab* tab) +{ + Q_ASSERT(tab); + + m_locationBars->removeWidget(tab->locationBar()); + disconnect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); + disconnect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); + disconnect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); + + tab->detach(); +} + void TabWidget::detachTab(int index) { WebTab* tab = weTab(index); @@ -661,12 +673,7 @@ void TabWidget::detachTab(int index) return; } - m_locationBars->removeWidget(tab->locationBar()); - disconnect(tab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); - disconnect(tab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); - disconnect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); - - tab->detach(); + detachTab(tab); BrowserWindow* window = mApp->createWindow(Qz::BW_NewWindow); window->setStartTab(tab); diff --git a/src/lib/tabwidget/tabwidget.h b/src/lib/tabwidget/tabwidget.h index f5c267a88..5427d8764 100644 --- a/src/lib/tabwidget/tabwidget.h +++ b/src/lib/tabwidget/tabwidget.h @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2010-2014 David Rosca +* Copyright (C) 2010-2017 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -97,6 +97,8 @@ public: ToolButton* buttonClosedTabs() const; AddTabButton* buttonAddTab() const; + void detachTab(WebTab* tab); + public slots: int addView(const LoadRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false, bool pinned = false); int addView(const LoadRequest &req, const QString &title = tr("New tab"), const Qz::NewTabPositionFlags &openFlags = Qz::NT_SelectedTab, bool selectLine = false, int position = -1, bool pinned = false); diff --git a/src/plugins/TabManager/tabmanagerwidget.cpp b/src/plugins/TabManager/tabmanagerwidget.cpp index 61f51beaf..385daa42a 100644 --- a/src/plugins/TabManager/tabmanagerwidget.cpp +++ b/src/plugins/TabManager/tabmanagerwidget.cpp @@ -543,13 +543,8 @@ void TabManagerWidget::detachSelectedTabs(const QHash & foreach (BrowserWindow* mainWindow, windows) { const QList &tabs = tabsHash.values(mainWindow); foreach (WebTab* webTab, tabs) { - mainWindow->tabWidget()->locationBars()->removeWidget(webTab->locationBar()); + mainWindow->tabWidget()->detachTab(webTab); - disconnect(webTab->webView(), SIGNAL(wantsCloseTab(int)), mainWindow->tabWidget(), SLOT(closeTab(int))); - disconnect(webTab->webView(), SIGNAL(changed()), mainWindow->tabWidget(), SIGNAL(changed())); - disconnect(webTab->webView(), SIGNAL(ipChanged(QString)), mainWindow->ipLabel(), SLOT(setText(QString))); - - webTab->detach(); if (mainWindow && mainWindow->tabWidget()->count() == 0) { mainWindow->close(); mainWindow = 0;