comparison libgui/src/m-editor/file-editor.cc @ 17627:811019b9ef57

Add help and documentation on actual keyword to the editor menu * octave-qscintilla.cc(context_help_doc): new function for editor menu action; (get_global_textcursor_pos): new function for calculationg the cursor pos; (contextMenuEvent): uses get_global_textcursor_pos now, added context menu entry for documentation; (contextmenu_help,contextmenu_doc): slots for context menu; (contextmenu_help_doc): new common function used from context_help_doc and the context menu slots * octave-qscintilla.h: new functions context_help_doc, contextmenu_doc, contextmenu_help_doc, get_global_textcursor_pos * file-editor-tab.cc(context_help): new slot for editor menu action * file-editor-tab.h: new slot context_help * file-editor.cc(request_context_help,request_context_doc): new slots for help menu entries; (construct): new help menu with keyword help and documentation; (add_file_editor_tab): connect new signal fetab_context_help to the new slot context_help in file_editor_tab; (set_shortcuts): enable/disable new shortcuts when editor focus changes (check_actions): enable/disable new actions depending on existing tabs * file-editor.h: new signal fetab_context_help, new slots request_context_help and request_contest_doc, new help and doc actions
author Torsten <ttl@justmail.de>
date Fri, 11 Oct 2013 13:05:06 +0200
parents adf06e03fbdd
children 99ffa521ecec
comparison
equal deleted inserted replaced
17626:82b1778798d3 17627:811019b9ef57
462 462
463 void 463 void
464 file_editor::request_paste (void) 464 file_editor::request_paste (void)
465 { 465 {
466 emit fetab_paste (_tab_widget->currentWidget ()); 466 emit fetab_paste (_tab_widget->currentWidget ());
467 }
468
469 void
470 file_editor::request_context_help (bool)
471 {
472 emit fetab_context_help (_tab_widget->currentWidget (), false);
473 }
474 void
475 file_editor::request_context_doc (bool)
476 {
477 emit fetab_context_help (_tab_widget->currentWidget (), true);
467 } 478 }
468 479
469 void 480 void
470 file_editor::request_save_file (void) 481 file_editor::request_save_file (void)
471 { 482 {
925 936
926 QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); 937 QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar);
927 _run_menu->addAction (_run_action); 938 _run_menu->addAction (_run_action);
928 _menu_bar->addMenu (_run_menu); 939 _menu_bar->addMenu (_run_menu);
929 940
941 QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar);
942 _context_help_action =
943 _help_menu->addAction (QIcon (), tr ("&Help on Keyword"),
944 this, SLOT (request_context_help (bool)));
945 _context_doc_action =
946 _help_menu->addAction (QIcon (), tr ("&Documentation on Keyword"),
947 this, SLOT (request_context_doc (bool)));
948 _menu_bar->addMenu (_help_menu);
949
930 // shortcuts 950 // shortcuts
931 set_shortcuts (true); 951 set_shortcuts (true);
932 952
933 // layout 953 // layout
934 QVBoxLayout *vbox_layout = new QVBoxLayout (); 954 QVBoxLayout *vbox_layout = new QVBoxLayout ();
1105 f, SLOT (cut (const QWidget*))); 1125 f, SLOT (cut (const QWidget*)));
1106 1126
1107 connect (this, SIGNAL (fetab_paste (const QWidget*)), 1127 connect (this, SIGNAL (fetab_paste (const QWidget*)),
1108 f, SLOT (paste (const QWidget*))); 1128 f, SLOT (paste (const QWidget*)));
1109 1129
1130 connect (this, SIGNAL (fetab_context_help (const QWidget*, bool)),
1131 f, SLOT (context_help (const QWidget*, bool)));
1132
1110 connect (this, SIGNAL (fetab_save_file (const QWidget*)), 1133 connect (this, SIGNAL (fetab_save_file (const QWidget*)),
1111 f, SLOT (save_file (const QWidget*))); 1134 f, SLOT (save_file (const QWidget*)));
1112 1135
1113 connect (this, SIGNAL (fetab_save_file_as (const QWidget*)), 1136 connect (this, SIGNAL (fetab_save_file_as (const QWidget*)),
1114 f, SLOT (save_file_as (const QWidget*))); 1137 f, SLOT (save_file_as (const QWidget*)));
1203 _uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8); 1226 _uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8);
1204 1227
1205 _copy_action->setShortcut (QKeySequence::Copy); 1228 _copy_action->setShortcut (QKeySequence::Copy);
1206 _cut_action->setShortcut (QKeySequence::Cut); 1229 _cut_action->setShortcut (QKeySequence::Cut);
1207 _paste_action->setShortcut (QKeySequence::Paste); 1230 _paste_action->setShortcut (QKeySequence::Paste);
1231 _context_help_action->setShortcut (QKeySequence::HelpContents);
1232 _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1);
1208 1233
1209 _find_action->setShortcut (QKeySequence::Find); 1234 _find_action->setShortcut (QKeySequence::Find);
1210 _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G); 1235 _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G);
1211 1236
1212 _next_bookmark_action->setShortcut (Qt::Key_F2); 1237 _next_bookmark_action->setShortcut (Qt::Key_F2);
1231 _uncomment_selection_action->setShortcut (no_key); 1256 _uncomment_selection_action->setShortcut (no_key);
1232 1257
1233 _copy_action->setShortcut (no_key); 1258 _copy_action->setShortcut (no_key);
1234 _cut_action->setShortcut (no_key); 1259 _cut_action->setShortcut (no_key);
1235 _paste_action->setShortcut (no_key); 1260 _paste_action->setShortcut (no_key);
1261 _context_help_action->setShortcut (no_key);
1236 1262
1237 _find_action->setShortcut (no_key); 1263 _find_action->setShortcut (no_key);
1238 _goto_line_action->setShortcut (no_key); 1264 _goto_line_action->setShortcut (no_key);
1239 1265
1240 _next_bookmark_action->setShortcut (no_key); 1266 _next_bookmark_action->setShortcut (no_key);
1262 _uncomment_selection_action->setEnabled (have_tabs); 1288 _uncomment_selection_action->setEnabled (have_tabs);
1263 1289
1264 _copy_action->setEnabled (have_tabs); 1290 _copy_action->setEnabled (have_tabs);
1265 _cut_action->setEnabled (have_tabs); 1291 _cut_action->setEnabled (have_tabs);
1266 _paste_action->setEnabled (have_tabs); 1292 _paste_action->setEnabled (have_tabs);
1293 _context_help_action->setEnabled (have_tabs);
1294 _context_doc_action->setEnabled (have_tabs);
1267 1295
1268 _find_action->setEnabled (have_tabs); 1296 _find_action->setEnabled (have_tabs);
1269 _goto_line_action->setEnabled (have_tabs); 1297 _goto_line_action->setEnabled (have_tabs);
1270 1298
1271 _next_bookmark_action->setEnabled (have_tabs); 1299 _next_bookmark_action->setEnabled (have_tabs);