diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 41ac955d5..9829e4b46 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 4d0d3cb04..23ae0334e 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& urls); diff --git a/src/SessionController.cpp b/src/SessionController.cpp index b99b65ca5..d09a0fd97 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 030f94ca2..238202350 100644 --- a/src/SessionController.h +++ b/src/SessionController.h @@ -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. diff --git a/src/settings/GeneralSettings.ui b/src/settings/GeneralSettings.ui index 34d936a45..771f0bb63 100644 --- a/src/settings/GeneralSettings.ui +++ b/src/settings/GeneralSettings.ui @@ -80,6 +80,19 @@ + + + + + 0 + 0 + + + + Show window title on the titlebar + + + diff --git a/src/settings/konsole.kcfg b/src/settings/konsole.kcfg index bc6fa9f27..3bec25fde 100644 --- a/src/settings/konsole.kcfg +++ b/src/settings/konsole.kcfg @@ -10,6 +10,11 @@ Show menubar initially in each Konsole window true + + + Show window title set by escape sequence on the titlebar + false + Show terminal size in columns and lines in the center of window after resizing