summaryrefslogtreecommitdiffstats
path: root/source/kde/kde/patch/konsole/konsole_fix_toolbar.patch
blob: 6071db5e96b002213ec21500b2fa59d2a7f5d6c4 (plain) (blame)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
--- ./src/MainWindow.h.orig	2021-08-04 16:48:59.000000000 -0500
+++ ./src/MainWindow.h	2021-08-19 19:24:14.000000000 -0500
@@ -200,6 +200,7 @@
     bool _menuBarInitialVisibility;
     bool _menuBarInitialVisibilityApplied;
     bool _blurEnabled = false;
+    bool _isSavedUiState = false;
 };
 }
 
--- ./src/MainWindow.cpp.orig	2021-08-04 16:48:59.000000000 -0500
+++ ./src/MainWindow.cpp	2021-08-19 19:24:14.000000000 -0500
@@ -11,12 +11,12 @@
 #include <QMouseEvent>
 #include <QMenu>
 #include <QMenuBar>
-#include <QStatusBar>
 
 // KDE
 #include <KAcceleratorManager>
 #include <KActionCollection>
 #include <KActionMenu>
+#include <KCrash>
 #include <KIconUtils>
 #include <KShortcutsDialog>
 #include <KLocalizedString>
@@ -56,6 +56,8 @@
 #include "terminalDisplay/TerminalDisplay.h"
 #include "widgets/ViewContainer.h"
 
+#include <konsoledebug.h>
+
 using namespace Konsole;
 
 MainWindow::MainWindow() :
@@ -68,13 +70,22 @@
     _menuBarInitialVisibility(true),
     _menuBarInitialVisibilityApplied(false)
 {
-    if (!KonsoleSettings::saveGeometryOnExit()) {
+    KSharedConfigPtr konsoleConfig = KSharedConfig::openConfig(QStringLiteral("konsolerc"));
+    KConfigGroup cg = konsoleConfig->group(QStringLiteral("MainWindow"));
+    const bool isGroup = cg.exists();
+    if (isGroup) {
+        const QString stateConfig = cg.readEntry(QStringLiteral("State"));
+
+        // If "stateConfig" is empty then this is the very first run,
+        // i.e. no konsolerc file in $HOME
+        _isSavedUiState = !stateConfig.isEmpty();
+    }
+
+    if (isGroup && !KonsoleSettings::saveGeometryOnExit()) {
         // If we are not using the global Konsole save geometry on exit,
         // remove all geometry data from [MainWindow] in Konsolerc, so KWin will
         // manage it directly
-        KSharedConfigPtr konsoleConfig = KSharedConfig::openConfig(QStringLiteral("konsolerc"));
-        KConfigGroup group = konsoleConfig->group("MainWindow");
-        QMap<QString, QString> configEntries = group.entryMap();
+        QMap<QString, QString> configEntries = cg.entryMap();
         QMapIterator<QString, QString> i(configEntries);
 
         while (i.hasNext()) {
@@ -91,7 +102,7 @@
                 || i.key().contains(QLatin1String(" YPosition"))
 #endif
             ) {
-                group.deleteEntry(i.key());
+                cg.deleteEntry(i.key());
             }
         }
     }
@@ -103,7 +114,7 @@
 
     // create view manager
     _viewManager = new ViewManager(this, actionCollection());
-    connect(_viewManager, &Konsole::ViewManager::empty, this, &Konsole::MainWindow::close);
+    connect(_viewManager, &Konsole::ViewManager::empty, this, &QWidget::close);
     connect(_viewManager, &Konsole::ViewManager::activeViewChanged, this,
             &Konsole::MainWindow::activeViewChanged);
     connect(_viewManager, &Konsole::ViewManager::unplugController, this,
@@ -129,8 +140,10 @@
     // 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();
@@ -146,11 +159,7 @@
     connect(KonsoleSettings::self(), &Konsole::KonsoleSettings::configChanged, this,
             &Konsole::MainWindow::applyKonsoleSettings);
 
-
-    // KXMLGui is making the status bar always visible, we need to fix in a proper way.
-    if (statusBar() != nullptr) {
-        statusBar()->installEventFilter(this);
-    }
+    KCrash::initialize();
 }
 
 void MainWindow::updateUseTransparency()
@@ -889,7 +898,15 @@
 #if KWINDOWSYSTEM_VERSION < QT_VERSION_CHECK(5,82,0)
         KWindowEffects::enableBlurBehind(winId(), blur);
 #else
-        KWindowEffects::enableBlurBehind(windowHandle(), blur);
+        // Set the WA_NativeWindow attribute to force the creation of the QWindow.
+        // Without this QWidget::windowHandle() returns 0.
+        // See https://phabricator.kde.org/D23108
+        setAttribute(Qt::WA_NativeWindow);
+        if (QWindow *window = windowHandle()) {
+            KWindowEffects::enableBlurBehind(window, blur);
+        } else {
+            qCWarning(KonsoleDebug) << "Blur effect couldn't be enabled.";
+        }
 #endif
     }
 }
@@ -935,9 +952,14 @@
         menuBar()->setVisible(_menuBarInitialVisibility);
         _toggleMenuBarAction->setChecked(_menuBarInitialVisibility);
         _menuBarInitialVisibilityApplied = true;
-        if (!KonsoleSettings::saveGeometryOnExit()) {
-            resize(sizeHint());
-        }
+    }
+
+    if (!_isSavedUiState || !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
@@ -971,13 +993,7 @@
             default: ;
         }
     }
-    if (qobject_cast<QStatusBar*>(obj) != nullptr) {
-        switch(event->type()) {
-            case QEvent::Show: statusBar()->hide(); break;
-            default: return true;
-        }
-        return true;
-    }
+
     return KXmlGuiWindow::eventFilter(obj, event);
 }