diff libgui/src/m-editor/file-editor.cc @ 22169:b3ced5e3cebb

Enable shortcuts for find next / find previous * file-editor-tab.cc (find_next, find_previous): new function/slot * file-editor-tab.cc (find): connect signals to the above and add the actions from the editor to the find dialog * file-editor-tab.h: New signals and slots * file-editor.cc (constructor): create list of actions for the editor tabs * file-editor.cc (request_find_next, request_find_previous): new funciton/slot * file-editor.cc (request_find): emit find signal with action list to tab * file-editor.cc (add_file_editor_tab): connect signals to the above * file-editor.cc (construct): new actions: find next / find previous * file-editor.cc (set_shortcut): shortcuts for the above * file-editor.cc (check_actions): enable the above * file-editor.h: New slots, signals and members * shortcut-manager.cc: shortcuts for find-next and find-previous, new default for Goto Line, which conflicts with find next in linux * find-dialog.cc (constructor): add new actions from the editor
author Lachlan Andrew <lachlanbis@gmail.com>
date Fri, 25 Mar 2016 14:28:40 +1100
parents 278fc29b69ca
children 603f0d752de2
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Sun Mar 15 19:35:01 2015 +0100
+++ b/libgui/src/m-editor/file-editor.cc	Fri Mar 25 14:28:40 2016 +1100
@@ -64,6 +64,10 @@
 
   construct ();
 
+  // actions that should also be available in the find dialog
+  _fetab_actions << _find_next_action;
+  _fetab_actions << _find_previous_action;
+
   setVisible (false);
   setAcceptDrops(true);
 
@@ -1045,7 +1049,19 @@
 void
 file_editor::request_find (bool)
 {
-  emit fetab_find (_tab_widget->currentWidget ());
+  emit fetab_find (_tab_widget->currentWidget (), _fetab_actions);
+}
+
+void
+file_editor::request_find_next (bool)
+{
+  emit fetab_find_next (_tab_widget->currentWidget ());
+}
+
+void
+file_editor::request_find_previous (bool)
+{
+  emit fetab_find_previous (_tab_widget->currentWidget ());
 }
 
 void
@@ -1612,6 +1628,12 @@
   _find_action = add_action (_edit_menu, resource_manager::icon ("edit-find-replace"),
           tr ("&Find and Replace..."), SLOT (request_find (bool)));
 
+  _find_next_action = add_action (_edit_menu, QIcon (),
+          tr ("Find &Next..."), SLOT (request_find_next (bool)));
+
+  _find_previous_action = add_action (_edit_menu, QIcon (),
+          tr ("Find &Previous..."), SLOT (request_find_previous (bool)));
+
   _edit_menu->addSeparator ();
 
   _edit_cmd_menu = _edit_menu->addMenu (tr ("&Commands"));
@@ -1832,6 +1854,8 @@
   _tool_bar->addAction (_cut_action);
   // _paste_action: later via the main window
   _tool_bar->addAction (_find_action);
+  //_tool_bar->addAction (_find_next_action);
+  //_tool_bar->addAction (_find_previous_action);
   _tool_bar->addSeparator ();
   _tool_bar->addAction (_run_action);
   _tool_bar->addSeparator ();
@@ -1981,7 +2005,7 @@
 
   // Signals from the file_editor non-trivial operations
   connect (this, SIGNAL (fetab_settings_changed (const QSettings *)),
-           f, SLOT (notice_settings (const QSettings *)));
+           f, SLOT (settings_changed (const QSettings *)));
 
   connect (this, SIGNAL (fetab_change_request (const QWidget*)),
            f, SLOT (change_editor_state (const QWidget*)));
@@ -2076,8 +2100,14 @@
   connect (this, SIGNAL (fetab_convert_eol (const QWidget*, QsciScintilla::EolMode)),
            f, SLOT (convert_eol (const QWidget*, QsciScintilla::EolMode)));
 
-  connect (this, SIGNAL (fetab_find (const QWidget*)),
-           f, SLOT (find (const QWidget*)));
+  connect (this, SIGNAL (fetab_find (const QWidget*, QList<QAction *>)),
+           f, SLOT (find (const QWidget*, QList<QAction *>)));
+
+  connect (this, SIGNAL (fetab_find_next (const QWidget*)),
+           f, SLOT (find_next (const QWidget*)));
+
+  connect (this, SIGNAL (fetab_find_previous (const QWidget*)),
+           f, SLOT (find_previous (const QWidget*)));
 
   connect (this, SIGNAL (fetab_goto_line (const QWidget*, int)),
            f, SLOT (goto_line (const QWidget*, int)));
@@ -2135,6 +2165,8 @@
   shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo");
   shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut");
   shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace");
+  shortcut_manager::set_shortcut (_find_next_action, "editor_edit:find_next");
+  shortcut_manager::set_shortcut (_find_previous_action, "editor_edit:find_previous");
 
   shortcut_manager::set_shortcut (_delete_start_word_action, "editor_edit:delete_start_word");
   shortcut_manager::set_shortcut (_delete_end_word_action, "editor_edit:delete_end_word");
@@ -2225,6 +2257,8 @@
   _zoom_normal_action->setEnabled (have_tabs);
 
   _find_action->setEnabled (have_tabs);
+  _find_next_action->setEnabled (have_tabs);
+  _find_previous_action->setEnabled (have_tabs);
   _print_action->setEnabled (have_tabs);
   _run_action->setEnabled (have_tabs);