From 5d23a21f37835a09014bee9d2154cf4705254aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Pejakovi=C4=87?= Date: Sun, 23 Feb 2014 14:49:32 +0100 Subject: [PATCH 1/2] [TabBar] Option to show/hide close button on inactive tabs. Closes #1220 --- src/lib/preferences/preferences.cpp | 2 ++ src/lib/preferences/preferences.ui | 46 +++++++++++++++++++++++++++++ src/lib/webview/tabbar.cpp | 13 ++++++-- src/lib/webview/tabbar.h | 3 +- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 5b49655d2..15b9e2e60 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -239,6 +239,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent) ui->closedInsteadOpened->setChecked(settings.value("closedInsteadOpenedTabs", false).toBool()); ui->showTabPreviews->setChecked(settings.value("showTabPreviews", false).toBool()); ui->animatedTabPreviews->setChecked(settings.value("tabPreviewAnimationsEnabled", true).toBool()); + ui->showCloseOnInactive->setCurrentIndex(settings.value("showCloseOnInactiveTabs", 0).toInt()); settings.endGroup(); connect(ui->showTabPreviews, SIGNAL(toggled(bool)), this, SLOT(showTabPreviewsChanged(bool))); @@ -914,6 +915,7 @@ void Preferences::saveSettings() settings.setValue("closedInsteadOpenedTabs", ui->closedInsteadOpened->isChecked()); settings.setValue("showTabPreviews", ui->showTabPreviews->isChecked()); settings.setValue("tabPreviewAnimationsEnabled", ui->animatedTabPreviews->isChecked()); + settings.setValue("showCloseOnInactiveTabs", ui->showCloseOnInactive->currentIndex()); settings.endGroup(); //DOWNLOADS diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index 319c42b8c..16e808118 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -763,6 +763,52 @@ + + + + + + Show close buttons on inactive tabs: + + + + + + + + Automatic + + + + + Always + + + + + Never + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 344a4b3fb..476c64d54 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -47,6 +47,7 @@ TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget) , m_tabPreview(new TabPreview(window, window)) , m_showTabPreviews(false) , m_hideTabBarWithOneTab(false) + , m_showCloseOnInactive(0) , m_clickedTab(0) , m_normalTabWidth(0) , m_activeTabWidth(0) @@ -56,7 +57,7 @@ TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget) setElideMode(Qt::ElideRight); setDocumentMode(true); setFocusPolicy(Qt::NoFocus); - setTabsClosable(true); + setTabsClosable(false); setMouseTracking(true); setMovable(true); @@ -90,6 +91,7 @@ void TabBar::loadSettings() m_tabPreview->setAnimationsEnabled(settings.value("tabPreviewAnimationsEnabled", true).toBool()); m_showTabPreviews = settings.value("showTabPreviews", false).toBool(); bool activateLastTab = settings.value("ActivateLastTabWhenClosingActual", false).toBool(); + m_showCloseOnInactive = settings.value("showCloseOnInactiveTabs", 0).toInt(0); settings.endGroup(); setSelectionBehaviorOnRemove(activateLastTab ? QTabBar::SelectPreviousTab : QTabBar::SelectRightTab); @@ -269,11 +271,16 @@ QSize TabBar::tabSizeHint(int index, bool fast) const bool tryAdjusting = availableWidth >= MINIMUM_TAB_WIDTH * normalTabsCount; - if (tabsClosable() && availableWidth < (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) { + if (m_showCloseOnInactive != 1 && tabsClosable() && availableWidth < (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) { // Hiding close buttons to save some space tabBar->setTabsClosable(false); tabBar->showCloseButton(currentIndex()); } + if (m_showCloseOnInactive == 1) { + // Hiding close buttons to save some space + tabBar->setTabsClosable(true); + tabBar->showCloseButton(currentIndex()); + } if (tryAdjusting) { m_normalTabWidth = maxWidthForTab; @@ -296,7 +303,7 @@ QSize TabBar::tabSizeHint(int index, bool fast) const } // Restore close buttons according to preferences - if (!tabsClosable() && availableWidth >= (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) { + if (m_showCloseOnInactive != 2 && !tabsClosable() && availableWidth >= (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) { tabBar->setTabsClosable(true); // Hide close buttons on pinned tabs diff --git a/src/lib/webview/tabbar.h b/src/lib/webview/tabbar.h index 2b5193a93..341af0cf0 100644 --- a/src/lib/webview/tabbar.h +++ b/src/lib/webview/tabbar.h @@ -112,7 +112,8 @@ private: bool m_showTabPreviews; bool m_hideTabBarWithOneTab; - + + int m_showCloseOnInactive; int m_clickedTab; mutable int m_normalTabWidth; From 9b7ecf1d12979a1b7c4c30076e0b0aa0e7354a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mladen=20Pejakovi=C4=87?= Date: Sun, 23 Feb 2014 14:54:22 +0100 Subject: [PATCH 2/2] [TabBar] Comment fix --- src/lib/webview/tabbar.cpp | 2 +- src/lib/webview/tabbar.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 476c64d54..b09c0fa86 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -277,7 +277,7 @@ QSize TabBar::tabSizeHint(int index, bool fast) const tabBar->showCloseButton(currentIndex()); } if (m_showCloseOnInactive == 1) { - // Hiding close buttons to save some space + // Always showing close buttons tabBar->setTabsClosable(true); tabBar->showCloseButton(currentIndex()); } diff --git a/src/lib/webview/tabbar.h b/src/lib/webview/tabbar.h index 341af0cf0..a359e4a25 100644 --- a/src/lib/webview/tabbar.h +++ b/src/lib/webview/tabbar.h @@ -112,7 +112,7 @@ private: bool m_showTabPreviews; bool m_hideTabBarWithOneTab; - + int m_showCloseOnInactive; int m_clickedTab;