From b641e06668aee6fc056e8b73860914d3386ad496 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 11 Sep 2021 02:48:12 +0200 Subject: [PATCH] Reimplement KMainWindow::applyMainWindowSettings() to override menubar state --- src/MainWindow.cpp | 15 +++++++++------ src/MainWindow.h | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index b041932f..7727da2e 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -114,6 +114,15 @@ MainWindow::MainWindow() KCrash::initialize(); } +void MainWindow::applyMainWindowSettings(const KConfigGroup &config) +{ + KMainWindow::applyMainWindowSettings(config); + + // Override the menubar state from the config file + menuBar()->setVisible(_menuBarInitialVisibility); + _toggleMenuBarAction->setChecked(_menuBarInitialVisibility); +} + bool MainWindow::wasWindowGeometrySaved() const { KSharedConfigPtr konsoleConfig = KSharedConfig::openConfig(QStringLiteral("konsolerc")); @@ -880,12 +889,6 @@ void MainWindow::showEvent(QShowEvent *event) // Apply this code on first show only if (_firstShowEvent) { _firstShowEvent = false; - // the initial visibility of menubar should be applied at this last - // moment. Otherwise, the initial visibility will be determined by - // what KMainWindow has automatically stored in konsolerc, but not by - // what users has explicitly configured . - menuBar()->setVisible(_menuBarInitialVisibility); - _toggleMenuBarAction->setChecked(_menuBarInitialVisibility); if (!KonsoleSettings::saveGeometryOnExit() || !wasWindowGeometrySaved()) { // Delay resizing to here, so that the other parts of the UI diff --git a/src/MainWindow.h b/src/MainWindow.h index 5c008aeb..c738b460 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -172,6 +172,8 @@ public Q_SLOTS: void viewFullScreen(bool fullScreen); private: + void applyMainWindowSettings(const KConfigGroup &config) override; + /** * Returns true if the window geometry was previously saved to the * config file, false otherwise.