Browse Source

bugfix: implement focusChild() of VMdTab and VHtmlTab to fix focus issue

Le Tan 8 years ago
parent
commit
a44259e66c
5 changed files with 16 additions and 1 deletions
  1. 1 1
      src/vedittab.h
  2. 4 0
      src/vhtmltab.cpp
  3. 3 0
      src/vhtmltab.h
  4. 5 0
      src/vmdtab.cpp
  5. 3 0
      src/vmdtab.h

+ 1 - 1
src/vedittab.h

@@ -71,7 +71,7 @@ protected:
     void wheelEvent(QWheelEvent *p_event) Q_DECL_OVERRIDE;
 
     // Called when VEditTab get focus. Should focus the proper child widget.
-    virtual void focusChild() {}
+    virtual void focusChild() = 0;
 
     // Called to zoom in/out content.
     virtual void zoom(bool p_zoomIn, qreal p_step = 0.25) = 0;

+ 4 - 0
src/vhtmltab.cpp

@@ -244,3 +244,7 @@ void VHtmlTab::zoom(bool /* p_zoomIn */, qreal /* p_step */)
 {
 }
 
+void VHtmlTab::focusChild()
+{
+    m_editor->setFocus();
+}

+ 3 - 0
src/vhtmltab.h

@@ -76,6 +76,9 @@ private:
     // Called to zoom in/out content.
     void zoom(bool p_zoomIn, qreal p_step = 0.25) Q_DECL_OVERRIDE;
 
+    // Focus the proper child widget.
+    void focusChild() Q_DECL_OVERRIDE;
+
     VEdit *m_editor;
 };
 #endif // VHTMLTAB_H

+ 5 - 0
src/vmdtab.cpp

@@ -704,3 +704,8 @@ MarkdownConverterType VMdTab::getMarkdownConverterType() const
 {
     return m_mdConType;
 }
+
+void VMdTab::focusChild()
+{
+    m_stacks->currentWidget()->setFocus();
+}

+ 3 - 0
src/vmdtab.h

@@ -120,6 +120,9 @@ private:
     // Zoom Web View.
     void zoomWebPage(bool p_zoomIn, qreal p_step = 0.25);
 
+    // Focus the proper child widget.
+    void focusChild() Q_DECL_OVERRIDE;
+
     VEdit *m_editor;
     VWebView *m_webViewer;
     VDocument *m_document;