add Menu Bar toolbar button to toggle menu bar

This commit is contained in:
Le Tan 2018-01-22 22:23:46 +08:00
parent ebf4173b88
commit ec0b98f050
6 changed files with 61 additions and 12 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<g>
<path style="fill:#000000" d="M32,376h283.35c6.186-14.112,20.281-24,36.65-24s30.465,9.888,36.65,24H480v32h-91.35c-6.186,14.112-20.281,24-36.65,24
s-30.465-9.888-36.65-24H32"/>
<path style="fill:#000000" d="M32,240h91.35c6.186-14.112,20.281-24,36.65-24s30.465,9.888,36.65,24H480v32H196.65c-6.186,14.112-20.281,24-36.65,24
s-30.465-9.888-36.65-24H32"/>
<path style="fill:#000000" d="M32,104h283.35c6.186-14.112,20.281-24,36.65-24s30.465,9.888,36.65,24H480v32h-91.35c-6.186,14.112-20.281,24-36.65,24
s-30.465-9.888-36.65-24H32"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -149,6 +149,9 @@ enable_compact_mode=true
; Whether enable tools dock widget
tools_dock_checked=true
; Whether show menu bar
menu_bar_checked=true
; Pages to open on startup
; 0 - none; 1 - Continue where you left off; 2 - specific pages
startup_page_type=0

View File

@ -435,6 +435,9 @@ public:
// Return [web]/copy_targets.
QStringList getCopyTargets() const;
bool getMenuBarChecked() const;
void setMenuBarChecked(bool p_checked);
private:
// Look up a config from user and default settings.
QVariant getConfigFromSettings(const QString &section, const QString &key) const;
@ -2022,4 +2025,15 @@ inline QString VConfigManager::getStyleOfSpanForMark() const
return getConfigFromSettings("web",
"style_of_span_for_mark").toString();
}
inline bool VConfigManager::getMenuBarChecked() const
{
return getConfigFromSettings("global",
"menu_bar_checked").toBool();
}
inline void VConfigManager::setMenuBarChecked(bool p_checked)
{
setConfigToSettings("global", "menu_bar_checked", p_checked);
}
#endif // VCONFIGMANAGER_H

View File

@ -429,18 +429,35 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
viewToolBar->addAction(expandViewAct);
m_fullScreenAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/fullscreen.svg"),
tr("Full Screen"),
this);
QAction *menuBarAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/menubar.svg"),
tr("Menu Bar"),
this);
menuBarAct->setStatusTip(tr("Toggle menu bar"));
menuBarAct->setCheckable(true);
menuBarAct->setChecked(g_config->getMenuBarChecked());
connect(menuBarAct, &QAction::triggered,
this, [this](bool p_checked) {
menuBar()->setVisible(p_checked);
g_config->setMenuBarChecked(p_checked);
});
QMenu *screenMenu = new QMenu(this);
screenMenu->setToolTipsVisible(true);
screenMenu->addAction(menuBarAct);
QAction *fullScreenAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/fullscreen.svg"),
tr("Full Screen"),
this);
QString keySeq = g_config->getShortcutKeySequence("FullScreen");
QKeySequence seq(keySeq);
if (!seq.isEmpty()) {
m_fullScreenAct->setText(tr("Full Screen\t%1").arg(VUtils::getShortcutText(keySeq)));
m_fullScreenAct->setShortcut(seq);
fullScreenAct->setText(tr("Full Screen\t%1").arg(VUtils::getShortcutText(keySeq)));
fullScreenAct->setShortcut(seq);
}
m_fullScreenAct->setStatusTip(tr("Toggle full screen"));
connect(m_fullScreenAct, &QAction::triggered,
fullScreenAct->setStatusTip(tr("Toggle full screen"));
fullScreenAct->setMenu(screenMenu);
connect(fullScreenAct, &QAction::triggered,
this, [this]() {
if (windowState() & Qt::WindowFullScreen) {
if (m_windowOldState & Qt::WindowMaximized) {
@ -453,7 +470,7 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
}
});
viewToolBar->addAction(m_fullScreenAct);
viewToolBar->addAction(fullScreenAct);
}
// Enable/disable all actions of @p_widget.
@ -764,6 +781,8 @@ void VMainWindow::initMenuBar()
initViewMenu();
initMarkdownMenu();
initHelpMenu();
menuBar()->setVisible(g_config->getMenuBarChecked());
}
void VMainWindow::initHelpMenu()
@ -1877,12 +1896,12 @@ void VMainWindow::handleAreaTabStatusUpdated(const VEditTabInfo &p_info)
}
// Disconnect the trigger signal from edit tab.
disconnect(m_curTab, 0, m_vimCmd, 0);
disconnect((VEditTab *)m_curTab, 0, m_vimCmd, 0);
}
m_curTab = p_info.m_editTab;
if (m_curTab) {
connect(m_curTab, &VEditTab::triggerVimCmd,
connect((VEditTab *)m_curTab, &VEditTab::triggerVimCmd,
m_vimCmd, &VVimCmdLineEdit::reset);
}

View File

@ -337,8 +337,6 @@ private:
QAction *expandViewAct;
QAction *m_fullScreenAct;
QAction *m_importNoteAct;
QAction *m_printAct;

View File

@ -238,5 +238,6 @@
<file>resources/icons/cart.svg</file>
<file>resources/icons/delete_cart_item.svg</file>
<file>resources/icons/fullscreen.svg</file>
<file>resources/icons/menubar.svg</file>
</qresource>
</RCC>