From 5fc0c180f1efb90d819c69f9eb3575eb49dcfdf7 Mon Sep 17 00:00:00 2001 From: Eugene Popov Date: Sat, 31 Jul 2021 12:37:52 +0300 Subject: [PATCH] Use one option to control menubar visibility Currently there are two options to control menubar visibility: the first in the menu and the second in the preferences dialog, moreover the second option makes the changes persistent. This MR removes the second option (from the preferences dialog) and makes the first option (from the menu) make the changes persistent. BUG: 440328 --- src/MainWindow.cpp | 27 ++--- src/MainWindow.h | 12 ++- src/settings/GeneralSettings.cpp | 2 - src/settings/GeneralSettings.ui | 164 +++++++++++++------------------ src/settings/konsole.kcfg | 10 -- 5 files changed, 90 insertions(+), 125 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 08ce2240..3b5a3757 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -66,7 +66,6 @@ MainWindow::MainWindow() , _toggleMenuBarAction(nullptr) , _newTabMenuAction(nullptr) , _pluggedController(nullptr) - , _menuBarInitialVisibility(true) { updateUseTransparency(); @@ -114,15 +113,6 @@ 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")); @@ -783,7 +773,6 @@ void MainWindow::showSettingsDialog(const bool showProfilePage) void MainWindow::applyKonsoleSettings() { - setMenuBarInitialVisibility(KonsoleSettings::showMenuBarByDefault()); setRemoveWindowTitleBarAndFrame(KonsoleSettings::removeWindowTitleBarAndFrame()); if (KonsoleSettings::allowMenuAccelerators()) { restoreMenuAccelerators(); @@ -854,9 +843,10 @@ void MainWindow::setBlur(bool blur) } } -void MainWindow::setMenuBarInitialVisibility(bool visible) +void MainWindow::setMenuBarInitialVisibility(bool showMenuBar) { - _menuBarInitialVisibility = visible; + _windowArgsMenuBarVisible.enabled = true; + _windowArgsMenuBarVisible.showMenuBar = showMenuBar; } void MainWindow::setRemoveWindowTitleBarAndFrame(bool frameless) @@ -890,6 +880,17 @@ void MainWindow::showEvent(QShowEvent *event) 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 + if (_windowArgsMenuBarVisible.enabled) { + menuBar()->setVisible(_windowArgsMenuBarVisible.showMenuBar); + _toggleMenuBarAction->setChecked(_windowArgsMenuBarVisible.showMenuBar); + } else { + _toggleMenuBarAction->setChecked(menuBar()->isVisible()); + } + if (!KonsoleSettings::rememberWindowSize() || !wasWindowGeometrySaved()) { // Delay resizing to here, so that the other parts of the UI // (ViewManager, TabbedViewContainer, TerminalDisplay ... etc) diff --git a/src/MainWindow.h b/src/MainWindow.h index c738b460..f292ee6c 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -88,7 +88,7 @@ public: /** * Set the initial visibility of the menubar. */ - void setMenuBarInitialVisibility(bool visible); + void setMenuBarInitialVisibility(bool showMenuBar); /** * @brief Set the frameless state @@ -172,8 +172,6 @@ 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. @@ -205,9 +203,13 @@ private: QPointer _pluggedController; QList _plugins; - bool _menuBarInitialVisibility; - bool _firstShowEvent = true; bool _blurEnabled = false; + bool _firstShowEvent = true; + + struct { + bool enabled = false; // indicates that we got a command line argument for menubar + bool showMenuBar = true; + } _windowArgsMenuBarVisible; }; } diff --git a/src/settings/GeneralSettings.cpp b/src/settings/GeneralSettings.cpp index 6da27d38..fa76226e 100644 --- a/src/settings/GeneralSettings.cpp +++ b/src/settings/GeneralSettings.cpp @@ -17,8 +17,6 @@ GeneralSettings::GeneralSettings(QWidget *aParent) setupUi(this); connect(enableAllMessagesButton, &QPushButton::clicked, this, &Konsole::GeneralSettings::slotEnableAllMessages); - - kcfg_ShowTerminalSizeHint->setVisible(false); } GeneralSettings::~GeneralSettings() = default; diff --git a/src/settings/GeneralSettings.ui b/src/settings/GeneralSettings.ui index e7c34ba7..1e7bfa51 100644 --- a/src/settings/GeneralSettings.ui +++ b/src/settings/GeneralSettings.ui @@ -6,8 +6,8 @@ 0 0 - 385 - 384 + 654 + 483 @@ -49,23 +49,14 @@ 6 - - - - - 0 - 0 - - - - Sets whether search should start from the bottom - + + - Search backwards + Search: - + @@ -78,8 +69,8 @@ - - + + 0 @@ -87,15 +78,15 @@ - Sets whether the search is case sensitive + If enabled, profile settings will be ignored - Case sensitive + Remember window size - - + + 0 @@ -103,28 +94,19 @@ - Show menubar + Show window title on the titlebar - - - - - 0 - 0 - - - - If enabled, profile settings will be ignored - + + - Remember window size + Focus terminals when the mouse pointer is moved over them - - + + 0 @@ -132,11 +114,11 @@ - Show window title on the titlebar + Match using regular expressions - + @@ -152,21 +134,7 @@ - - - - Remove window titlebar and frame - - - - - - - Focus terminals when the mouse pointer is moved over them - - - - + @@ -179,34 +147,46 @@ - - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + 0 0 - - Show hint for terminal size after resizing + + Sets whether the search is case sensitive - - - - - Notifications: + Case sensitive - - + + - Search: + Remove window titlebar and frame - + Qt::Vertical @@ -222,7 +202,24 @@ - + + + + Process and window: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Notifications: + + + + 0 @@ -258,45 +255,22 @@ - - - - Process and window: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - + 0 0 + + Sets whether search should start from the bottom + - Match using regular expressions + Search backwards - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - diff --git a/src/settings/konsole.kcfg b/src/settings/konsole.kcfg index 3fc787f4..24a02ade 100644 --- a/src/settings/konsole.kcfg +++ b/src/settings/konsole.kcfg @@ -5,11 +5,6 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - - Show menubar by default in each Konsole window - true - false @@ -28,11 +23,6 @@ Allow users to access top menu through Alt+Key combination false - - - Show terminal size in columns and lines in the center of window after resizing - true - The window size will be saved upon exiting Konsole