summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-02-19 07:19:37 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-02-19 07:23:48 (GMT)
commit4fb4da4c752b4781344f6eb9306780c35613d1bb (patch)
tree8697ab94e6fe3aeec7fffa54f38030a3b47c0cdf
parent2ba24db12c80fb834d139a69f7d15d22b5c1b40f (diff)
Add global option for showing window title on titlebar
When the window title from current session is emtpy, fallback to using tab title. CCBUG: 162326 REVIEW: 103978
-rw-r--r--src/MainWindow.cpp33
-rw-r--r--src/MainWindow.h1
-rw-r--r--src/SessionController.cpp12
-rw-r--r--src/SessionController.h7
-rw-r--r--src/settings/GeneralSettings.ui13
-rw-r--r--src/settings/konsole.kcfg5
6 files changed, 67 insertions, 4 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 41ac955..9829e4b 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -184,6 +184,8 @@ void MainWindow::disconnectController(SessionController* controller)
{
disconnect(controller , SIGNAL(titleChanged(ViewProperties*))
, this , SLOT(activeViewTitleChanged(ViewProperties*)));
+ disconnect(controller , SIGNAL(rawTitleChanged())
+ , this , SLOT(updateWindowCaption()));
// KXmlGuiFactory::removeClient() will try to access actions associated
// with the controller internally, which may not be valid after the controller
@@ -206,11 +208,14 @@ void MainWindow::activeViewChanged(SessionController* controller)
if (_pluggedController)
disconnectController(_pluggedController);
- // listen for title changes from the current session
Q_ASSERT(controller);
+ _pluggedController = controller;
+ // listen for title changes from the current session
connect(controller , SIGNAL(titleChanged(ViewProperties*)) ,
this , SLOT(activeViewTitleChanged(ViewProperties*)));
+ connect(controller , SIGNAL(rawTitleChanged()) ,
+ this , SLOT(updateWindowCaption()));
controller->setShowMenuAction(_toggleMenuBarAction);
guiFactory()->addClient(controller);
@@ -221,15 +226,33 @@ void MainWindow::activeViewChanged(SessionController* controller)
// update session title to match newly activated session
activeViewTitleChanged(controller);
- _pluggedController = controller;
-
// Update window icon to newly activated session's icon
updateWindowIcon();
}
void MainWindow::activeViewTitleChanged(ViewProperties* properties)
{
- setPlainCaption(properties->title());
+ Q_UNUSED(properties);
+ updateWindowCaption();
+}
+
+void MainWindow::updateWindowCaption()
+{
+ if ( !_pluggedController)
+ return;
+
+ const QString& title = _pluggedController->title();
+ const QString& userTitle = _pluggedController->userTitle();
+
+ // use tab title as caption by default
+ QString caption = title;
+
+ // use window title as caption only when enabled and it is not empty
+ if ( KonsoleSettings::showWindowTitleOnTitleBar() && !userTitle.isEmpty() ) {
+ caption = userTitle;
+ }
+
+ setCaption(caption);
}
void MainWindow::updateWindowIcon()
@@ -561,6 +584,8 @@ void MainWindow::applyKonsoleSettings()
_viewManager->updateNavigationOptions(options);
// setAutoSaveSettings("MainWindow", KonsoleSettings::saveGeometryOnExit());
+
+ updateWindowCaption();
}
void MainWindow::activateMenuBar()
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 4d0d3cb..23ae033 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -163,6 +163,7 @@ private slots:
void setSaveGeometryOnExit(bool visible);
void updateWindowIcon();
+ void updateWindowCaption();
void openUrls(const QList<KUrl>& urls);
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index b99b65c..d09a0fd 100644
--- a/src/SessionController.cpp
+++ b/src/SessionController.cpp
@@ -1118,6 +1118,7 @@ void SessionController::sessionTitleChanged()
title = _session->title(Session::NameRole);
setTitle(title);
+ emit rawTitleChanged();
}
void SessionController::showDisplayContextMenu(const QPoint& position)
@@ -1579,5 +1580,16 @@ QRegExp SearchHistoryTask::regExp() const
return _regExp;
}
+QString SessionController::userTitle () const
+{
+ if ( _session) {
+ return _session->userTitle();
+ }
+ else
+ {
+ return QString();
+ }
+}
+
#include "SessionController.moc"
diff --git a/src/SessionController.h b/src/SessionController.h
index 030f94c..2382023 100644
--- a/src/SessionController.h
+++ b/src/SessionController.h
@@ -107,6 +107,11 @@ public:
}
/**
+ * Returns the "window title" of the associated session.
+ */
+ QString userTitle () const;
+
+ /**
* Returns true if the controller is valid.
* A valid controller is one which has a non-null session() and view().
*
@@ -156,6 +161,8 @@ signals:
*/
void focused(SessionController* controller);
+ void rawTitleChanged();
+
public slots:
/**
* Issues a command to the session to navigate to the specified URL.
diff --git a/src/settings/GeneralSettings.ui b/src/settings/GeneralSettings.ui
index 34d936a..771f0bb 100644
--- a/src/settings/GeneralSettings.ui
+++ b/src/settings/GeneralSettings.ui
@@ -80,6 +80,19 @@
</property>
</widget>
</item>
+ <item row="4" column="0">
+ <widget class="QCheckBox" name="kcfg_ShowWindowTitleOnTitleBar">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Show window title on the titlebar</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/settings/konsole.kcfg b/src/settings/konsole.kcfg
index bc6fa9f..3bec25f 100644
--- a/src/settings/konsole.kcfg
+++ b/src/settings/konsole.kcfg
@@ -10,6 +10,11 @@
<tooltip>Show menubar initially in each Konsole window</tooltip>
<default>true</default>
</entry>
+ <entry name="ShowWindowTitleOnTitleBar" type="Bool">
+ <label>Show window title on the titlebar</label>
+ <tooltip>Show window title set by escape sequence on the titlebar</tooltip>
+ <default>false</default>
+ </entry>
<entry name="ShowTerminalSizeHint" type="Bool">
<label>Show hint for terminal size after resizing</label>
<tooltip>Show terminal size in columns and lines in the center of window after resizing</tooltip>