Commit b42ebb06 authored by Laurent Montel's avatar Laurent Montel
Browse files

Fix bug 431308: Hide Menu by Ctrl+M

BUG: 431308
FIXED-IN: 5.22.0
parent f1a27012
Pipeline #255160 passed with stage
in 1 minute and 19 seconds
......@@ -44,6 +44,11 @@
</entry>
<entry type="String" name="LastVersionSeen" hidden="true">
</entry>
<entry key="ShowMenuBar" type="Bool">
<default>true</default>
<!-- label and whatsthis are already provided by KStandardAction::showMenubar -->
<label></label>
</entry>
</group>
</kcfg>
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui version="421" name="kontact" >
<gui version="422" name="kontact" >
<MenuBar>
<Menu name="file" noMerge="1">
<text>&amp;File</text>
......@@ -19,6 +19,7 @@
<Menu noMerge="1" name="settings">
<text>&amp;Settings</text>
<Merge name="StandardToolBarMenuHandler" />
<Action name="options_show_menubar" group="settings_configure" />
<Merge/>
<Separator/>
<Action name="colorscheme_menu" />
......
......@@ -46,6 +46,7 @@ using namespace Kontact;
#include <KSqueezedTextLabel>
#include <KStandardAction>
#include <KSycoca>
#include <KToggleAction>
#include <KToolBar>
#include <KWindowConfig>
#include <KXMLGUIFactory>
......@@ -97,6 +98,8 @@ MainWindow::MainWindow()
KConfigGroup grp(KSharedConfig::openConfig(), "MainWindow");
KWindowConfig::restoreWindowSize(windowHandle(), grp);
setAutoSaveSettings();
mShowMenuBarAction->setChecked(Prefs::self()->showMenuBar());
slotToggleMenubar(true);
}
void MainWindow::initGUI()
......@@ -317,6 +320,29 @@ void MainWindow::setupActions()
auto manager = new KColorSchemeManager(this);
actionCollection()->addAction(QStringLiteral("colorscheme_menu"), manager->createSchemeSelectionMenu(this));
mShowMenuBarAction = KStandardAction::showMenubar(this, &MainWindow::slotToggleMenubar, actionCollection());
}
void MainWindow::slotToggleMenubar(bool dontShowWarning)
{
if (menuBar()) {
if (mShowMenuBarAction->isChecked()) {
menuBar()->show();
} else {
if (!dontShowWarning && (!toolBar()->isVisible() /* || !toolBar()->actions().contains(mHamburgerMenu)*/)) {
const QString accel = mShowMenuBarAction->shortcut().toString();
KMessageBox::information(this,
i18n("<qt>This will hide the menu bar completely."
" You can show it again by typing %1.</qt>",
accel),
i18n("Hide menu bar"),
QStringLiteral("HideMenuBarWarning"));
}
menuBar()->hide();
}
Prefs::self()->setShowMenuBar(mShowMenuBarAction->isChecked());
}
}
void MainWindow::slotFullScreen(bool t)
......
......@@ -22,10 +22,10 @@ class QSplitter;
class QStackedWidget;
class IntroductionWebEngineView;
class KToggleFullScreenAction;
class KToggleAction;
using PluginList = QList<KontactInterface::Plugin *>;
using ActionPluginList = QList<QAction *>;
namespace Kontact
{
class SidePaneBase;
......@@ -103,6 +103,8 @@ private Q_SLOTS:
private:
void setHelpText(QAction *action, const QString &text);
void slotFullScreen(bool t);
void slotToggleMenubar(bool dontShowWarning);
QFrame *mTopWidget = nullptr;
QSplitter *mSplitter = nullptr;
......@@ -129,6 +131,7 @@ private:
int mSaveSideBarWidth = 10;
QAction *mShowHideAction = nullptr;
KToggleFullScreenAction *mShowFullScreenAction = nullptr;
KToggleAction *mShowMenuBarAction = nullptr;
};
}
......
Supports Markdown
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