mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Merge pull request #1242 from pejakm/tabsv2
Option to show/hide close button on inactive tabs. Closes #1220
This commit is contained in:
commit
e5246a0c74
@ -239,6 +239,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
|
|||||||
ui->closedInsteadOpened->setChecked(settings.value("closedInsteadOpenedTabs", false).toBool());
|
ui->closedInsteadOpened->setChecked(settings.value("closedInsteadOpenedTabs", false).toBool());
|
||||||
ui->showTabPreviews->setChecked(settings.value("showTabPreviews", false).toBool());
|
ui->showTabPreviews->setChecked(settings.value("showTabPreviews", false).toBool());
|
||||||
ui->animatedTabPreviews->setChecked(settings.value("tabPreviewAnimationsEnabled", true).toBool());
|
ui->animatedTabPreviews->setChecked(settings.value("tabPreviewAnimationsEnabled", true).toBool());
|
||||||
|
ui->showCloseOnInactive->setCurrentIndex(settings.value("showCloseOnInactiveTabs", 0).toInt());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
connect(ui->showTabPreviews, SIGNAL(toggled(bool)), this, SLOT(showTabPreviewsChanged(bool)));
|
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("closedInsteadOpenedTabs", ui->closedInsteadOpened->isChecked());
|
||||||
settings.setValue("showTabPreviews", ui->showTabPreviews->isChecked());
|
settings.setValue("showTabPreviews", ui->showTabPreviews->isChecked());
|
||||||
settings.setValue("tabPreviewAnimationsEnabled", ui->animatedTabPreviews->isChecked());
|
settings.setValue("tabPreviewAnimationsEnabled", ui->animatedTabPreviews->isChecked());
|
||||||
|
settings.setValue("showCloseOnInactiveTabs", ui->showCloseOnInactive->currentIndex());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
//DOWNLOADS
|
//DOWNLOADS
|
||||||
|
@ -763,6 +763,52 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<spacer name="verticalSpacer_8">
|
<spacer name="verticalSpacer_8">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -47,6 +47,7 @@ TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget)
|
|||||||
, m_tabPreview(new TabPreview(window, window))
|
, m_tabPreview(new TabPreview(window, window))
|
||||||
, m_showTabPreviews(false)
|
, m_showTabPreviews(false)
|
||||||
, m_hideTabBarWithOneTab(false)
|
, m_hideTabBarWithOneTab(false)
|
||||||
|
, m_showCloseOnInactive(0)
|
||||||
, m_clickedTab(0)
|
, m_clickedTab(0)
|
||||||
, m_normalTabWidth(0)
|
, m_normalTabWidth(0)
|
||||||
, m_activeTabWidth(0)
|
, m_activeTabWidth(0)
|
||||||
@ -56,7 +57,7 @@ TabBar::TabBar(BrowserWindow* window, TabWidget* tabWidget)
|
|||||||
setElideMode(Qt::ElideRight);
|
setElideMode(Qt::ElideRight);
|
||||||
setDocumentMode(true);
|
setDocumentMode(true);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
setTabsClosable(true);
|
setTabsClosable(false);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setMovable(true);
|
setMovable(true);
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ void TabBar::loadSettings()
|
|||||||
m_tabPreview->setAnimationsEnabled(settings.value("tabPreviewAnimationsEnabled", true).toBool());
|
m_tabPreview->setAnimationsEnabled(settings.value("tabPreviewAnimationsEnabled", true).toBool());
|
||||||
m_showTabPreviews = settings.value("showTabPreviews", false).toBool();
|
m_showTabPreviews = settings.value("showTabPreviews", false).toBool();
|
||||||
bool activateLastTab = settings.value("ActivateLastTabWhenClosingActual", false).toBool();
|
bool activateLastTab = settings.value("ActivateLastTabWhenClosingActual", false).toBool();
|
||||||
|
m_showCloseOnInactive = settings.value("showCloseOnInactiveTabs", 0).toInt(0);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
setSelectionBehaviorOnRemove(activateLastTab ? QTabBar::SelectPreviousTab : QTabBar::SelectRightTab);
|
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;
|
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
|
// Hiding close buttons to save some space
|
||||||
tabBar->setTabsClosable(false);
|
tabBar->setTabsClosable(false);
|
||||||
tabBar->showCloseButton(currentIndex());
|
tabBar->showCloseButton(currentIndex());
|
||||||
}
|
}
|
||||||
|
if (m_showCloseOnInactive == 1) {
|
||||||
|
// Always showing close buttons
|
||||||
|
tabBar->setTabsClosable(true);
|
||||||
|
tabBar->showCloseButton(currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
if (tryAdjusting) {
|
if (tryAdjusting) {
|
||||||
m_normalTabWidth = maxWidthForTab;
|
m_normalTabWidth = maxWidthForTab;
|
||||||
@ -296,7 +303,7 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore close buttons according to preferences
|
// 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);
|
tabBar->setTabsClosable(true);
|
||||||
|
|
||||||
// Hide close buttons on pinned tabs
|
// Hide close buttons on pinned tabs
|
||||||
|
@ -113,6 +113,7 @@ private:
|
|||||||
bool m_showTabPreviews;
|
bool m_showTabPreviews;
|
||||||
bool m_hideTabBarWithOneTab;
|
bool m_hideTabBarWithOneTab;
|
||||||
|
|
||||||
|
int m_showCloseOnInactive;
|
||||||
int m_clickedTab;
|
int m_clickedTab;
|
||||||
|
|
||||||
mutable int m_normalTabWidth;
|
mutable int m_normalTabWidth;
|
||||||
|
Loading…
Reference in New Issue
Block a user