diff libgui/src/m-editor/file-editor.cc @ 17628:99ffa521ecec

Add possibility to edit the function related to the actual keyword in editor * octave-qscintilla.cc(get_actual_word): new internal function; (context_help_doc): uses new function get_actual_word; (contextMenuEvent): new context menu for editing function of actual keyword (context_edit): function for edit action in editor file menu; (contextmenu_edit): new slot for context menu; * octave-qscintilla.h: new functions context_edit, contextmenu_edit, get_actual_word * file-editor-tab.cc(context_edit): new slot for editor menu action * file-editor-tab.h: new slot context_edit * file-editor.cc(request_context_edit): new slot for file menu entry; (construct): new entry in file menu for editing function of actual keyword; (add_file_editor_tab): connect new signal fetab_context_edit to the new slot context_edit in file_editor_tab; (set_shortcuts): enable/disable new shortcut when editor focus changes (check_actions): enable/disable new action depending on existing tabs * file-editor.h: new signal fetab_context_edit, new slot request_context_edit, new edit function action
author Torsten <ttl@justmail.de>
date Fri, 11 Oct 2013 14:12:37 +0200
parents 811019b9ef57
children 7945344506ae
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Fri Oct 11 13:05:06 2013 +0200
+++ b/libgui/src/m-editor/file-editor.cc	Fri Oct 11 14:12:37 2013 +0200
@@ -478,6 +478,12 @@
 }
 
 void
+file_editor::request_context_edit (bool)
+{
+  emit fetab_context_edit (_tab_widget->currentWidget ());
+}
+
+void
 file_editor::request_save_file (void)
 {
   emit fetab_save_file (_tab_widget->currentWidget ());
@@ -877,7 +883,10 @@
   fileMenu->addAction (new_action);
   fileMenu->addAction (open_action);
   fileMenu->addMenu (_mru_file_menu);
-
+  fileMenu->addSeparator ();
+  _context_edit_action =
+    fileMenu->addAction (QIcon (), tr ("&Edit Function"),
+                         this, SLOT (request_context_edit (bool)));
   fileMenu->addSeparator ();
   fileMenu->addAction (_save_action);
   fileMenu->addAction (_save_as_action);
@@ -1130,6 +1139,9 @@
   connect (this, SIGNAL (fetab_context_help (const QWidget*, bool)),
            f, SLOT (context_help (const QWidget*, bool)));
 
+  connect (this, SIGNAL (fetab_context_edit (const QWidget*)),
+           f, SLOT (context_edit (const QWidget*)));
+
   connect (this, SIGNAL (fetab_save_file (const QWidget*)),
            f, SLOT (save_file (const QWidget*)));
 
@@ -1241,6 +1253,7 @@
       _print_action->setShortcut (QKeySequence::Print);
       _run_action->setShortcut (Qt::ControlModifier+ Qt::Key_R);
 
+      _context_edit_action->setShortcut (Qt::ControlModifier + Qt::Key_E);
       _save_action->setShortcut (QKeySequence::Save);
       _save_as_action->setShortcut (QKeySequence::SaveAs);
       _close_action->setShortcut (QKeySequence::Close);
@@ -1270,6 +1283,7 @@
       _print_action->setShortcut (no_key);
       _run_action->setShortcut (no_key);
 
+      _context_edit_action->setShortcut (no_key);
       _save_action->setShortcut (no_key);
       _save_as_action->setShortcut (no_key);
       _close_action->setShortcut (no_key);
@@ -1303,6 +1317,7 @@
   _print_action->setEnabled (have_tabs);
   _run_action->setEnabled (have_tabs);
 
+  _context_edit_action->setEnabled (have_tabs);
   _save_action->setEnabled (have_tabs);
   _save_as_action->setEnabled (have_tabs);
   _close_action->setEnabled (have_tabs);