From fb652ff6cd177e5fcc185a96bcde2f6a4a88e0f4 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 1 Jan 2018 15:10:11 +0100 Subject: [PATCH] Tabs: Make the code work better with zero tabs --- src/lib/tabwidget/tabbar.cpp | 8 ++++---- src/lib/tabwidget/tabwidget.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 58d66a399..6a2944577 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -88,7 +88,7 @@ void TabBar::loadSettings() settings.endGroup(); setSelectionBehaviorOnRemove(activateLastTab ? QTabBar::SelectPreviousTab : QTabBar::SelectRightTab); - setVisible(!(count() == 1 && m_hideTabBarWithOneTab)); + setVisible(!(count() <= 1 && m_hideTabBarWithOneTab)); setUpLayout(); } @@ -107,7 +107,7 @@ void TabBar::setVisible(bool visible) // Make sure to honor user preference if (visible) { - visible = !(count() == 1 && m_hideTabBarWithOneTab); + visible = !(count() <= 1 && m_hideTabBarWithOneTab); } ComboTabBar::setVisible(visible); @@ -416,7 +416,7 @@ void TabBar::tabInserted(int index) { Q_UNUSED(index) - setVisible(!(count() == 1 && m_hideTabBarWithOneTab)); + setVisible(!(count() <= 1 && m_hideTabBarWithOneTab)); } void TabBar::tabRemoved(int index) @@ -424,7 +424,7 @@ void TabBar::tabRemoved(int index) Q_UNUSED(index) showCloseButton(currentIndex()); - setVisible(!(count() == 1 && m_hideTabBarWithOneTab)); + setVisible(!(count() <= 1 && m_hideTabBarWithOneTab)); // Make sure to move add tab button to correct position when there are no normal tabs if (normalTabsCount() == 0) { diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index 661949469..1a039f32d 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -471,7 +471,7 @@ void TabWidget::requestCloseTab(int index) return; // This would close last tab, so we close the window instead - if (count() == 1) { + if (count() <= 1) { // If we are not closing window upon closing last tab, let's just load new-tab-url if (m_dontCloseWithOneTab) { if (webView->url() == m_urlOnNewTab) { @@ -661,7 +661,7 @@ void TabWidget::detachTab(int index) { WebTab* tab = weTab(index); - if (count() < 2) { + if (count() <= 1) { return; }