Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to hide menubar #1441

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/libs/core/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ void Settings::load()
minimizeToSystray = settings->value(QStringLiteral("minimize_to_systray"), false).toBool();
hideOnClose = settings->value(QStringLiteral("hide_on_close"), false).toBool();

hideMenuBar = settings->value(QStringLiteral("hide_menu_bar"), false).toBool();

settings->beginGroup(GroupGlobalShortcuts);
showShortcut = settings->value(QStringLiteral("show")).value<QKeySequence>();
settings->endGroup();
Expand Down Expand Up @@ -246,6 +248,8 @@ void Settings::save()
settings->setValue(QStringLiteral("minimize_to_systray"), minimizeToSystray);
settings->setValue(QStringLiteral("hide_on_close"), hideOnClose);

settings->setValue(QStringLiteral("hide_menu_bar"), hideMenuBar);

settings->beginGroup(GroupGlobalShortcuts);
settings->setValue(QStringLiteral("show"), showShortcut);
settings->endGroup();
Expand Down
3 changes: 3 additions & 0 deletions src/libs/core/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class Settings final : public QObject
// Tabs Behavior
bool openNewTabAfterActive;

// Appearance
bool hideMenuBar;

// Search
bool isFuzzySearchEnabled;

Expand Down
20 changes: 20 additions & 0 deletions src/libs/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent)
dialog->exec();
});

// View Menu
ui->actionHideMenu->setShortcut(QStringLiteral("Ctrl+m"));
connect(ui->actionHideMenu, &QAction::triggered, this, [this]() {
if (ui->menuBar->isVisible()) {
m_settings->hideMenuBar = true;
}
else {
m_settings->hideMenuBar = false;
}
applySettings();
});
addAction(ui->actionHideMenu);

// Help Menu
connect(ui->actionSubmitFeedback, &QAction::triggered, []() {
QDesktopServices::openUrl(QUrl(QStringLiteral("https://github.com/zealdocs/zeal/issues")));
Expand Down Expand Up @@ -533,6 +546,13 @@ void MainWindow::applySettings()
m_globalShortcut->setShortcut(m_settings->showShortcut);
}

if (m_settings->hideMenuBar){
ui->menuBar->hide();
}
else {
ui->menuBar->show();
}

if (m_settings->showSystrayIcon)
createTrayIcon();
else
Expand Down
12 changes: 12 additions & 0 deletions src/libs/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
<addaction name="separator"/>
<addaction name="actionPreferences"/>
</widget>
<widget class="QMenu" name="menu_View">
<property name="title">
<string>&amp;View</string>
</property>
<addaction name="actionHideMenu"/>
</widget>
<widget class="QMenu" name="menu_Tools">
<property name="title">
<string>&amp;Tools</string>
Expand All @@ -102,6 +108,7 @@
</widget>
<addaction name="menuFile"/>
<addaction name="menu_Edit"/>
<addaction name="menu_View"/>
<addaction name="menu_Tools"/>
<addaction name="menuHelp"/>
</widget>
Expand Down Expand Up @@ -175,6 +182,11 @@
<string>&amp;Find</string>
</property>
</action>
<action name="actionHideMenu">
<property name="text">
<string>&amp;Hide menubar</string>
</property>
</action>
<action name="actionDocsets">
<property name="text">
<string>&amp;Docsets…</string>
Expand Down