mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[ComboTabBar] Correctly switch tabs when closing last tab in tabbar
Also remove custom logic for SelectPreviousTab on tab remove and use only the QTabBar's selectionBehaviorOnRemove Fix 1 for #1322
This commit is contained in:
parent
d1754094b8
commit
964a76c04b
@ -49,8 +49,8 @@ ComboTabBar::ComboTabBar(QWidget* parent)
|
||||
{
|
||||
QObject::setObjectName(QSL("tabbarwidget"));
|
||||
|
||||
m_mainTabBar = new TabBarHelper(this);
|
||||
m_pinnedTabBar = new TabBarHelper(this);
|
||||
m_mainTabBar = new TabBarHelper(/*pinnedTabBar*/ false, this);
|
||||
m_pinnedTabBar = new TabBarHelper(/*pinnedTabBar*/ true, this);
|
||||
m_mainTabBarWidget = new TabBarScrollWidget(m_mainTabBar, this);
|
||||
m_pinnedTabBarWidget = new TabBarScrollWidget(m_pinnedTabBar, this);
|
||||
|
||||
@ -915,7 +915,7 @@ void ComboTabBar::leaveEvent(QEvent* event)
|
||||
}
|
||||
|
||||
|
||||
TabBarHelper::TabBarHelper(ComboTabBar* comboTabBar)
|
||||
TabBarHelper::TabBarHelper(bool pinnedTabBar, ComboTabBar* comboTabBar)
|
||||
: QTabBar(comboTabBar)
|
||||
, m_comboTabBar(comboTabBar)
|
||||
, m_scrollArea(0)
|
||||
@ -923,6 +923,7 @@ TabBarHelper::TabBarHelper(ComboTabBar* comboTabBar)
|
||||
, m_pressedGlobalX(-1)
|
||||
, m_dragInProgress(false)
|
||||
, m_activeTabBar(false)
|
||||
, m_pinnedTabBar(pinnedTabBar)
|
||||
, m_useFastTabSizeHint(false)
|
||||
, m_bluredBackground(false)
|
||||
{
|
||||
@ -955,6 +956,17 @@ void TabBarHelper::setActiveTabBar(bool activate)
|
||||
{
|
||||
if (m_activeTabBar != activate) {
|
||||
m_activeTabBar = activate;
|
||||
|
||||
// If the last tab in a tabbar is closed, the selection jumps to the other
|
||||
// tabbar. The stacked widget automatically selects the next tab, which is
|
||||
// either the last tab in pinned tabbar or the first one in main tabbar.
|
||||
|
||||
if (!m_activeTabBar) {
|
||||
m_comboTabBar->m_blockCurrentChangedSignal = true;
|
||||
setCurrentIndex(m_pinnedTabBar ? count() - 1 : 0);
|
||||
m_comboTabBar->m_blockCurrentChangedSignal = false;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
@ -963,9 +975,8 @@ void TabBarHelper::removeTab(int index)
|
||||
{
|
||||
// Removing tab in inactive tabbar will change current index and thus
|
||||
// changing active tabbar, which is really not wanted.
|
||||
if (!m_activeTabBar) {
|
||||
if (!m_activeTabBar)
|
||||
m_comboTabBar->m_blockCurrentChangedSignal = true;
|
||||
}
|
||||
|
||||
QTabBar::removeTab(index);
|
||||
|
||||
|
@ -212,7 +212,7 @@ class QUPZILLA_EXPORT TabBarHelper : public QTabBar
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TabBarHelper(ComboTabBar* comboTabBar);
|
||||
explicit TabBarHelper(bool pinnedTabBar, ComboTabBar* comboTabBar);
|
||||
|
||||
void setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget);
|
||||
|
||||
@ -252,6 +252,7 @@ private:
|
||||
int m_pressedGlobalX;
|
||||
bool m_dragInProgress;
|
||||
bool m_activeTabBar;
|
||||
bool m_pinnedTabBar;
|
||||
bool m_useFastTabSizeHint;
|
||||
bool m_bluredBackground;
|
||||
};
|
||||
|
@ -116,7 +116,6 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
|
||||
, m_closedTabsManager(new ClosedTabsManager)
|
||||
, m_lastTabIndex(-1)
|
||||
, m_lastBackgroundTabIndex(-1)
|
||||
, m_isClosingToLastTabIndex(false)
|
||||
{
|
||||
setObjectName(QSL("tabwidget"));
|
||||
|
||||
@ -389,10 +388,6 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N
|
||||
m_window->locationBar()->setFocus();
|
||||
}
|
||||
|
||||
if (openFlags & Qz::NT_SelectedTab || openFlags & Qz::NT_NotSelectedTab) {
|
||||
m_isClosingToLastTabIndex = true;
|
||||
}
|
||||
|
||||
if (openFlags & Qz::NT_NotSelectedTab) {
|
||||
WebTab* currentWebTab = weTab();
|
||||
// Workarounding invalid QWebPage::viewportSize() until QWebView is shown
|
||||
@ -485,9 +480,6 @@ void TabWidget::closeTab(int index, bool force)
|
||||
disconnect(webView, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
disconnect(webView, SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString)));
|
||||
|
||||
if (m_isClosingToLastTabIndex && m_lastTabIndex < count() && index == currentIndex())
|
||||
setCurrentIndex(m_lastTabIndex);
|
||||
|
||||
m_lastBackgroundTabIndex = -1;
|
||||
|
||||
if (m_menuTabs->isVisible()) {
|
||||
@ -508,7 +500,6 @@ void TabWidget::currentTabChanged(int index)
|
||||
if (!validIndex(index))
|
||||
return;
|
||||
|
||||
m_isClosingToLastTabIndex = m_lastBackgroundTabIndex == index;
|
||||
m_lastBackgroundTabIndex = -1;
|
||||
m_lastTabIndex = index;
|
||||
|
||||
@ -529,7 +520,6 @@ void TabWidget::tabMoved(int before, int after)
|
||||
Q_UNUSED(before)
|
||||
Q_UNUSED(after)
|
||||
|
||||
m_isClosingToLastTabIndex = false;
|
||||
m_lastBackgroundTabIndex = -1;
|
||||
m_lastTabIndex = before;
|
||||
}
|
||||
@ -642,10 +632,6 @@ void TabWidget::detachTab(int index)
|
||||
|
||||
BrowserWindow* window = mApp->createWindow(Qz::BW_NewWindow);
|
||||
window->setStartTab(tab);
|
||||
|
||||
if (m_isClosingToLastTabIndex && m_lastTabIndex < count() && index == currentIndex()) {
|
||||
setCurrentIndex(m_lastTabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
int TabWidget::duplicateTab(int index)
|
||||
|
@ -155,7 +155,6 @@ private:
|
||||
|
||||
int m_lastTabIndex;
|
||||
int m_lastBackgroundTabIndex;
|
||||
bool m_isClosingToLastTabIndex;
|
||||
|
||||
bool m_dontCloseWithOneTab;
|
||||
bool m_showClosedTabsButton;
|
||||
|
Loading…
Reference in New Issue
Block a user