CaptainMode: Y to focus to edit area

This commit is contained in:
Le Tan 2018-07-03 20:27:35 +08:00
parent 927bb54502
commit bc932fa913
7 changed files with 29 additions and 10 deletions

View File

@ -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+#`

View File

@ -201,8 +201,8 @@ RemoveSplit=R
- `E`
是否扩展编辑区域。
- `P`
切换单列/双列面板模式
- `Y`
将焦点设为编辑区域
- `T`
打开或关闭工具面板。
- `Shift+#`

View File

@ -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

View File

@ -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);

View File

@ -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<VMainWindow *>(p_target);
obj->focusEditArea();
return false;
}
void VMainWindow::promptNewNotebookIfEmpty()
{
if (vnote->getNotebooks().isEmpty()) {

View File

@ -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;

View File

@ -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();
}