1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

TabManager: Don't repeat detaching tab code.

This commit is contained in:
Razi Alavizadeh 2017-10-03 16:12:28 +03:30
parent 33846b9523
commit bad3a76a2e
3 changed files with 17 additions and 13 deletions

View File

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

View File

@ -1,6 +1,6 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
*
* 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);

View File

@ -543,13 +543,8 @@ void TabManagerWidget::detachSelectedTabs(const QHash<BrowserWindow*, WebTab*> &
foreach (BrowserWindow* mainWindow, windows) {
const QList<WebTab*> &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;