mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
MainWindow: support hiding tool bar
ToolBar: Ctrl+E Shift+#
This commit is contained in:
parent
ecbed00467
commit
e59a23cda6
@ -204,6 +204,8 @@ Toggle expanding the edit area.
|
|||||||
Toggle single panel or two panels mode.
|
Toggle single panel or two panels mode.
|
||||||
- `T`
|
- `T`
|
||||||
Toggle the Tools panel.
|
Toggle the Tools panel.
|
||||||
|
- `Shift+#`
|
||||||
|
Toggle the Tool Bar.
|
||||||
- `F`
|
- `F`
|
||||||
Popup the opened notes list of current split window. Within this list, pressing the sequence number in front of each note could jump to that note.
|
Popup the opened notes list of current split window. Within this list, pressing the sequence number in front of each note could jump to that note.
|
||||||
- `A`
|
- `A`
|
||||||
@ -226,6 +228,10 @@ Discard current changes and exit edit mode.
|
|||||||
Vertically split current window.
|
Vertically split current window.
|
||||||
- `R`
|
- `R`
|
||||||
Remove current split window.
|
Remove current split window.
|
||||||
|
- `Shift+|`
|
||||||
|
Maximize current split window.
|
||||||
|
- `=`
|
||||||
|
Distribute all the split windows evenly.
|
||||||
- `H`
|
- `H`
|
||||||
Jump to the first split window on the left.
|
Jump to the first split window on the left.
|
||||||
- `L`
|
- `L`
|
||||||
|
@ -205,6 +205,8 @@ RemoveSplit=R
|
|||||||
切换单列/双列面板模式。
|
切换单列/双列面板模式。
|
||||||
- `T`
|
- `T`
|
||||||
打开或关闭工具面板。
|
打开或关闭工具面板。
|
||||||
|
- `Shift+#`
|
||||||
|
打开或关闭工具栏。
|
||||||
- `F`
|
- `F`
|
||||||
打开当前分割窗口的笔记列表。在该列表中,可以直接按笔记对应的序号实现跳转。
|
打开当前分割窗口的笔记列表。在该列表中,可以直接按笔记对应的序号实现跳转。
|
||||||
- `A`
|
- `A`
|
||||||
@ -227,6 +229,10 @@ RemoveSplit=R
|
|||||||
垂直分割当前窗口。
|
垂直分割当前窗口。
|
||||||
- `R`
|
- `R`
|
||||||
移除当前分割窗口。
|
移除当前分割窗口。
|
||||||
|
- `Shift+|`
|
||||||
|
最大化当前分割窗口。
|
||||||
|
- `=`
|
||||||
|
均等分布所有分割窗口。
|
||||||
- `H`
|
- `H`
|
||||||
跳转到左边一个分割窗口。
|
跳转到左边一个分割窗口。
|
||||||
- `L`
|
- `L`
|
||||||
|
@ -159,6 +159,9 @@ search_dock_checked=false
|
|||||||
; Whether show menu bar
|
; Whether show menu bar
|
||||||
menu_bar_checked=true
|
menu_bar_checked=true
|
||||||
|
|
||||||
|
; Whether show tool bar
|
||||||
|
tool_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
|
||||||
@ -370,6 +373,8 @@ DiscardAndRead=Q
|
|||||||
ToolsDock=T
|
ToolsDock=T
|
||||||
; Toggle Search dock widget
|
; Toggle Search dock widget
|
||||||
SearchDock=C
|
SearchDock=C
|
||||||
|
; Toggle tool bar
|
||||||
|
ToolBar=Shift+#
|
||||||
; Close current note
|
; Close current note
|
||||||
CloseNote=X
|
CloseNote=X
|
||||||
; Show shortcuts help document
|
; Show shortcuts help document
|
||||||
|
@ -474,6 +474,9 @@ public:
|
|||||||
bool getMenuBarChecked() const;
|
bool getMenuBarChecked() const;
|
||||||
void setMenuBarChecked(bool p_checked);
|
void setMenuBarChecked(bool p_checked);
|
||||||
|
|
||||||
|
bool getToolBarChecked() const;
|
||||||
|
void setToolBarChecked(bool p_checked);
|
||||||
|
|
||||||
bool getSingleClickClosePreviousTab() const;
|
bool getSingleClickClosePreviousTab() const;
|
||||||
void setSingleClickClosePreviousTab(bool p_enabled);
|
void setSingleClickClosePreviousTab(bool p_enabled);
|
||||||
|
|
||||||
@ -2215,6 +2218,17 @@ inline void VConfigManager::setMenuBarChecked(bool p_checked)
|
|||||||
setConfigToSettings("global", "menu_bar_checked", p_checked);
|
setConfigToSettings("global", "menu_bar_checked", p_checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool VConfigManager::getToolBarChecked() const
|
||||||
|
{
|
||||||
|
return getConfigFromSettings("global",
|
||||||
|
"tool_bar_checked").toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void VConfigManager::setToolBarChecked(bool p_checked)
|
||||||
|
{
|
||||||
|
setConfigToSettings("global", "tool_bar_checked", p_checked);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool VConfigManager::getSingleClickClosePreviousTab() const
|
inline bool VConfigManager::getSingleClickClosePreviousTab() const
|
||||||
{
|
{
|
||||||
return m_singleClickClosePreviousTab;
|
return m_singleClickClosePreviousTab;
|
||||||
|
@ -175,6 +175,10 @@ void VMainWindow::registerCaptainAndNavigationTargets()
|
|||||||
g_config->getCaptainShortcutKeySequence("DiscardAndRead"),
|
g_config->getCaptainShortcutKeySequence("DiscardAndRead"),
|
||||||
this,
|
this,
|
||||||
discardAndReadByCaptain);
|
discardAndReadByCaptain);
|
||||||
|
m_captain->registerCaptainTarget(tr("ToolBar"),
|
||||||
|
g_config->getCaptainShortcutKeySequence("ToolBar"),
|
||||||
|
this,
|
||||||
|
toggleToolBarByCaptain);
|
||||||
m_captain->registerCaptainTarget(tr("ToolsDock"),
|
m_captain->registerCaptainTarget(tr("ToolsDock"),
|
||||||
g_config->getCaptainShortcutKeySequence("ToolsDock"),
|
g_config->getCaptainShortcutKeySequence("ToolsDock"),
|
||||||
this,
|
this,
|
||||||
@ -343,13 +347,15 @@ void VMainWindow::initToolBar()
|
|||||||
const int tbIconSize = g_config->getToolBarIconSize() * VUtils::calculateScaleFactor();
|
const int tbIconSize = g_config->getToolBarIconSize() * VUtils::calculateScaleFactor();
|
||||||
QSize iconSize(tbIconSize, tbIconSize);
|
QSize iconSize(tbIconSize, tbIconSize);
|
||||||
|
|
||||||
initFileToolBar(iconSize);
|
m_toolBars.append(initFileToolBar(iconSize));
|
||||||
initViewToolBar(iconSize);
|
m_toolBars.append(initViewToolBar(iconSize));
|
||||||
initEditToolBar(iconSize);
|
m_toolBars.append(initEditToolBar(iconSize));
|
||||||
initNoteToolBar(iconSize);
|
m_toolBars.append(initNoteToolBar(iconSize));
|
||||||
|
|
||||||
|
setToolBarVisible(g_config->getToolBarChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initViewToolBar(QSize p_iconSize)
|
QToolBar *VMainWindow::initViewToolBar(QSize p_iconSize)
|
||||||
{
|
{
|
||||||
QToolBar *viewToolBar = addToolBar(tr("View"));
|
QToolBar *viewToolBar = addToolBar(tr("View"));
|
||||||
viewToolBar->setObjectName("ViewToolBar");
|
viewToolBar->setObjectName("ViewToolBar");
|
||||||
@ -422,6 +428,8 @@ void VMainWindow::initViewToolBar(QSize p_iconSize)
|
|||||||
});
|
});
|
||||||
|
|
||||||
viewToolBar->addAction(expandViewAct);
|
viewToolBar->addAction(expandViewAct);
|
||||||
|
|
||||||
|
return viewToolBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable/disable all actions of @p_widget.
|
// Enable/disable all actions of @p_widget.
|
||||||
@ -434,7 +442,7 @@ static void setActionsEnabled(QWidget *p_widget, bool p_enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initEditToolBar(QSize p_iconSize)
|
QToolBar *VMainWindow::initEditToolBar(QSize p_iconSize)
|
||||||
{
|
{
|
||||||
m_editToolBar = addToolBar(tr("Edit Toolbar"));
|
m_editToolBar = addToolBar(tr("Edit Toolbar"));
|
||||||
m_editToolBar->setObjectName("EditToolBar");
|
m_editToolBar->setObjectName("EditToolBar");
|
||||||
@ -557,9 +565,11 @@ void VMainWindow::initEditToolBar(QSize p_iconSize)
|
|||||||
m_editToolBar->addAction(insertImageAct);
|
m_editToolBar->addAction(insertImageAct);
|
||||||
|
|
||||||
setActionsEnabled(m_editToolBar, false);
|
setActionsEnabled(m_editToolBar, false);
|
||||||
|
|
||||||
|
return m_editToolBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initNoteToolBar(QSize p_iconSize)
|
QToolBar *VMainWindow::initNoteToolBar(QSize p_iconSize)
|
||||||
{
|
{
|
||||||
QToolBar *noteToolBar = addToolBar(tr("Note Toolbar"));
|
QToolBar *noteToolBar = addToolBar(tr("Note Toolbar"));
|
||||||
noteToolBar->setObjectName("NoteToolBar");
|
noteToolBar->setObjectName("NoteToolBar");
|
||||||
@ -614,9 +624,11 @@ void VMainWindow::initNoteToolBar(QSize p_iconSize)
|
|||||||
noteToolBar->addWidget(m_attachmentBtn);
|
noteToolBar->addWidget(m_attachmentBtn);
|
||||||
noteToolBar->addAction(flashPageAct);
|
noteToolBar->addAction(flashPageAct);
|
||||||
noteToolBar->addAction(universalEntryAct);
|
noteToolBar->addAction(universalEntryAct);
|
||||||
|
|
||||||
|
return noteToolBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initFileToolBar(QSize p_iconSize)
|
QToolBar *VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||||
{
|
{
|
||||||
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
||||||
fileToolBar->setObjectName("NoteToolBar");
|
fileToolBar->setObjectName("NoteToolBar");
|
||||||
@ -707,6 +719,8 @@ void VMainWindow::initFileToolBar(QSize p_iconSize)
|
|||||||
fileToolBar->addAction(m_editReadAct);
|
fileToolBar->addAction(m_editReadAct);
|
||||||
fileToolBar->addAction(m_discardExitAct);
|
fileToolBar->addAction(m_discardExitAct);
|
||||||
fileToolBar->addAction(saveNoteAct);
|
fileToolBar->addAction(saveNoteAct);
|
||||||
|
|
||||||
|
return fileToolBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initMenuBar()
|
void VMainWindow::initMenuBar()
|
||||||
@ -922,6 +936,19 @@ void VMainWindow::initViewMenu()
|
|||||||
{
|
{
|
||||||
m_viewMenu = menuBar()->addMenu(tr("&View"));
|
m_viewMenu = menuBar()->addMenu(tr("&View"));
|
||||||
m_viewMenu->setToolTipsVisible(true);
|
m_viewMenu->setToolTipsVisible(true);
|
||||||
|
|
||||||
|
m_toolBarAct = new QAction(tr("Tool Bar"), this);
|
||||||
|
m_toolBarAct->setToolTip(tr("Toogle the tool bar"));
|
||||||
|
VUtils::fixTextWithCaptainShortcut(m_toolBarAct, "ToolBar");
|
||||||
|
m_toolBarAct->setCheckable(true);
|
||||||
|
m_toolBarAct->setChecked(g_config->getToolBarChecked());
|
||||||
|
connect(m_toolBarAct, &QAction::triggered,
|
||||||
|
this, [this] (bool p_checked) {
|
||||||
|
g_config->setToolBarChecked(p_checked);
|
||||||
|
setToolBarVisible(p_checked);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_viewMenu->addAction(m_toolBarAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initFileMenu()
|
void VMainWindow::initFileMenu()
|
||||||
@ -2645,7 +2672,20 @@ bool VMainWindow::showAttachmentListByCaptain(void *p_target, void *p_data)
|
|||||||
Q_UNUSED(p_data);
|
Q_UNUSED(p_data);
|
||||||
VMainWindow *obj = static_cast<VMainWindow *>(p_target);
|
VMainWindow *obj = static_cast<VMainWindow *>(p_target);
|
||||||
if (obj->m_attachmentBtn->isEnabled()) {
|
if (obj->m_attachmentBtn->isEnabled()) {
|
||||||
|
// Show tool bar first.
|
||||||
|
bool toolBarChecked = obj->m_toolBarAct->isChecked();
|
||||||
|
if (!toolBarChecked) {
|
||||||
|
obj->setToolBarVisible(true);
|
||||||
|
|
||||||
|
// Make it visible first.
|
||||||
|
QCoreApplication::sendPostedEvents();
|
||||||
|
}
|
||||||
|
|
||||||
obj->m_attachmentBtn->showPopupWidget();
|
obj->m_attachmentBtn->showPopupWidget();
|
||||||
|
|
||||||
|
if (!toolBarChecked) {
|
||||||
|
obj->setToolBarVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -2686,6 +2726,14 @@ bool VMainWindow::discardAndReadByCaptain(void *p_target, void *p_data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VMainWindow::toggleToolBarByCaptain(void *p_target, void *p_data)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_data);
|
||||||
|
VMainWindow *obj = static_cast<VMainWindow *>(p_target);
|
||||||
|
obj->m_toolBarAct->trigger();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool VMainWindow::toggleToolsDockByCaptain(void *p_target, void *p_data)
|
bool VMainWindow::toggleToolsDockByCaptain(void *p_target, void *p_data)
|
||||||
{
|
{
|
||||||
Q_UNUSED(p_data);
|
Q_UNUSED(p_data);
|
||||||
@ -3186,6 +3234,17 @@ void VMainWindow::setMenuBarVisible(bool p_visible)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VMainWindow::setToolBarVisible(bool p_visible)
|
||||||
|
{
|
||||||
|
for (auto bar : m_toolBars) {
|
||||||
|
if (p_visible) {
|
||||||
|
bar->setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||||
|
} else {
|
||||||
|
bar->setFixedHeight(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
|
void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
|
||||||
{
|
{
|
||||||
QTimer::singleShot(300, [this, p_files]() {
|
QTimer::singleShot(300, [this, p_files]() {
|
||||||
|
@ -211,14 +211,13 @@ private:
|
|||||||
|
|
||||||
void initToolBar();
|
void initToolBar();
|
||||||
|
|
||||||
void initFileToolBar(QSize p_iconSize = QSize());
|
QToolBar *initFileToolBar(QSize p_iconSize = QSize());
|
||||||
|
|
||||||
void initViewToolBar(QSize p_iconSize = QSize());
|
QToolBar *initViewToolBar(QSize p_iconSize = QSize());
|
||||||
|
|
||||||
void initNoteToolBar(QSize p_iconSize = QSize());
|
QToolBar *initNoteToolBar(QSize p_iconSize = QSize());
|
||||||
|
|
||||||
// Init the Edit toolbar.
|
QToolBar *initEditToolBar(QSize p_iconSize = QSize());
|
||||||
void initEditToolBar(QSize p_iconSize = QSize());
|
|
||||||
|
|
||||||
void initMenuBar();
|
void initMenuBar();
|
||||||
void initFileMenu();
|
void initFileMenu();
|
||||||
@ -297,6 +296,8 @@ private:
|
|||||||
|
|
||||||
void setMenuBarVisible(bool p_visible);
|
void setMenuBarVisible(bool p_visible);
|
||||||
|
|
||||||
|
void setToolBarVisible(bool p_visible);
|
||||||
|
|
||||||
void showNotebookPanel();
|
void showNotebookPanel();
|
||||||
|
|
||||||
// Captain mode functions.
|
// Captain mode functions.
|
||||||
@ -310,6 +311,8 @@ private:
|
|||||||
|
|
||||||
static bool discardAndReadByCaptain(void *p_target, void *p_data);
|
static bool discardAndReadByCaptain(void *p_target, void *p_data);
|
||||||
|
|
||||||
|
static bool toggleToolBarByCaptain(void *p_target, void *p_data);
|
||||||
|
|
||||||
static bool toggleToolsDockByCaptain(void *p_target, void *p_data);
|
static bool toggleToolsDockByCaptain(void *p_target, void *p_data);
|
||||||
|
|
||||||
static bool toggleSearchDockByCaptain(void *p_target, void *p_data);
|
static bool toggleSearchDockByCaptain(void *p_target, void *p_data);
|
||||||
@ -407,6 +410,8 @@ private:
|
|||||||
// Enable heading sequence for current note.
|
// Enable heading sequence for current note.
|
||||||
QAction *m_headingSequenceAct;
|
QAction *m_headingSequenceAct;
|
||||||
|
|
||||||
|
QAction *m_toolBarAct;
|
||||||
|
|
||||||
// Act group for render styles.
|
// Act group for render styles.
|
||||||
QActionGroup *m_renderStyleActs;
|
QActionGroup *m_renderStyleActs;
|
||||||
|
|
||||||
@ -416,9 +421,12 @@ private:
|
|||||||
// Menus
|
// Menus
|
||||||
QMenu *m_viewMenu;
|
QMenu *m_viewMenu;
|
||||||
|
|
||||||
// Edit Toolbar.
|
// Edit ToolBar.
|
||||||
QToolBar *m_editToolBar;
|
QToolBar *m_editToolBar;
|
||||||
|
|
||||||
|
// All the ToolBar.
|
||||||
|
QVector<QToolBar *> m_toolBars;
|
||||||
|
|
||||||
// Attachment button.
|
// Attachment button.
|
||||||
VButtonWithWidget *m_attachmentBtn;
|
VButtonWithWidget *m_attachmentBtn;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user