diff --git a/src/resources/docs/shortcuts_en.md b/src/resources/docs/shortcuts_en.md index 78104aee..ddc24c40 100644 --- a/src/resources/docs/shortcuts_en.md +++ b/src/resources/docs/shortcuts_en.md @@ -200,8 +200,8 @@ Press the leader key `Ctrl+E`, then VNote will enter the Captain Mode, within wh - `E` Toggle expanding the edit area. -- `P` -Toggle single panel or two panels mode. +- `Y` +Focus to the edit area. - `T` Toggle the Tools panel. - `Shift+#` diff --git a/src/resources/docs/shortcuts_zh.md b/src/resources/docs/shortcuts_zh.md index 1f620d0a..3be805ea 100644 --- a/src/resources/docs/shortcuts_zh.md +++ b/src/resources/docs/shortcuts_zh.md @@ -201,8 +201,8 @@ RemoveSplit=R - `E` 是否扩展编辑区域。 -- `P` -切换单列/双列面板模式。 +- `Y` +将焦点设为编辑区域。 - `T` 打开或关闭工具面板。 - `Shift+#` diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index d45bcd24..aa0deed8 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -423,6 +423,8 @@ ApplySnippet=S Export=O ; Toggle live preview LivePreview=I +; Focus edit area +FocusEditArea=Y [external_editors] ; Define external editors which could be called to edit notes diff --git a/src/vbuttonwithwidget.h b/src/vbuttonwithwidget.h index 2cc1610b..bdd3134c 100644 --- a/src/vbuttonwithwidget.h +++ b/src/vbuttonwithwidget.h @@ -70,11 +70,6 @@ public: QWidget *getPopupWidget() const; - // Show the popup widget. - void showPopupWidget(); - - void hidePopupWidget(); - // Set the bubble to display a number @p_num. // @p_num: -1 to hide the bubble. void setBubbleNumber(int p_num); @@ -82,6 +77,12 @@ public: // Set the foreground and background of the bubble. void setBubbleColor(const QColor &p_fg, const QColor &p_bg); +public slots: + // Show the popup widget. + void showPopupWidget(); + + void hidePopupWidget(); + signals: // Emit when popup widget is about to show. void popupWidgetAboutToShow(QWidget *p_widget); diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index b90ec8a3..b03e53ea 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -210,6 +210,10 @@ void VMainWindow::registerCaptainAndNavigationTargets() g_config->getCaptainShortcutKeySequence("Export"), this, exportByCaptain); + m_captain->registerCaptainTarget(tr("FocusEditArea"), + g_config->getCaptainShortcutKeySequence("FocusEditArea"), + this, + focusEditAreaByCaptain); } void VMainWindow::setupUI() @@ -2818,6 +2822,15 @@ bool VMainWindow::exportByCaptain(void *p_target, void *p_data) return true; } +bool VMainWindow::focusEditAreaByCaptain(void *p_target, void *p_data) +{ + Q_UNUSED(p_data); + + VMainWindow *obj = static_cast(p_target); + obj->focusEditArea(); + return false; +} + void VMainWindow::promptNewNotebookIfEmpty() { if (vnote->getNotebooks().isEmpty()) { diff --git a/src/vmainwindow.h b/src/vmainwindow.h index 3ed7b70e..098c5c7c 100644 --- a/src/vmainwindow.h +++ b/src/vmainwindow.h @@ -328,6 +328,8 @@ private: static bool exportByCaptain(void *p_target, void *p_data); + static bool focusEditAreaByCaptain(void *p_target, void *p_data); + // End Captain mode functions. VNote *vnote; diff --git a/src/vtagpanel.cpp b/src/vtagpanel.cpp index 130f9cda..4dda785a 100644 --- a/src/vtagpanel.cpp +++ b/src/vtagpanel.cpp @@ -265,7 +265,8 @@ bool VTagPanel::handleKeyNavigation(int p_key, bool &p_succeed) // Show all tags panel. // To avoid focus in VCaptain after hiding the menu. g_mainWin->focusEditArea(); - m_btn->showPopupWidget(); + // Use timer to hide the label first. + QTimer::singleShot(50, m_btn, SLOT(showPopupWidget())); } else { m_tagEdit->setFocus(); }