Commit 4fb4da4c authored by Jekyll Wu's avatar Jekyll Wu

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
parent 2ba24db1
......@@ -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()
......
......@@ -163,6 +163,7 @@ private slots:
void setSaveGeometryOnExit(bool visible);
void updateWindowIcon();
void updateWindowCaption();
void openUrls(const QList<KUrl>& urls);
......
......@@ -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"
......@@ -106,6 +106,11 @@ public:
return _view;
}
/**
* 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.
......
......@@ -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>
......
......@@ -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>
......
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