forked from qt-creator/qt-creator
Core: Add action to hide the menu bar
This will only affect the platforms that do not have a native menu bar e.g. Windows and Linux excepting Unity. Fixes: QTCREATORBUG-29498 Change-Id: I17a654cfa50342f3e506bf0a2b14225c4d3a6bee Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -86,6 +86,7 @@ const char OPTIONS[] = "QtCreator.Options";
|
|||||||
const char LOGGER[] = "QtCreator.Logger";
|
const char LOGGER[] = "QtCreator.Logger";
|
||||||
const char TOGGLE_LEFT_SIDEBAR[] = "QtCreator.ToggleLeftSidebar";
|
const char TOGGLE_LEFT_SIDEBAR[] = "QtCreator.ToggleLeftSidebar";
|
||||||
const char TOGGLE_RIGHT_SIDEBAR[] = "QtCreator.ToggleRightSidebar";
|
const char TOGGLE_RIGHT_SIDEBAR[] = "QtCreator.ToggleRightSidebar";
|
||||||
|
const char TOGGLE_MENUBAR[] = "QtCreator.ToggleMenubar";
|
||||||
const char CYCLE_MODE_SELECTOR_STYLE[] =
|
const char CYCLE_MODE_SELECTOR_STYLE[] =
|
||||||
"QtCreator.CycleModeSelectorStyle";
|
"QtCreator.CycleModeSelectorStyle";
|
||||||
const char TOGGLE_FULLSCREEN[] = "QtCreator.ToggleFullScreen";
|
const char TOGGLE_FULLSCREEN[] = "QtCreator.ToggleFullScreen";
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/touchbar/touchbar.h>
|
#include <utils/touchbar/touchbar.h>
|
||||||
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/terminalcommand.h>
|
#include <utils/terminalcommand.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
@@ -106,6 +107,7 @@ static const char colorKey[] = "Color";
|
|||||||
static const char windowGeometryKey[] = "WindowGeometry";
|
static const char windowGeometryKey[] = "WindowGeometry";
|
||||||
static const char windowStateKey[] = "WindowState";
|
static const char windowStateKey[] = "WindowState";
|
||||||
static const char modeSelectorLayoutKey[] = "ModeSelectorLayout";
|
static const char modeSelectorLayoutKey[] = "ModeSelectorLayout";
|
||||||
|
static const char menubarVisibleKey[] = "MenubarVisible";
|
||||||
|
|
||||||
static const bool askBeforeExitDefault = false;
|
static const bool askBeforeExitDefault = false;
|
||||||
|
|
||||||
@@ -833,6 +835,27 @@ void MainWindow::registerDefaultActions()
|
|||||||
mview->addAction(cmd, Constants::G_VIEW_VIEWS);
|
mview->addAction(cmd, Constants::G_VIEW_VIEWS);
|
||||||
m_toggleRightSideBarButton->setEnabled(false);
|
m_toggleRightSideBarButton->setEnabled(false);
|
||||||
|
|
||||||
|
// Show Menubar Action
|
||||||
|
if (menuBar() && !menuBar()->isNativeMenuBar()) {
|
||||||
|
m_toggleMenubarAction = new QAction(Tr::tr("Show Menubar"), this);
|
||||||
|
m_toggleMenubarAction->setCheckable(true);
|
||||||
|
cmd = ActionManager::registerAction(m_toggleMenubarAction, Constants::TOGGLE_MENUBAR);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Alt+M")));
|
||||||
|
connect(m_toggleMenubarAction, &QAction::toggled, this, [this, cmd](bool visible) {
|
||||||
|
if (!visible) {
|
||||||
|
CheckableMessageBox::information(
|
||||||
|
Core::ICore::dialogParent(),
|
||||||
|
Tr::tr("Hide Menubar"),
|
||||||
|
Tr::tr(
|
||||||
|
"This will hide the menu bar completely. You can show it again by typing ")
|
||||||
|
+ cmd->keySequence().toString(QKeySequence::NativeText),
|
||||||
|
QString("ToogleMenuBarHint"));
|
||||||
|
}
|
||||||
|
menuBar()->setVisible(visible);
|
||||||
|
});
|
||||||
|
mview->addAction(cmd, Constants::G_VIEW_VIEWS);
|
||||||
|
}
|
||||||
|
|
||||||
registerModeSelectorStyleActions();
|
registerModeSelectorStyleActions();
|
||||||
|
|
||||||
// Window->Views
|
// Window->Views
|
||||||
@@ -1184,6 +1207,14 @@ void MainWindow::readSettings()
|
|||||||
updateModeSelectorStyleMenu();
|
updateModeSelectorStyleMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (menuBar() && !menuBar()->isNativeMenuBar()) {
|
||||||
|
const bool isVisible = settings->value(menubarVisibleKey, true).toBool();
|
||||||
|
|
||||||
|
menuBar()->setVisible(isVisible);
|
||||||
|
if (m_toggleMenubarAction)
|
||||||
|
m_toggleMenubarAction->setChecked(isVisible);
|
||||||
|
}
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
EditorManagerPrivate::readSettings();
|
EditorManagerPrivate::readSettings();
|
||||||
@@ -1202,6 +1233,9 @@ void MainWindow::saveSettings()
|
|||||||
StyleHelper::requestedBaseColor(),
|
StyleHelper::requestedBaseColor(),
|
||||||
QColor(StyleHelper::DEFAULT_BASE_COLOR));
|
QColor(StyleHelper::DEFAULT_BASE_COLOR));
|
||||||
|
|
||||||
|
if (menuBar() && !menuBar()->isNativeMenuBar())
|
||||||
|
settings->setValue(menubarVisibleKey, menuBar()->isVisible());
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
DocumentManager::saveSettings();
|
DocumentManager::saveSettings();
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ private:
|
|||||||
QAction *m_loggerAction = nullptr;
|
QAction *m_loggerAction = nullptr;
|
||||||
QAction *m_toggleLeftSideBarAction = nullptr;
|
QAction *m_toggleLeftSideBarAction = nullptr;
|
||||||
QAction *m_toggleRightSideBarAction = nullptr;
|
QAction *m_toggleRightSideBarAction = nullptr;
|
||||||
|
QAction *m_toggleMenubarAction = nullptr;
|
||||||
QAction *m_cycleModeSelectorStyleAction = nullptr;
|
QAction *m_cycleModeSelectorStyleAction = nullptr;
|
||||||
QAction *m_setModeSelectorStyleIconsAndTextAction = nullptr;
|
QAction *m_setModeSelectorStyleIconsAndTextAction = nullptr;
|
||||||
QAction *m_setModeSelectorStyleHiddenAction = nullptr;
|
QAction *m_setModeSelectorStyleHiddenAction = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user