Просмотр исходного кода

CaptainMode: Y to focus to edit area

Le Tan 7 лет назад
Родитель
Сommit
bc932fa913

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

+ 2 - 2
src/resources/docs/shortcuts_zh.md

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

+ 2 - 0
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

+ 6 - 5
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);

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

+ 2 - 0
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;

+ 2 - 1
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();
             }