summaryrefslogtreecommitdiff
path: root/kde-apps/konsole/files/konsole-21.04.3-dont-close-window-while-split.patch
blob: 20762b109574f2fa30f813f535b79a468f5d6768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 2591a9489a4d3a43c7a7f00764e9f84822d4946c Mon Sep 17 00:00:00 2001
From: Ahmad Samir <a.samirh78@gmail.com>
Date: Sun, 15 Aug 2021 15:51:33 +0200
Subject: [PATCH] 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.08.1
(cherry picked from commit 4a3cab03f5d853f4dd48531979fc3fb57dde5e2e)
---
 src/ViewManager.cpp           | 6 +++---
 src/widgets/ViewContainer.cpp | 9 +++++++++
 src/widgets/ViewContainer.h   | 6 ++++++
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index 9c006e2bd..426040b78 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -494,9 +494,9 @@ void ViewManager::sessionFinished()
         return;
     }
 
-    // The last session/tab? emit empty() so that close() is called in
-    // MainWindow, fixes #432077
-    if (_viewContainer->count() == 1) {
+    // The last session/tab, and only one view (no splits), emit empty()
+    // so that close() is called in MainWindow, fixes #432077
+    if (_viewContainer->count() == 1 && _viewContainer->currentTabViewCount() == 1) {
         Q_EMIT empty();
         return;
     }
diff --git a/src/widgets/ViewContainer.cpp b/src/widgets/ViewContainer.cpp
index 2d7bfd13b..b25c00cdd 100644
--- a/src/widgets/ViewContainer.cpp
+++ b/src/widgets/ViewContainer.cpp
@@ -145,6 +145,15 @@ ViewSplitter *TabbedViewContainer::viewSplitterAt(int 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)
 {
     auto splitter = viewSplitterAt(index);
diff --git a/src/widgets/ViewContainer.h b/src/widgets/ViewContainer.h
index 3cbacf2cf..8e0a0986a 100644
--- a/src/widgets/ViewContainer.h
+++ b/src/widgets/ViewContainer.h
@@ -135,6 +135,12 @@ public:
      */
     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 disconnectTerminalDisplay(TerminalDisplay *display);
     void moveTabLeft();
-- 
GitLab