changeset 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 cc731bdc5103
children 20257791e358
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/m-editor/find-dialog.cc libgui/src/m-editor/find-dialog.h libgui/src/shortcut-manager.cc
diffstat 7 files changed, 89 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sun Mar 15 19:35:01 2015 +0100
+++ b/libgui/src/m-editor/file-editor-tab.cc	Fri Mar 25 14:28:40 2016 +1100
@@ -1178,7 +1178,7 @@
 }
 
 void
-file_editor_tab::find (const QWidget *ID)
+file_editor_tab::find (const QWidget *ID, QList<QAction *> fetab_actions)
 {
   if (ID != this)
     return;
@@ -1193,9 +1193,17 @@
   if (! _find_dialog)
     {
       _find_dialog = new find_dialog (_edit_area,
+                                      fetab_actions.mid (0,2),
                                       qobject_cast<QWidget *> (sender ()));
       connect (_find_dialog, SIGNAL (finished (int)),
                this, SLOT (handle_find_dialog_finished (int)));
+
+      connect (this, SIGNAL (request_find_next ()),
+               _find_dialog, SLOT (find_next ()));
+
+      connect (this, SIGNAL (request_find_previous ()),
+               _find_dialog, SLOT (find_prev ()));
+
       _find_dialog->setWindowModality (Qt::NonModal);
       _find_dialog_geometry = _find_dialog->geometry ();
     }
@@ -1214,6 +1222,20 @@
 }
 
 void
+file_editor_tab::find_next (const QWidget *ID)
+{
+  if (ID == this)
+    emit request_find_next ();
+}
+
+void
+file_editor_tab::find_previous (const QWidget *ID)
+{
+  if (ID == this)
+    emit request_find_previous ();
+}
+
+void
 file_editor_tab::goto_line (const QWidget *ID, int line)
 {
   if (ID != this)
--- a/libgui/src/m-editor/file-editor-tab.h	Sun Mar 15 19:35:01 2015 +0100
+++ b/libgui/src/m-editor/file-editor-tab.h	Fri Mar 25 14:28:40 2016 +1100
@@ -114,7 +114,9 @@
   void zoom_out (const QWidget *ID);
   void zoom_normal (const QWidget *ID);
 
-  void find (const QWidget *ID);
+  void find (const QWidget *ID, QList<QAction *>);
+  void find_next (const QWidget *ID);
+  void find_previous (const QWidget *ID);
   void goto_line (const QWidget *ID, int line = -1);
   void move_match_brace (const QWidget *ID, bool select);
   void show_auto_completion (const QWidget *ID);
@@ -159,6 +161,9 @@
   void edit_mfile_request (const QString&, const QString&,
                            const QString&, int);
 
+  void request_find_next (void);
+  void request_find_previous (void);
+
   void remove_breakpoint_via_debugger_linenr (int debugger_linenr);
   void request_remove_breakpoint_via_editor_linenr (int editor_linenr);
   void remove_all_breakpoints (void);
@@ -293,6 +298,7 @@
   int _line;
   int _col;
   bool _lines_changed;
+
 };
 
 #endif
--- 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);
 
--- a/libgui/src/m-editor/file-editor.h	Sun Mar 15 19:35:01 2015 +0100
+++ b/libgui/src/m-editor/file-editor.h	Fri Mar 25 14:28:40 2016 +1100
@@ -136,7 +136,9 @@
   void fetab_indent_selected_text (const QWidget* ID);
   void fetab_unindent_selected_text (const QWidget* ID);
   void fetab_convert_eol (const QWidget* ID, QsciScintilla::EolMode eol_mode);
-  void fetab_find (const QWidget* ID);
+  void fetab_find (const QWidget* ID, QList<QAction *>);
+  void fetab_find_next (const QWidget* ID);
+  void fetab_find_previous (const QWidget* ID);
   void fetab_goto_line (const QWidget* ID, int line = -1);
   void fetab_move_match_brace (const QWidget* ID, bool select);
   void fetab_completion (const QWidget*);
@@ -217,6 +219,8 @@
   void request_conv_eol_mac (bool);
 
   void request_find (bool);
+  void request_find_next (bool);
+  void request_find_previous (bool);
 
   void request_goto_line (bool);
   void request_completion (bool);
@@ -372,6 +376,8 @@
   QAction *_transpose_line_action;
 
   QAction *_find_action;
+  QAction *_find_next_action;
+  QAction *_find_previous_action;
   QAction *_find_files_action;
   QAction *_goto_line_action;
   QAction *_completion_action;
@@ -418,6 +424,8 @@
   QMenu *_fileMenu;
   QMenu *_view_editor_menu;
 
+  QList<QAction*> _fetab_actions;
+
   tab_widget *_tab_widget;
 
   int _marker_breakpoint;
--- a/libgui/src/m-editor/find-dialog.cc	Sun Mar 15 19:35:01 2015 +0100
+++ b/libgui/src/m-editor/find-dialog.cc	Fri Mar 25 14:28:40 2016 +1100
@@ -69,7 +69,8 @@
 #include <QIcon>
 #include "find-dialog.h"
 
-find_dialog::find_dialog (QsciScintilla* edit_area, QWidget *p)
+find_dialog::find_dialog (QsciScintilla* edit_area,
+                          QList<QAction *> find_actions, QWidget *p)
   : QDialog (p)
 {
   setWindowTitle (tr ("Find and Replace"));
@@ -175,6 +176,9 @@
   _rep_all = 0;
   _rep_active = false;
 
+  // set the actions
+  addActions (find_actions);
+
   // move dialog to side of the parent if there is room on the desktop to do so.
   int xp = p->x () +20;
   int yp = p->y () + p->frameGeometry ().height () - sizeHint ().height () -20;
--- a/libgui/src/m-editor/find-dialog.h	Sun Mar 15 19:35:01 2015 +0100
+++ b/libgui/src/m-editor/find-dialog.h	Fri Mar 25 14:28:40 2016 +1100
@@ -76,7 +76,8 @@
 {
   Q_OBJECT
 public:
-  find_dialog (QsciScintilla* edit_area, QWidget *parent = 0);
+  find_dialog (QsciScintilla* edit_area, QList<QAction *> find_actions,
+               QWidget *parent = 0);
   void init_search_text ();
 
 private slots:
--- a/libgui/src/shortcut-manager.cc	Sun Mar 15 19:35:01 2015 +0100
+++ b/libgui/src/shortcut-manager.cc	Fri Mar 25 14:28:40 2016 +1100
@@ -205,6 +205,10 @@
   init (tr ("Cut"), "editor_edit:cut", QKeySequence::Cut);
   init (tr ("Find and Replace"), "editor_edit:find_replace",
         QKeySequence::Find);
+  init (tr ("Find Next"), "editor_edit:find_next",
+        QKeySequence::FindNext);
+  init (tr ("Find Previous"), "editor_edit:find_previous",
+        QKeySequence::FindPrevious);
   init (tr ("Delete to Start of Word"), "editor_edit:delete_start_word",
         QKeySequence::DeleteStartOfWord);
   init (tr ("Delete to End of Word"), "editor_edit:delete_end_word",
@@ -255,7 +259,7 @@
         QKeySequence ());
 
   init (tr ("Goto Line"), "editor_edit:goto_line",
-        QKeySequence (ctrl + Qt::Key_G));
+        QKeySequence (ctrl + Qt::Key_L));
   init (tr ("Move to Matching Brace"), "editor_edit:move_to_brace",
         QKeySequence (ctrl + Qt::Key_M));
   init (tr ("Select to Matching Brace"), "editor_edit:select_to_brace",