mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
add Menu Bar toolbar button to toggle menu bar
This commit is contained in:
parent
ebf4173b88
commit
ec0b98f050
14
src/resources/icons/menubar.svg
Normal file
14
src/resources/icons/menubar.svg
Normal 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 |
@ -149,6 +149,9 @@ enable_compact_mode=true
|
|||||||
; Whether enable tools dock widget
|
; Whether enable tools dock widget
|
||||||
tools_dock_checked=true
|
tools_dock_checked=true
|
||||||
|
|
||||||
|
; Whether show menu bar
|
||||||
|
menu_bar_checked=true
|
||||||
|
|
||||||
; Pages to open on startup
|
; Pages to open on startup
|
||||||
; 0 - none; 1 - Continue where you left off; 2 - specific pages
|
; 0 - none; 1 - Continue where you left off; 2 - specific pages
|
||||||
startup_page_type=0
|
startup_page_type=0
|
||||||
|
@ -435,6 +435,9 @@ public:
|
|||||||
// Return [web]/copy_targets.
|
// Return [web]/copy_targets.
|
||||||
QStringList getCopyTargets() const;
|
QStringList getCopyTargets() const;
|
||||||
|
|
||||||
|
bool getMenuBarChecked() const;
|
||||||
|
void setMenuBarChecked(bool p_checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Look up a config from user and default settings.
|
// Look up a config from user and default settings.
|
||||||
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
||||||
@ -2022,4 +2025,15 @@ inline QString VConfigManager::getStyleOfSpanForMark() const
|
|||||||
return getConfigFromSettings("web",
|
return getConfigFromSettings("web",
|
||||||
"style_of_span_for_mark").toString();
|
"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
|
#endif // VCONFIGMANAGER_H
|
||||||
|
@ -429,18 +429,35 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
|||||||
|
|
||||||
viewToolBar->addAction(expandViewAct);
|
viewToolBar->addAction(expandViewAct);
|
||||||
|
|
||||||
m_fullScreenAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/fullscreen.svg"),
|
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"),
|
tr("Full Screen"),
|
||||||
this);
|
this);
|
||||||
QString keySeq = g_config->getShortcutKeySequence("FullScreen");
|
QString keySeq = g_config->getShortcutKeySequence("FullScreen");
|
||||||
QKeySequence seq(keySeq);
|
QKeySequence seq(keySeq);
|
||||||
if (!seq.isEmpty()) {
|
if (!seq.isEmpty()) {
|
||||||
m_fullScreenAct->setText(tr("Full Screen\t%1").arg(VUtils::getShortcutText(keySeq)));
|
fullScreenAct->setText(tr("Full Screen\t%1").arg(VUtils::getShortcutText(keySeq)));
|
||||||
m_fullScreenAct->setShortcut(seq);
|
fullScreenAct->setShortcut(seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fullScreenAct->setStatusTip(tr("Toggle full screen"));
|
fullScreenAct->setStatusTip(tr("Toggle full screen"));
|
||||||
connect(m_fullScreenAct, &QAction::triggered,
|
fullScreenAct->setMenu(screenMenu);
|
||||||
|
connect(fullScreenAct, &QAction::triggered,
|
||||||
this, [this]() {
|
this, [this]() {
|
||||||
if (windowState() & Qt::WindowFullScreen) {
|
if (windowState() & Qt::WindowFullScreen) {
|
||||||
if (m_windowOldState & Qt::WindowMaximized) {
|
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.
|
// Enable/disable all actions of @p_widget.
|
||||||
@ -764,6 +781,8 @@ void VMainWindow::initMenuBar()
|
|||||||
initViewMenu();
|
initViewMenu();
|
||||||
initMarkdownMenu();
|
initMarkdownMenu();
|
||||||
initHelpMenu();
|
initHelpMenu();
|
||||||
|
|
||||||
|
menuBar()->setVisible(g_config->getMenuBarChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initHelpMenu()
|
void VMainWindow::initHelpMenu()
|
||||||
@ -1877,12 +1896,12 @@ void VMainWindow::handleAreaTabStatusUpdated(const VEditTabInfo &p_info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect the trigger signal from edit tab.
|
// 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;
|
m_curTab = p_info.m_editTab;
|
||||||
if (m_curTab) {
|
if (m_curTab) {
|
||||||
connect(m_curTab, &VEditTab::triggerVimCmd,
|
connect((VEditTab *)m_curTab, &VEditTab::triggerVimCmd,
|
||||||
m_vimCmd, &VVimCmdLineEdit::reset);
|
m_vimCmd, &VVimCmdLineEdit::reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,8 +337,6 @@ private:
|
|||||||
|
|
||||||
QAction *expandViewAct;
|
QAction *expandViewAct;
|
||||||
|
|
||||||
QAction *m_fullScreenAct;
|
|
||||||
|
|
||||||
QAction *m_importNoteAct;
|
QAction *m_importNoteAct;
|
||||||
|
|
||||||
QAction *m_printAct;
|
QAction *m_printAct;
|
||||||
|
@ -238,5 +238,6 @@
|
|||||||
<file>resources/icons/cart.svg</file>
|
<file>resources/icons/cart.svg</file>
|
||||||
<file>resources/icons/delete_cart_item.svg</file>
|
<file>resources/icons/delete_cart_item.svg</file>
|
||||||
<file>resources/icons/fullscreen.svg</file>
|
<file>resources/icons/fullscreen.svg</file>
|
||||||
|
<file>resources/icons/menubar.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user