[konsole] src: Add option to allow tab width to be expanding
Kurt Hindenburg
null at kde.org
Sun Nov 5 17:05:53 UTC 2017
Git commit 001d937d10949bc5d377ef2147dc96e376ca635b by Kurt Hindenburg.
Committed on 05/11/2017 at 16:56.
Pushed by hindenburg into branch 'master'.
Add option to allow tab width to be expanding
Qt5.9+ changed the way tab widths are handled. Add option to allow
tab width to expanding to full window or as width of tab text.
GUI:
BUG: 380879
FIXED-IN: 17.12
M +6 -0 src/MainWindow.cpp
M +1 -0 src/MainWindow.h
M +13 -0 src/ViewContainer.cpp
M +14 -0 src/ViewContainer.h
M +11 -0 src/ViewManager.cpp
M +2 -0 src/ViewManager.h
M +52 -25 src/settings/TabBarSettings.ui
M +4 -0 src/settings/konsole.kcfg
https://commits.kde.org/konsole/001d937d10949bc5d377ef2147dc96e376ca635b
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 387358b7..344bba03 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -770,6 +770,7 @@ void MainWindow::applyKonsoleSettings()
setNavigationVisibility(KonsoleSettings::tabBarVisibility());
setNavigationPosition(KonsoleSettings::tabBarPosition());
setNavigationBehavior(KonsoleSettings::newTabBehavior());
+ setNavigationTabWidthExpanding(KonsoleSettings::expandTabWidth());
setShowQuickButtons(KonsoleSettings::showQuickButtons());
if (KonsoleSettings::tabBarUseUserStyleSheet()) {
@@ -804,6 +805,11 @@ void MainWindow::setNavigationBehavior(int behavior)
_viewManager->setNavigationBehavior(behavior);
}
+void MainWindow::setNavigationTabWidthExpanding(bool expand)
+{
+ _viewManager->setNavigationTabWidthExpanding(expand);
+}
+
void MainWindow::setNavigationStyleSheetFromFile(const QUrl &styleSheetFile)
{
// Let's only deal w/ local files for now
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 04c70a15..218f25db 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -107,6 +107,7 @@ public:
void setNavigationStyleSheet(const QString &stylesheet);
void setNavigationStyleSheetFromFile(const QUrl &stylesheetfile);
void setNavigationBehavior(int behavior);
+ void setNavigationTabWidthExpanding(bool expand);
void setShowQuickButtons(bool show);
Q_SIGNALS:
diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp
index 8c447fcc..3338130d 100644
--- a/src/ViewContainer.cpp
+++ b/src/ViewContainer.cpp
@@ -45,6 +45,7 @@
#include "ViewContainerTabBar.h"
#include "ProfileList.h"
#include "ViewManager.h"
+#include "KonsoleSettings.h"
// TODO Perhaps move everything which is Konsole-specific into different files
@@ -134,6 +135,11 @@ QList<ViewContainer::NavigationPosition> ViewContainer::supportedNavigationPosit
return QList<NavigationPosition>() << NavigationPositionTop;
}
+void ViewContainer::setNavigationTabWidthExpanding(bool expand)
+{
+ navigationTabWidthExpandingChanged(expand);
+}
+
ViewContainer::NavigationVisibility ViewContainer::navigationVisibility() const
{
return _navigationVisibility;
@@ -433,6 +439,11 @@ void TabbedViewContainer::navigationPositionChanged(NavigationPosition position)
}
}
+void TabbedViewContainer::navigationTabWidthExpandingChanged(bool expand)
+{
+ _tabBar->setExpanding(expand);
+}
+
void TabbedViewContainer::navigationVisibilityChanged(NavigationVisibility mode)
{
if (mode == AlwaysShowNavigation && _tabBar->isHidden()) {
@@ -464,8 +475,10 @@ void TabbedViewContainer::setStyleSheet(const QString &styleSheet)
_tabBar->setStyleSheet(styleSheet);
}
+// TODO: Only called via dbus method - remove
void TabbedViewContainer::navigationTextModeChanged(bool useTextWidth)
{
+ // Qt 5.9 changed how tabs are displayed
if (useTextWidth) {
_tabBar->setStyleSheet(QStringLiteral("QTabBar::tab { }"));
_tabBar->setExpanding(false);
diff --git a/src/ViewContainer.h b/src/ViewContainer.h
index 167d246f..c4a52d72 100644
--- a/src/ViewContainer.h
+++ b/src/ViewContainer.h
@@ -149,6 +149,11 @@ public:
*/
NavigationPosition navigationPosition() const;
+ /**
+ * Set whether tab width are expanding
+ */
+ void setNavigationTabWidthExpanding(bool expand);
+
/**
* Returns the list of supported navigation positions.
* The supported positions will depend upon the type of the
@@ -322,6 +327,14 @@ protected:
{
}
+ /**
+ * Called when the navigation tab width expanding option changes.
+ * See setNavigationTabWidthExpanding
+ */
+ virtual void navigationTabWidthExpandingChanged(bool)
+ {
+ }
+
/**
* Called when the navigation position changes to re-layout
* the container and place the navigation widget in the
@@ -399,6 +412,7 @@ protected:
void removeViewWidget(QWidget *view) Q_DECL_OVERRIDE;
void navigationVisibilityChanged(NavigationVisibility mode) Q_DECL_OVERRIDE;
void navigationPositionChanged(NavigationPosition position) Q_DECL_OVERRIDE;
+ void navigationTabWidthExpandingChanged(bool expand) Q_DECL_OVERRIDE;
void navigationTextModeChanged(bool mode) Q_DECL_OVERRIDE;
void moveViewWidget(int fromIndex, int toIndex) Q_DECL_OVERRIDE;
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index 8d6b1ebd..48ff37e4 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -59,6 +59,7 @@ ViewManager::ViewManager(QObject *parent, KActionCollection *collection) :
_navigationVisibility(ViewContainer::AlwaysShowNavigation),
_navigationPosition(ViewContainer::NavigationPositionTop),
_showQuickButtons(false),
+ _navigationTabWidthExpanding(true),
_newTabBehavior(PutNewTabAtTheEnd),
_navigationStyleSheet(QString()),
_managerId(0)
@@ -672,6 +673,7 @@ ViewContainer *ViewManager::createContainer()
// FIXME: these code feels duplicated
container->setNavigationVisibility(_navigationVisibility);
container->setNavigationPosition(_navigationPosition);
+ container->setNavigationTabWidthExpanding(_navigationTabWidthExpanding);
container->setStyleSheet(_navigationStyleSheet);
if (_showQuickButtons) {
container->setFeatures(container->features()
@@ -1244,6 +1246,15 @@ void ViewManager::setNavigationPosition(int position)
}
}
+void ViewManager::setNavigationTabWidthExpanding(bool expand)
+{
+ _navigationTabWidthExpanding = expand;
+
+ foreach (ViewContainer *container, _viewSplitter->containers()) {
+ container->setNavigationTabWidthExpanding(expand);
+ }
+}
+
void ViewManager::setNavigationStyleSheet(const QString &styleSheet)
{
_navigationStyleSheet = styleSheet;
diff --git a/src/ViewManager.h b/src/ViewManager.h
index 4cc6daef..7d29b70c 100644
--- a/src/ViewManager.h
+++ b/src/ViewManager.h
@@ -168,6 +168,7 @@ public:
void setNavigationVisibility(int visibility);
void setNavigationPosition(int position);
void setNavigationBehavior(int behavior);
+ void setNavigationTabWidthExpanding(bool expand);
void setNavigationStyleSheet(const QString &styleSheet);
void setShowQuickButtons(bool show);
@@ -401,6 +402,7 @@ private:
ViewContainer::NavigationVisibility _navigationVisibility;
ViewContainer::NavigationPosition _navigationPosition;
bool _showQuickButtons;
+ bool _navigationTabWidthExpanding;
NewTabBehavior _newTabBehavior;
QString _navigationStyleSheet;
diff --git a/src/settings/TabBarSettings.ui b/src/settings/TabBarSettings.ui
index cbe68046..85093f87 100644
--- a/src/settings/TabBarSettings.ui
+++ b/src/settings/TabBarSettings.ui
@@ -17,10 +17,10 @@
<string>Appearance</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_1">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
<property name="text">
- <string>Tab bar visibility:</string>
+ <string>Tab bar position:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -52,34 +52,34 @@
</item>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_1">
<property name="text">
- <string>Tab bar position:</string>
+ <string>Tab bar visibility:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
- <item row="1" column="1" colspan="2">
- <widget class="KComboBox" name="kcfg_TabBarPosition">
+ <item row="4" column="0" colspan="2">
+ <widget class="QCheckBox" name="kcfg_ExpandTabWidth">
+ <property name="text">
+ <string>Expand Individual Tab Widths to Full Window</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="KUrlRequester" name="kcfg_TabBarUserStyleSheetFile">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>1</horstretch>
+ <horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <item>
- <property name="text">
- <string>Above Terminal Area</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Below Terminal Area</string>
- </property>
- </item>
+ <property name="filter" stdset="0">
+ <string>text/css</string>
+ </property>
</widget>
</item>
<item row="2" column="0" colspan="3">
@@ -89,23 +89,49 @@
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2">
+ <item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_TabBarUseUserStyleSheet">
<property name="text">
<string>Use user-defined stylesheet</string>
</property>
</widget>
</item>
- <item row="3" column="2">
- <widget class="KUrlRequester" name="kcfg_TabBarUserStyleSheetFile">
+ <item row="1" column="1" colspan="2">
+ <widget class="KComboBox" name="kcfg_TabBarPosition">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>2</horstretch>
+ <horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="filter">
- <string>text/css</string>
+ <item>
+ <property name="text">
+ <string>Above Terminal Area</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Below Terminal Area</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="3">
+ <widget class="QLabel" name="Qt59label">
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="text">
+ <string>Qt 5.9+ has changes that will affect the below two options.</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
</property>
</widget>
</item>
@@ -176,6 +202,7 @@
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
+ <container>1</container>
</customwidget>
</customwidgets>
<resources/>
diff --git a/src/settings/konsole.kcfg b/src/settings/konsole.kcfg
index 79f05a41..cfc8fb0d 100644
--- a/src/settings/konsole.kcfg
+++ b/src/settings/konsole.kcfg
@@ -104,6 +104,10 @@
</choices>
<default>PutNewTabAtTheEnd</default>
</entry>
+ <entry name="ExpandTabWidth" type="Bool">
+ <label>Expand the tab widths (Qt5.9+ uses the full window width)</label>
+ <default>true</default>
+ </entry>
</group>
<group name="PrintOptions">
<entry name="PrinterFriendly" type="Bool">
More information about the kde-doc-english
mailing list