diff libgui/src/documentation.h @ 25155:17387d4edd1d stable

Add standard key bindings and actions to in-page Documentation find (bug #53006) * documentation.cc (documentation::documentation): Connect m_doc_browser cursor position change signal to slot that records position. Connect m_find_line_edit text-edited signal to find_forward_from_anchor() to provide search-while-type. Replace QKeySequence "Ctrl+F" definition with Qt's pre-defined QKeySequence::Find. Change the context of the key press from Qt::WidgetWithChildrenShortcut to the broader Qt::WindowShortcut and rename the sequence show_shortcut. Connect show_shortcut object's activated() signal to parent widget's show() slot and to m_find_line_edit's selectAll() and setFocus() slots. Create a hide_shortcut QShortcut with QKeySequence "Escape" and connect its activated() signal to parent widget's hide() slot and m_doc_browser's setFocus() slot. Create a findnext_shortcut and connect its activated() signal to the documentation class's find_forward() slot. Create a findnext_shortcut and connect its activated() signal to the documentation class's find_backward() slot. Set m_search_anchor_position to zero. (documentation::find_forward): After doing the find operation, record the current "anchor" position of the QTextEdit's cursor position. (documentation::find_backward): Ditto. (documentation::toggle_hidden_find): Removed. (documentation::find_forward_from_anchor): Added. For search-while-type, set the QTextEdit's cursor position back to the anchor position before calling the find() routine and allow "undoing" the search-while-type. (documentation::record_anchor_position): Added. Record the QTextEdit cursor's current position. (documentation::handle_cursor_position_change): Added. Upon the QTextEdit's cursor change, call record_anchor_position() but only if that position change was due to user action within the window. * documentation.h (documentation:public QSplitter): Add new integer member variable m_search_anchor_position. (documentation::find_forward_from_anchor): Added. Slot declaration. (documentation::record_anchor_position): Ditto. (documentation::handle_cursor_position_change): Ditto.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Thu, 05 Apr 2018 11:35:58 -0500
parents 9578133ca03e
children 41bbdf17f51a
line wrap: on
line diff
--- a/libgui/src/documentation.h	Sat Apr 07 15:08:15 2018 -0700
+++ b/libgui/src/documentation.h	Thu Apr 05 11:35:58 2018 -0500
@@ -88,13 +88,16 @@
     void filter_update_history (void);
     void find_forward (void);
     void find_backward (void);
-    void toggle_hidden_find (void);
+    void find_forward_from_anchor (const QString& text);
+    void record_anchor_position (void);
+    void handle_cursor_position_change (void);
 
   private:
 
     QHelpEngine *m_help_engine;
     documentation_browser *m_doc_browser;
     QLineEdit *m_find_line_edit;
+    int m_search_anchor_position;
     QComboBox *m_filter;
     QString m_collection;