Mercurial > octave-nkf
comparison libgui/src/m-editor/file-editor.cc @ 18482:3a509de8e791 gui-release
automatic completion list as user preference (bug #41469)
* file-editor-tab.cc (constructor): remove unnecessary call for completion list;
(show_auto_completion): new slot showing autocompletion list at cursor;
(notice_settings): auto completion properties are set even if automatic
showing of the list is disabled, only treshold is updated
* file-editor-tab.h: new public slot show_completion list
* file-editor.cc (request_completion): new slot for completion-list-action
triggering a signal to the actual editor tab;
(construct): new action in edit menu for showing completion list, the signal
is connected to request_completion;
(add_file_editor_tab): connect signal for showing the completion list to
the new editor tab's slot show_auto_completion;
(set_shortcuts): set shortcut for new action;
(check_actions): disable new action when no tab is present
* file-editor.h: new action, new slot, new signal for tab
* settings-dialog.ui: update the settings dialog accordingly
author | Torsten <ttl@justmail.de> |
---|---|
date | Mon, 17 Feb 2014 20:42:08 +0100 |
parents | f959c63934e6 |
children | ca65b05b9a8a |
comparison
equal
deleted
inserted
replaced
18475:00d684465379 | 18482:3a509de8e791 |
---|---|
695 emit fetab_goto_line (_tab_widget->currentWidget ()); | 695 emit fetab_goto_line (_tab_widget->currentWidget ()); |
696 } | 696 } |
697 | 697 |
698 | 698 |
699 void | 699 void |
700 file_editor::request_completion (void) | |
701 { | |
702 emit fetab_completion (_tab_widget->currentWidget ()); | |
703 } | |
704 | |
705 void | |
700 file_editor::handle_mru_add_file (const QString& file_name) | 706 file_editor::handle_mru_add_file (const QString& file_name) |
701 { | 707 { |
702 _mru_files.removeAll (file_name); | 708 _mru_files.removeAll (file_name); |
703 _mru_files.prepend (file_name); | 709 _mru_files.prepend (file_name); |
704 mru_menu_update (); | 710 mru_menu_update (); |
984 _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), | 990 _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), |
985 tr ("Save File and Run"), _tool_bar); | 991 tr ("Save File and Run"), _tool_bar); |
986 | 992 |
987 _goto_line_action = new QAction (tr ("Go &to Line..."), _tool_bar); | 993 _goto_line_action = new QAction (tr ("Go &to Line..."), _tool_bar); |
988 | 994 |
995 _completion_action = new QAction (tr ("&Show Completion List"), _tool_bar); | |
996 | |
989 // the mru-list and an empty array of actions | 997 // the mru-list and an empty array of actions |
990 QSettings *settings = resource_manager::get_settings (); | 998 QSettings *settings = resource_manager::get_settings (); |
991 // FIXME: what should happen if settings is 0? | |
992 _mru_files = settings->value ("editor/mru_file_list").toStringList (); | 999 _mru_files = settings->value ("editor/mru_file_list").toStringList (); |
993 for (int i = 0; i < MaxMRUFiles; ++i) | 1000 for (int i = 0; i < MaxMRUFiles; ++i) |
994 { | 1001 { |
995 _mru_file_actions[i] = new QAction (this); | 1002 _mru_file_actions[i] = new QAction (this); |
996 _mru_file_actions[i]->setVisible (false); | 1003 _mru_file_actions[i]->setVisible (false); |
1013 _uncomment_selection_action->setShortcutContext (Qt::WindowShortcut); | 1020 _uncomment_selection_action->setShortcutContext (Qt::WindowShortcut); |
1014 _indent_selection_action->setShortcutContext (Qt::WindowShortcut); | 1021 _indent_selection_action->setShortcutContext (Qt::WindowShortcut); |
1015 _unindent_selection_action->setShortcutContext (Qt::WindowShortcut); | 1022 _unindent_selection_action->setShortcutContext (Qt::WindowShortcut); |
1016 _find_action->setShortcutContext (Qt::WindowShortcut); | 1023 _find_action->setShortcutContext (Qt::WindowShortcut); |
1017 _goto_line_action->setShortcutContext (Qt::WindowShortcut); | 1024 _goto_line_action->setShortcutContext (Qt::WindowShortcut); |
1025 _completion_action->setShortcutContext (Qt::WindowShortcut); | |
1018 | 1026 |
1019 // toolbar | 1027 // toolbar |
1020 _tool_bar->addAction (new_action); | 1028 _tool_bar->addAction (new_action); |
1021 _tool_bar->addAction (open_action); | 1029 _tool_bar->addAction (open_action); |
1022 _tool_bar->addAction (_save_action); | 1030 _tool_bar->addAction (_save_action); |
1090 editMenu->addSeparator (); | 1098 editMenu->addSeparator (); |
1091 editMenu->addAction (_find_action); | 1099 editMenu->addAction (_find_action); |
1092 editMenu->addSeparator (); | 1100 editMenu->addSeparator (); |
1093 editMenu->addAction (_comment_selection_action); | 1101 editMenu->addAction (_comment_selection_action); |
1094 editMenu->addAction (_uncomment_selection_action); | 1102 editMenu->addAction (_uncomment_selection_action); |
1095 editMenu->addSeparator (); | |
1096 editMenu->addAction (_indent_selection_action); | 1103 editMenu->addAction (_indent_selection_action); |
1097 editMenu->addAction (_unindent_selection_action); | 1104 editMenu->addAction (_unindent_selection_action); |
1105 editMenu->addSeparator (); | |
1106 editMenu->addAction (_completion_action); | |
1098 editMenu->addSeparator (); | 1107 editMenu->addSeparator (); |
1099 editMenu->addAction (_toggle_bookmark_action); | 1108 editMenu->addAction (_toggle_bookmark_action); |
1100 editMenu->addAction (_next_bookmark_action); | 1109 editMenu->addAction (_next_bookmark_action); |
1101 editMenu->addAction (_previous_bookmark_action); | 1110 editMenu->addAction (_previous_bookmark_action); |
1102 editMenu->addAction (_remove_bookmark_action); | 1111 editMenu->addAction (_remove_bookmark_action); |
1235 this, SLOT (request_find ())); | 1244 this, SLOT (request_find ())); |
1236 | 1245 |
1237 connect (_goto_line_action, SIGNAL (triggered ()), | 1246 connect (_goto_line_action, SIGNAL (triggered ()), |
1238 this, SLOT (request_goto_line ())); | 1247 this, SLOT (request_goto_line ())); |
1239 | 1248 |
1249 connect (_completion_action, SIGNAL (triggered ()), | |
1250 this, SLOT (request_completion ())); | |
1251 | |
1240 connect (_mru_file_menu, SIGNAL (triggered (QAction *)), | 1252 connect (_mru_file_menu, SIGNAL (triggered (QAction *)), |
1241 this, SLOT (request_mru_open_file (QAction *))); | 1253 this, SLOT (request_mru_open_file (QAction *))); |
1242 | 1254 |
1243 mru_menu_update (); | 1255 mru_menu_update (); |
1244 | 1256 |
1393 connect (this, SIGNAL (fetab_find (const QWidget*)), | 1405 connect (this, SIGNAL (fetab_find (const QWidget*)), |
1394 f, SLOT (find (const QWidget*))); | 1406 f, SLOT (find (const QWidget*))); |
1395 | 1407 |
1396 connect (this, SIGNAL (fetab_goto_line (const QWidget*, int)), | 1408 connect (this, SIGNAL (fetab_goto_line (const QWidget*, int)), |
1397 f, SLOT (goto_line (const QWidget*, int))); | 1409 f, SLOT (goto_line (const QWidget*, int))); |
1410 | |
1411 connect (this, SIGNAL (fetab_completion (const QWidget*)), | |
1412 f, SLOT (show_auto_completion (const QWidget*))); | |
1398 | 1413 |
1399 connect (this, SIGNAL (fetab_set_focus (const QWidget*)), | 1414 connect (this, SIGNAL (fetab_set_focus (const QWidget*)), |
1400 f, SLOT (set_focus (const QWidget*))); | 1415 f, SLOT (set_focus (const QWidget*))); |
1401 | 1416 |
1402 connect (this, SIGNAL (fetab_insert_debugger_pointer (const QWidget*, int)), | 1417 connect (this, SIGNAL (fetab_insert_debugger_pointer (const QWidget*, int)), |
1456 _context_help_action->setShortcut (QKeySequence::HelpContents); | 1471 _context_help_action->setShortcut (QKeySequence::HelpContents); |
1457 _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1); | 1472 _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1); |
1458 | 1473 |
1459 _find_action->setShortcut (QKeySequence::Find); | 1474 _find_action->setShortcut (QKeySequence::Find); |
1460 _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G); | 1475 _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G); |
1476 _completion_action->setShortcut (Qt::ControlModifier + Qt::Key_Space); | |
1461 | 1477 |
1462 _next_bookmark_action->setShortcut (Qt::Key_F2); | 1478 _next_bookmark_action->setShortcut (Qt::Key_F2); |
1463 _previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2); | 1479 _previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2); |
1464 _toggle_bookmark_action->setShortcut (Qt::Key_F7); | 1480 _toggle_bookmark_action->setShortcut (Qt::Key_F7); |
1465 | 1481 |
1490 _paste_action->setShortcut (no_key); | 1506 _paste_action->setShortcut (no_key); |
1491 _context_help_action->setShortcut (no_key); | 1507 _context_help_action->setShortcut (no_key); |
1492 | 1508 |
1493 _find_action->setShortcut (no_key); | 1509 _find_action->setShortcut (no_key); |
1494 _goto_line_action->setShortcut (no_key); | 1510 _goto_line_action->setShortcut (no_key); |
1511 _completion_action->setShortcut (no_key); | |
1495 | 1512 |
1496 _next_bookmark_action->setShortcut (no_key); | 1513 _next_bookmark_action->setShortcut (no_key); |
1497 _previous_bookmark_action->setShortcut (no_key); | 1514 _previous_bookmark_action->setShortcut (no_key); |
1498 _toggle_bookmark_action->setShortcut (no_key); | 1515 _toggle_bookmark_action->setShortcut (no_key); |
1499 | 1516 |
1526 _context_help_action->setEnabled (have_tabs); | 1543 _context_help_action->setEnabled (have_tabs); |
1527 _context_doc_action->setEnabled (have_tabs); | 1544 _context_doc_action->setEnabled (have_tabs); |
1528 | 1545 |
1529 _find_action->setEnabled (have_tabs); | 1546 _find_action->setEnabled (have_tabs); |
1530 _goto_line_action->setEnabled (have_tabs); | 1547 _goto_line_action->setEnabled (have_tabs); |
1548 _completion_action->setEnabled (have_tabs); | |
1531 | 1549 |
1532 _next_bookmark_action->setEnabled (have_tabs); | 1550 _next_bookmark_action->setEnabled (have_tabs); |
1533 _previous_bookmark_action->setEnabled (have_tabs); | 1551 _previous_bookmark_action->setEnabled (have_tabs); |
1534 _toggle_bookmark_action->setEnabled (have_tabs); | 1552 _toggle_bookmark_action->setEnabled (have_tabs); |
1535 _remove_bookmark_action->setEnabled (have_tabs); | 1553 _remove_bookmark_action->setEnabled (have_tabs); |