Commit 4a3cab03 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

When closing a session, don't close the whole window if there are splits

When closing a session, we check if that is the last tab, and make the code
close the whole window, but we also need to make sure it's the last view,
i.e. no split views.

CCBUG: 440976
FIXED-IN: 21.12
parent 3d967a59
...@@ -494,9 +494,9 @@ void ViewManager::sessionFinished() ...@@ -494,9 +494,9 @@ void ViewManager::sessionFinished()
return; return;
} }
// The last session/tab? emit empty() so that close() is called in // The last session/tab, and only one view (no splits), emit empty()
// MainWindow, fixes #432077 // so that close() is called in MainWindow, fixes #432077
if (_viewContainer->count() == 1) { if (_viewContainer->count() == 1 && _viewContainer->currentTabViewCount() == 1) {
Q_EMIT empty(); Q_EMIT empty();
return; return;
} }
......
...@@ -144,6 +144,15 @@ ViewSplitter *TabbedViewContainer::viewSplitterAt(int index) ...@@ -144,6 +144,15 @@ ViewSplitter *TabbedViewContainer::viewSplitterAt(int index)
return qobject_cast<ViewSplitter*>(widget(index)); return qobject_cast<ViewSplitter*>(widget(index));
} }
int TabbedViewContainer::currentTabViewCount()
{
if (auto *splitter = activeViewSplitter()) {
return splitter->findChildren<TerminalDisplay*>().count();
}
return 1;
}
void TabbedViewContainer::moveTabToWindow(int index, QWidget *window) void TabbedViewContainer::moveTabToWindow(int index, QWidget *window)
{ {
auto splitter = viewSplitterAt(index); auto splitter = viewSplitterAt(index);
......
...@@ -135,6 +135,12 @@ public: ...@@ -135,6 +135,12 @@ public:
*/ */
ViewSplitter *viewSplitterAt(int index); ViewSplitter *viewSplitterAt(int index);
/**
* Returns the number of split views (i.e. TerminalDisplay widgets)
* in this tab; if there are no split views, 1 is returned.
*/
int currentTabViewCount();
void connectTerminalDisplay(TerminalDisplay *display); void connectTerminalDisplay(TerminalDisplay *display);
void disconnectTerminalDisplay(TerminalDisplay *display); void disconnectTerminalDisplay(TerminalDisplay *display);
void moveTabLeft(); void moveTabLeft();
......
Supports Markdown
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