Commit 91112821 authored by Thomas Schöps's avatar Thomas Schöps Committed by Thomas Schöps

Add a setting to disable the close buttons on tabs

parent 7cb06699
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
<entry name="TabBarVisibility" key="TabBarVisibility" type="Int"> <entry name="TabBarVisibility" key="TabBarVisibility" type="Int">
<default>1</default> <default>1</default>
</entry> </entry>
<entry name="CloseButtonsOnTabs" key="CloseButtonsOnTabs" type="Int">
<default>1</default>
</entry>
<entry name="TabBarOpenAfterCurrent" key="TabBarOpenAfterCurrent" type="Int"> <entry name="TabBarOpenAfterCurrent" key="TabBarOpenAfterCurrent" type="Int">
<default>1</default> <default>1</default>
</entry> </entry>
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
<string>Tabbed Browsing</string> <string>Tabbed Browsing</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_1"> <layout class="QGridLayout" name="gridLayout_1">
<item row="1" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="kcfg_TabBarOpenAfterCurrent"> <widget class="QCheckBox" name="kcfg_TabBarOpenAfterCurrent">
<property name="toolTip"> <property name="toolTip">
<string>Controls whether to open new tabs next to the active one.</string> <string>Controls whether to open new tabs next to the active one.</string>
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QCheckBox" name="kcfg_TabBarArrangeBuddies"> <widget class="QCheckBox" name="kcfg_TabBarArrangeBuddies">
<property name="toolTip"> <property name="toolTip">
<string>When enabled, plugins can group related files side by side. <string>When enabled, plugins can group related files side by side.
...@@ -123,6 +123,19 @@ For example, a header file will be opened next to the implementation file.</stri ...@@ -123,6 +123,19 @@ For example, a header file will be opened next to the implementation file.</stri
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="kcfg_CloseButtonsOnTabs">
<property name="toolTip">
<string>Enables or disables the display of a close button in each tab in the tab bar at the top of the editor window.</string>
</property>
<property name="text">
<string>Show close buttons on tabs</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -191,5 +204,21 @@ For example, a header file will be opened next to the implementation file.</stri ...@@ -191,5 +204,21 @@ For example, a header file will be opened next to the implementation file.</stri
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>kcfg_TabBarVisibility</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_CloseButtonsOnTabs</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>260</x>
<y>133</y>
</hint>
<hint type="destinationlabel">
<x>260</x>
<y>158</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>
...@@ -365,7 +365,7 @@ Container::Container(QWidget *parent) ...@@ -365,7 +365,7 @@ Container::Container(QWidget *parent)
setTabBarHidden(!configTabBarVisible()); setTabBarHidden(!configTabBarVisible());
d->tabBar->setTabsClosable(true); d->tabBar->setTabsClosable(configCloseButtonsOnTabs());
d->tabBar->setMovable(true); d->tabBar->setMovable(true);
d->tabBar->setExpanding(false); d->tabBar->setExpanding(false);
d->tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); d->tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
...@@ -379,6 +379,12 @@ bool Container::configTabBarVisible() ...@@ -379,6 +379,12 @@ bool Container::configTabBarVisible()
return group.readEntry("TabBarVisibility", 1); return group.readEntry("TabBarVisibility", 1);
} }
bool Container::configCloseButtonsOnTabs()
{
KConfigGroup group = KSharedConfig::openConfig()->group("UiSettings");
return group.readEntry("CloseButtonsOnTabs", 1);
}
void Container::setLeftCornerWidget(QWidget* widget) void Container::setLeftCornerWidget(QWidget* widget)
{ {
Q_D(Container); Q_D(Container);
...@@ -632,6 +638,13 @@ void Container::setTabBarHidden(bool hide) ...@@ -632,6 +638,13 @@ void Container::setTabBarHidden(bool hide)
} }
} }
void Container::setCloseButtonsOnTabs(bool show)
{
Q_D(Container);
d->tabBar->setTabsClosable(show);
}
void Container::resetTabColors(const QColor& color) void Container::resetTabColors(const QColor& color)
{ {
Q_D(Container); Q_D(Container);
......
...@@ -61,6 +61,7 @@ public: ...@@ -61,6 +61,7 @@ public:
View *viewForWidget(QWidget *w) const; View *viewForWidget(QWidget *w) const;
void setTabBarHidden(bool hide); void setTabBarHidden(bool hide);
void setCloseButtonsOnTabs(bool show);
void setTabColor(const View* view, const QColor& color); void setTabColor(const View* view, const QColor& color);
void setTabColors(const QHash<const View*, QColor>& colors); void setTabColors(const QHash<const View*, QColor>& colors);
...@@ -76,6 +77,7 @@ public: ...@@ -76,6 +77,7 @@ public:
QRect tabRect(int tab) const; QRect tabRect(int tab) const;
static bool configTabBarVisible(); static bool configTabBarVisible();
static bool configCloseButtonsOnTabs();
Q_SIGNALS: Q_SIGNALS:
void activateView(Sublime::View* view); void activateView(Sublime::View* view);
......
...@@ -351,8 +351,10 @@ void MainWindow::loadSettings() ...@@ -351,8 +351,10 @@ void MainWindow::loadSettings()
} }
const bool tabBarHidden = !Container::configTabBarVisible(); const bool tabBarHidden = !Container::configTabBarVisible();
const bool closeButtonsOnTabs = Container::configCloseButtonsOnTabs();
for (Container *container : qAsConst(d->viewContainers)) { for (Container *container : qAsConst(d->viewContainers)) {
container->setTabBarHidden(tabBarHidden); container->setTabBarHidden(tabBarHidden);
container->setCloseButtonsOnTabs(closeButtonsOnTabs);
} }
hu.stop(); hu.stop();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment