Commit 5fc0c180 authored by Eugene Popov's avatar Eugene Popov Committed by Kurt Hindenburg
Browse files

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
parent a8a2b9a7
......@@ -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)
......
......@@ -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<SessionController> _pluggedController;
QList<IKonsolePlugin *> _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;
};
}
......
......@@ -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;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>385</width>
<height>384</height>
<width>654</width>
<height>483</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -49,23 +49,14 @@
<property name="spacing">
<number>6</number>
</property>
<item row="12" column="1">
<widget class="QCheckBox" name="kcfg_SearchReverseSearch">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Sets whether search should start from the bottom</string>
</property>
<item row="7" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Search backwards</string>
<string comment="@item:intext Search options">Search:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="2" column="1">
<widget class="QCheckBox" name="kcfg_AllowMenuAccelerators">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
......@@ -78,8 +69,8 @@
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="kcfg_SearchCaseSensitive">
<item row="0" column="1">
<widget class="QCheckBox" name="kcfg_RememberWindowSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -87,15 +78,15 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Sets whether the search is case sensitive</string>
<string>If enabled, profile settings will be ignored</string>
</property>
<property name="text">
<string>Case sensitive</string>
<string>Remember window size</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="kcfg_ShowMenuBarByDefault">
<item row="3" column="1">
<widget class="QCheckBox" name="kcfg_ShowWindowTitleOnTitleBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -103,28 +94,19 @@
</sizepolicy>
</property>
<property name="text">
<string>Show menubar</string>
<string>Show window title on the titlebar</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="kcfg_RememberWindowSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>If enabled, profile settings will be ignored</string>
</property>
<item row="5" column="1">
<widget class="QCheckBox" name="kcfg_FocusFollowsMouse">
<property name="text">
<string>Remember window size</string>
<string>Focus terminals when the mouse pointer is moved over them</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="kcfg_ShowWindowTitleOnTitleBar">
<item row="8" column="1">
<widget class="QCheckBox" name="kcfg_SearchRegExpression">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -132,11 +114,11 @@
</sizepolicy>
</property>
<property name="text">
<string>Show window title on the titlebar</string>
<string>Match using regular expressions</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="1" column="1">
<widget class="QCheckBox" name="kcfg_UseSingleInstance">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
......@@ -152,21 +134,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="kcfg_RemoveWindowTitleBarAndFrame">
<property name="text">
<string>Remove window titlebar and frame</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="kcfg_FocusFollowsMouse">
<property name="text">
<string>Focus terminals when the mouse pointer is moved over them</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="kcfg_SearchHighlightMatches">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
......@@ -179,34 +147,46 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="kcfg_ShowTerminalSizeHint">
<item row="6" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="kcfg_SearchCaseSensitive">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show hint for terminal size after resizing</string>
<property name="toolTip">
<string>Sets whether the search is case sensitive</string>
</property>
</widget>
</item>
<item row="14" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Notifications:</string>
<string>Case sensitive</string>
</property>
</widget>
</item>
<item row="9" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_2">
<item row="4" column="1">
<widget class="QCheckBox" name="kcfg_RemoveWindowTitleBarAndFrame">
<property name="text">
<string comment="@item:intext Search options">Search:</string>
<string>Remove window titlebar and frame</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="11" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -222,7 +202,24 @@
</property>
</spacer>
</item>
<item row="14" column="1">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Process and window:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="12" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Notifications:</string>
</property>
</widget>
</item>
<item row="12" column="1">
<layout class="QHBoxLayout" stretch="0,1">
<property name="spacing">
<number>0</number>
......@@ -258,45 +255,22 @@
</item>
</layout>
</item>
<item row="0" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="label">
<property name="text">
<string>Process and window:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="kcfg_SearchRegExpression">
<widget class="QCheckBox" name="kcfg_SearchReverseSearch">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Sets whether search should start from the bottom</string>
</property>
<property name="text">
<string>Match using regular expressions</string>
<string>Search backwards</string>
</property>
</widget>
</item>
<item row="13" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
......
......@@ -5,11 +5,6 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="konsolerc" />
<group name="KonsoleWindow">
<entry name="ShowMenuBarByDefault" type="Bool">
<label>Show menubar by default</label>
<tooltip>Show menubar by default in each Konsole window</tooltip>
<default>true</default>
</entry>
<entry name="RemoveWindowTitleBarAndFrame" type="Bool">
<label>Remove window titlebar and frame</label>
<default>false</default>
......@@ -28,11 +23,6 @@
<tooltip>Allow users to access top menu through Alt+Key combination</tooltip>
<default>false</default>
</entry>
<entry name="ShowTerminalSizeHint" type="Bool">
<label>Show hint for terminal size after resizing</label>
<tooltip>Show terminal size in columns and lines in the center of window after resizing</tooltip>
<default>true</default>
</entry>
<entry name="RememberWindowSize" type="Bool">
<label>Use current window size on next startup</label>
<tooltip>The window size will be saved upon exiting Konsole</tooltip>
......
  • FYI, in the future please keep the commit message to 70-75 characters per line - I just noticed this message overflows.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment