From 8817493c68c7c9097faa5edf7a8a87cb8fb39a79 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 1 Jan 2018 15:26:58 +0100 Subject: [PATCH] Tabs: Allow to detach tab from window with only one tab Window will be closed after detaching this tab. --- src/lib/tabwidget/tabbar.cpp | 2 +- src/lib/tabwidget/tabwidget.cpp | 9 ++++----- src/lib/webtab/webtab.cpp | 5 +++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index bcdf24056..ad2779f00 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -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) { diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index 1a039f32d..6b4ab6c51 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -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); diff --git a/src/lib/webtab/webtab.cpp b/src/lib/webtab/webtab.cpp index 9f5164ac1..ba03d8b16 100644 --- a/src/lib/webtab/webtab.cpp +++ b/src/lib/webtab/webtab.cpp @@ -1,6 +1,6 @@ /* ============================================================ * Falkon - Qt web browser -* Copyright (C) 2010-2017 David Rosca +* Copyright (C) 2010-2018 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 @@ -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);