summaryrefslogtreecommitdiff
blob: fc62466ea6270c5d625a6999c147e8e4eecc0bfb (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
From fb7f838fd3138a39aea3bcb2e91f923741587137 Mon Sep 17 00:00:00 2001
From: Ahmad Samir <a.samirh78@gmail.com>
Date: Thu, 29 Jul 2021 18:44:07 +0200
Subject: [PATCH] Fix KXmlGUI toolbars; and Konsole MainWindow size

Call setupGUI(), which will call createGUI (since we set the
KXmlGuiWindow::Create flag), omit the StatusBar flag since we don't have a
statusbar and don't want the "Show StatusBar" menu action.

TabbedViewContainer::sizeHint() calculates an optimum size for itself,
including the sizes of its child widgets; added in efb621d091c05f11 by
Mariusz Glebocki; following the code:
MainWindow creates a ViewManager
ViewManager creates a TabbedViewContainer and then a TerminalDisplay

which means that the first time TabbedViewContainer::sizeHint() is called
the TerminalDisplay widget size is 0, then TabbedViewContainer::sizeHint()
would return 0.

Which is why calling resize() in MainWindow was delayed to the showEvent(),
(and even delayed more by a QTimer::singleShot() call in Application),
at which point all the child widgets have been created and
MainWindow::sizeHint() (which logically takes into account the sizeHint()
of its child widgets) would return a sensible size.

CCBUG: 430036
CCBUG: 439339
BUG: 436471


(cherry picked from commit 090356661c92bfedeeeaf6f4f77d294facb3d8c6)
---
 src/MainWindow.cpp | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index c67acf8b9..a4b36b61d 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -131,8 +131,10 @@ MainWindow::MainWindow() :
     // in terminal applications
     KAcceleratorManager::setNoAccel(menuBar());
 
-    // create menus
-    createGUI();
+    constexpr KXmlGuiWindow::StandardWindowOptions guiOpts = ToolBar | Keys | Save | Create;
+    const QString xmlFile = componentName() + QLatin1String("ui.rc"); // Typically "konsoleui.rc"
+    // The "Create" flag will make it call createGUI()
+    setupGUI(guiOpts, xmlFile);
 
     // remember the original menu accelerators for later use
     rememberMenuAccelerators();
@@ -945,9 +947,14 @@ void MainWindow::showEvent(QShowEvent *event)
         menuBar()->setVisible(_menuBarInitialVisibility);
         _toggleMenuBarAction->setChecked(_menuBarInitialVisibility);
         _menuBarInitialVisibilityApplied = true;
-        if (!KonsoleSettings::saveGeometryOnExit()) {
-            resize(sizeHint());
-        }
+    }
+
+    if (!KonsoleSettings::saveGeometryOnExit()) {
+        // Delay resizing to here, so that the other parts of the UI
+        // (ViewManager, TabbedViewContainer, TerminalDisplay ... etc)
+        // have been created and TabbedViewContainer::sizeHint() returns
+        // a usuable size.
+        resize(sizeHint());
     }
 
     // Call parent method
-- 
GitLab