1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[TabBar] Option to show/hide close button on inactive tabs. Closes #1220

This commit is contained in:
Mladen Pejaković 2014-02-23 14:49:32 +01:00
parent 7d98a162d6
commit 5d23a21f37
4 changed files with 60 additions and 4 deletions

View File

@ -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

View File

@ -763,6 +763,52 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QLabel" name="label_65">
<property name="text">
<string>Show close buttons on inactive tabs:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="showCloseOnInactive">
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>Always</string>
</property>
</item>
<item>
<property name="text">
<string>Never</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_30">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_8">
<property name="orientation">

View File

@ -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

View File

@ -113,6 +113,7 @@ private:
bool m_showTabPreviews;
bool m_hideTabBarWithOneTab;
int m_showCloseOnInactive;
int m_clickedTab;
mutable int m_normalTabWidth;