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

Tabs: Allow to detach tab from window with only one tab

Window will be closed after detaching this tab.
This commit is contained in:
David Rosca 2018-01-01 15:26:58 +01:00
parent 3eac8bd161
commit 8817493c68
3 changed files with 8 additions and 8 deletions

View File

@ -484,7 +484,7 @@ void TabBar::mouseMoveEvent(QMouseEvent* event)
} else if (eventY > height()) {
offset = eventY - height();
}
if (count() > 1 && offset > QApplication::startDragDistance()) {
if (offset > QApplication::startDragDistance()) {
const QPoint global = mapToGlobal(m_dragStartPosition);
QWidget *w = QApplication::widgetAt(global);
if (w) {

View File

@ -655,16 +655,15 @@ void TabWidget::detachTab(WebTab* tab)
disconnect(tab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));
tab->detach();
if (count() == 0) {
m_window->close();
}
}
void TabWidget::detachTab(int index)
{
WebTab* tab = weTab(index);
if (count() <= 1) {
return;
}
detachTab(tab);
tab->setPinned(false);

View File

@ -1,6 +1,6 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2018 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
@ -274,7 +274,8 @@ void WebTab::detach()
Q_ASSERT(m_tabBar);
// Remove icon from tab
m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), 0);
m_tabBar->setTabButton(tabIndex(), m_tabBar->iconButtonPosition(), nullptr);
m_tabIcon->setParent(this);
// Remove the tab from tabbar
setParent(0);