mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Set the tab title to the current focused Terminal
This commit is contained in:
@@ -277,18 +277,35 @@ void TabbedViewContainer::addView(TerminalDisplay *view, int index)
|
||||
insertTab(index, viewSplitter, item->icon(), item->title());
|
||||
}
|
||||
|
||||
connect(item, &Konsole::ViewProperties::titleChanged, this,
|
||||
&Konsole::TabbedViewContainer::updateTitle);
|
||||
connect(item, &Konsole::ViewProperties::iconChanged, this,
|
||||
&Konsole::TabbedViewContainer::updateIcon);
|
||||
connect(item, &Konsole::ViewProperties::activity, this,
|
||||
&Konsole::TabbedViewContainer::updateActivity);
|
||||
|
||||
connectTerminalDisplay(view);
|
||||
connect(viewSplitter, &ViewSplitter::destroyed, this, &TabbedViewContainer::viewDestroyed);
|
||||
setCurrentIndex(index);
|
||||
emit viewAdded(view);
|
||||
}
|
||||
|
||||
void TabbedViewContainer::splitView(TerminalDisplay *view, Qt::Orientation orientation)
|
||||
{
|
||||
auto viewSplitter = qobject_cast<ViewSplitter*>(currentWidget());
|
||||
viewSplitter->addTerminalDisplay(view, orientation);
|
||||
connectTerminalDisplay(view);
|
||||
}
|
||||
|
||||
void TabbedViewContainer::connectTerminalDisplay(TerminalDisplay *display)
|
||||
{
|
||||
auto item = display->sessionController();
|
||||
connect(item, &Konsole::SessionController::focused, this,
|
||||
&Konsole::TabbedViewContainer::currentSessionControllerChanged);
|
||||
|
||||
connect(item, &Konsole::ViewProperties::titleChanged, this,
|
||||
&Konsole::TabbedViewContainer::updateTitle);
|
||||
|
||||
connect(item, &Konsole::ViewProperties::iconChanged, this,
|
||||
&Konsole::TabbedViewContainer::updateIcon);
|
||||
|
||||
connect(item, &Konsole::ViewProperties::activity, this,
|
||||
&Konsole::TabbedViewContainer::updateActivity);
|
||||
}
|
||||
|
||||
void TabbedViewContainer::viewDestroyed(QObject *view)
|
||||
{
|
||||
auto widget = static_cast<ViewSplitter*>(view);
|
||||
@@ -360,12 +377,12 @@ void TabbedViewContainer::tabDoubleClicked(int index)
|
||||
|
||||
void TabbedViewContainer::renameTab(int index)
|
||||
{
|
||||
/* TODO: Fix renaming.
|
||||
The problem with the renaming right now is that many Terminals can be at a tab.
|
||||
*/
|
||||
|
||||
if (index != -1) {
|
||||
// terminalAt(index)->sessionController()->rename();
|
||||
setCurrentIndex(index);
|
||||
viewSplitterAt(index)
|
||||
-> activeTerminalDisplay()
|
||||
-> sessionController()
|
||||
-> rename();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,11 +481,17 @@ void TabbedViewContainer::updateActivity(ViewProperties *item)
|
||||
}
|
||||
}
|
||||
|
||||
void TabbedViewContainer::currentSessionControllerChanged(SessionController *controller)
|
||||
{
|
||||
updateTitle(qobject_cast<ViewProperties*>(controller));
|
||||
}
|
||||
|
||||
void TabbedViewContainer::updateTitle(ViewProperties *item)
|
||||
{
|
||||
auto controller = qobject_cast<SessionController*>(item);
|
||||
auto topLevelSplitter = qobject_cast<ViewSplitter*>(controller->view()->parentWidget())->getToplevelSplitter();
|
||||
|
||||
const int index = indexOf(controller->view());
|
||||
const int index = indexOf(topLevelSplitter);
|
||||
QString tabText = item->title();
|
||||
|
||||
setTabToolTip(index, tabText);
|
||||
|
||||
@@ -77,6 +77,9 @@ public:
|
||||
/** Adds a new view to the container widget */
|
||||
void addView(TerminalDisplay *view, int index = -1);
|
||||
|
||||
/** splits the currently focused Splitter */
|
||||
void splitView(TerminalDisplay *view, Qt::Orientation orientation);
|
||||
|
||||
/** Removes a view from the container */
|
||||
void removeView(TerminalDisplay *view);
|
||||
|
||||
@@ -130,7 +133,7 @@ public:
|
||||
void currentTabChanged(int index);
|
||||
void closeCurrentTab();
|
||||
void wheelScrolled(int delta);
|
||||
|
||||
void currentSessionControllerChanged(SessionController *controller);
|
||||
void tabDoubleClicked(int index);
|
||||
void openTabContextMenu(const QPoint &point);
|
||||
void setNavigationVisibility(ViewManager::NavigationVisibility navigationVisibility);
|
||||
@@ -144,6 +147,9 @@ public:
|
||||
* this is the only thing that should be used to retrieve widgets.
|
||||
*/
|
||||
ViewSplitter *viewSplitterAt(int index);
|
||||
|
||||
void connectTerminalDisplay(TerminalDisplay *view);
|
||||
|
||||
Q_SIGNALS:
|
||||
/** Emitted when the container has no more children */
|
||||
void empty(TabbedViewContainer *container);
|
||||
|
||||
@@ -513,7 +513,8 @@ void ViewManager::splitView(Qt::Orientation orientation)
|
||||
|
||||
auto terminalDisplay = createView(session);
|
||||
|
||||
viewSplitter->addTerminalDisplay(terminalDisplay, orientation);
|
||||
_viewContainer->splitView(terminalDisplay, orientation);
|
||||
|
||||
emit splitViewToggle(viewSplitter->count() > 0);
|
||||
|
||||
// focus the new container
|
||||
|
||||
Reference in New Issue
Block a user