# HG changeset patch # User Torsten # Date 1398235339 -7200 # Node ID 777281eeb3d459160ed96df4a2ff3b9362e6a37e # Parent 8b9e99c061f9ed8c3b9ef2cdaef68db8148b96c3 add all editor actions to the shortcut manager and fix their shortcut context * file_editor_interface.h: new virtual function insert_new_open_actions * file-editor.cc (request_undo, request_redo, request_copy, request_cut, request_paste, request_selectall, request_save_file, request_save_file_as, request_print_file, request_run_file, request_toggle_bookmark, request_next_bookmark, request_previous_bookmark, request_remove_bookmark, request_toggle_breakpoint, request_next_breakpoint, request_previous_breakpoint, request_remove_breakpoint, request_comment_selected_text, request_uncomment_selected_text, request_indent_selected_text, request_unindent_selected_text, request_find, request_goto_line, request_completion) : change slot parameter from void to bool; (handle_editor_state_changed): renamed context_run_action; (notice_settings): call set_shortcuts without parameter; (insert_new_open_actions): new function called from main window for addings global action (new, open) to the editors file menu; (add_action): new function for adding a new action to a menu, connecting the slot, adding the action to the editor, and setting the shortcut context; (construct): make all actions class variables, add actions with add_actions, removing obsolete calls to QAction (), to setShortcutContext (), and to connect (), new submenu for navigation actions; (copyClipboard, pasteClipboard, selectAll): use slots with bool parameter; (set_shortcuts): remove the parameter of this function, it is now only called when the shortcut settings were changed and not when the terminal changes focus; (check_actions): enable/disable whole submenus instead of singe actions * file-editor.h: new function insert_new_open_actions, slots with bool parameter instead void, class variables for all actions, new submenus, set_shortcuts without parameter * main-window.cc (construct): do not connect the signal for setting shortcuts depending on terminal focus to the editor, insert new and open file actions into the editor file menu * main-window.h: remove the signal for settings other widgets shortcuts * shortcut-manager.cc (do_init_data): add more actions to the list diff -r 8b9e99c061f9 -r 777281eeb3d4 libgui/src/m-editor/file-editor-interface.h --- a/libgui/src/m-editor/file-editor-interface.h Fri Apr 18 15:04:39 2014 -0400 +++ b/libgui/src/m-editor/file-editor-interface.h Wed Apr 23 08:42:19 2014 +0200 @@ -44,6 +44,7 @@ virtual QMenu *debug_menu () = 0; virtual QToolBar *toolbar () = 0; + virtual void insert_new_open_actions (QAction*,QAction*,QAction*) = 0; virtual void handle_enter_debug_mode (void) = 0; virtual void handle_exit_debug_mode (void) = 0; diff -r 8b9e99c061f9 -r 777281eeb3d4 libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Fri Apr 18 15:04:39 2014 -0400 +++ b/libgui/src/m-editor/file-editor.cc Wed Apr 23 08:42:19 2014 +0200 @@ -570,37 +570,37 @@ } void -file_editor::request_undo (void) +file_editor::request_undo (bool) { emit fetab_undo (_tab_widget->currentWidget ()); } void -file_editor::request_redo (void) +file_editor::request_redo (bool) { emit fetab_redo (_tab_widget->currentWidget ()); } void -file_editor::request_copy (void) +file_editor::request_copy (bool) { emit fetab_copy (_tab_widget->currentWidget ()); } void -file_editor::request_cut (void) +file_editor::request_cut (bool) { emit fetab_cut (_tab_widget->currentWidget ()); } void -file_editor::request_paste (void) +file_editor::request_paste (bool) { emit fetab_paste (_tab_widget->currentWidget ()); } void -file_editor::request_selectall (void) +file_editor::request_selectall (bool) { emit fetab_selectall (_tab_widget->currentWidget ()); } @@ -624,26 +624,26 @@ } void -file_editor::request_save_file (void) +file_editor::request_save_file (bool) { emit fetab_save_file (_tab_widget->currentWidget ()); } void -file_editor::request_save_file_as (void) +file_editor::request_save_file_as (bool) { emit fetab_save_file_as (_tab_widget->currentWidget ()); } void -file_editor::request_print_file (void) +file_editor::request_print_file (bool) { emit fetab_print_file (_tab_widget->currentWidget ()); } void -file_editor::request_run_file (void) +file_editor::request_run_file (bool) { emit fetab_run_file (_tab_widget->currentWidget ()); } @@ -655,49 +655,49 @@ } void -file_editor::request_toggle_bookmark (void) +file_editor::request_toggle_bookmark (bool) { emit fetab_toggle_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_next_bookmark (void) +file_editor::request_next_bookmark (bool) { emit fetab_next_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_previous_bookmark (void) +file_editor::request_previous_bookmark (bool) { emit fetab_previous_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_remove_bookmark (void) +file_editor::request_remove_bookmark (bool) { emit fetab_remove_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_toggle_breakpoint (void) +file_editor::request_toggle_breakpoint (bool) { emit fetab_toggle_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_next_breakpoint (void) +file_editor::request_next_breakpoint (bool) { emit fetab_next_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_previous_breakpoint (void) +file_editor::request_previous_breakpoint (bool) { emit fetab_previous_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_remove_breakpoint (void) +file_editor::request_remove_breakpoint (bool) { emit fetab_remove_all_breakpoints (_tab_widget->currentWidget ()); } @@ -758,12 +758,12 @@ QsciCommand::LineTranspose); } void -file_editor::request_comment_selected_text (void) +file_editor::request_comment_selected_text (bool) { emit fetab_comment_selected_text (_tab_widget->currentWidget ()); } void -file_editor::request_uncomment_selected_text (void) +file_editor::request_uncomment_selected_text (bool) { emit fetab_uncomment_selected_text (_tab_widget->currentWidget ()); } @@ -782,33 +782,33 @@ QsciCommand::SelectionLowerCase); } void -file_editor::request_indent_selected_text (void) +file_editor::request_indent_selected_text (bool) { emit fetab_indent_selected_text (_tab_widget->currentWidget ()); } void -file_editor::request_unindent_selected_text (void) +file_editor::request_unindent_selected_text (bool) { emit fetab_unindent_selected_text (_tab_widget->currentWidget ()); } void -file_editor::request_find (void) +file_editor::request_find (bool) { emit fetab_find (_tab_widget->currentWidget ()); } void -file_editor::request_goto_line (void) +file_editor::request_goto_line (bool) { emit fetab_goto_line (_tab_widget->currentWidget ()); } void -file_editor::request_completion (void) +file_editor::request_completion (bool) { emit fetab_completion (_tab_widget->currentWidget ()); } @@ -969,7 +969,7 @@ { _copy_action->setEnabled (copy_available); _cut_action->setEnabled (copy_available); - _context_run_action->setEnabled (copy_available); + _run_selection_action->setEnabled (copy_available); if (!file_name.isEmpty ()) { @@ -1014,6 +1014,8 @@ _tab_widget->setUsesScrollButtons (true); _tab_widget->setStyleSheet (style_sheet); + set_shortcuts (); + // Relay signal to file editor tabs. emit fetab_settings_changed (settings); } @@ -1031,6 +1033,28 @@ } void +file_editor::insert_new_open_actions (QAction *new_action, + QAction *new_fcn_action, + QAction *open_action) +{ + _fileMenu->insertAction (_mru_file_menu->menuAction (), open_action); + _fileMenu->insertAction (open_action, new_fcn_action); + _fileMenu->insertAction (new_fcn_action, new_action); + _tool_bar->insertAction (_save_action, open_action); + _tool_bar->insertAction (open_action, new_action); +} + +QAction* +file_editor::add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member) +{ + QAction *a = menu->addAction (icon, text, this, member); + addAction (a); // important for shortcut context + a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + return a; +} + +void file_editor::construct (void) { QWidget *editor_widget = new QWidget (this); @@ -1049,84 +1073,6 @@ _tab_widget->setMovable (true); #endif - QAction *new_action = new QAction (QIcon (":/actions/icons/filenew.png"), - tr ("&New Script"), _tool_bar); - - QAction *open_action = new QAction (QIcon (":/actions/icons/folder_documents.png"), - tr ("&Open File..."), _tool_bar); - - _save_action = new QAction (QIcon (":/actions/icons/filesave.png"), - tr ("&Save File"), _tool_bar); - - _save_as_action = new QAction (QIcon (":/actions/icons/filesaveas.png"), - tr ("Save File &As..."), _tool_bar); - - _print_action = new QAction ( QIcon (":/actions/icons/fileprint.png"), - tr ("Print..."), _tool_bar); - - _undo_action = new QAction (QIcon (":/actions/icons/undo.png"), - tr ("&Undo"), _tool_bar); - - _redo_action = new QAction (QIcon (":/actions/icons/redo.png"), - tr ("&Redo"), _tool_bar); - - _copy_action = new QAction (QIcon (":/actions/icons/editcopy.png"), - tr ("&Copy"), _tool_bar); - _copy_action->setEnabled (false); - - _cut_action = new QAction (QIcon (":/actions/icons/editcut.png"), - tr ("Cu&t"), _tool_bar); - _cut_action->setEnabled (false); - - _paste_action - = new QAction (QIcon (":/actions/icons/editpaste.png"), - tr ("Paste"), _tool_bar); - - _next_bookmark_action = new QAction (tr ("&Next Bookmark"), _tool_bar); - - _previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"), - _tool_bar); - - _toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"), _tool_bar); - - _remove_bookmark_action - = new QAction (tr ("&Remove All Bookmarks"), _tool_bar); - - QAction *next_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_next.png"), - tr ("&Next Breakpoint"), _tool_bar); - QAction *previous_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_prev.png"), - tr ("Pre&vious Breakpoint"), _tool_bar); - QAction *toggle_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_toggle.png"), - tr ("Toggle &Breakpoint"), _tool_bar); - QAction *remove_all_breakpoints_action - = new QAction (QIcon (":/actions/icons/bp_rm_all.png"), - tr ("&Remove All Breakpoints"), _tool_bar); - - _selectall_action - = new QAction (tr ("Select All"), _tool_bar); - - _comment_selection_action - = new QAction (tr ("&Comment"), _tool_bar); - _uncomment_selection_action - = new QAction (tr ("&Uncomment"), _tool_bar); - - _indent_selection_action - = new QAction (tr ("&Indent"), _tool_bar); - _unindent_selection_action - = new QAction (tr ("&Unindent"), _tool_bar); - - _find_action = new QAction (QIcon (":/actions/icons/find.png"), - tr ("&Find and Replace..."), _tool_bar); - - _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), - tr ("Save File and Run"), _tool_bar); - - _goto_line_action = new QAction (tr ("Go &to Line..."), _tool_bar); - - _completion_action = new QAction (tr ("&Show Completion List"), _tool_bar); // the mru-list and an empty array of actions QSettings *settings = resource_manager::get_settings (); @@ -1137,30 +1083,217 @@ _mru_file_actions[i]->setVisible (false); } - // some actions are disabled from the beginning - _copy_action->setEnabled (false); - _cut_action->setEnabled (false); + // menu bar + + // file menu + + _fileMenu = new QMenu (tr ("&File"), _menu_bar); + + // new and open menus are inserted later by the main window + _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), _fileMenu); + for (int i = 0; i < MaxMRUFiles; ++i) + _mru_file_menu->addAction (_mru_file_actions[i]); + _fileMenu->addMenu (_mru_file_menu); + + _fileMenu->addSeparator (); + + _edit_function_action = add_action (_fileMenu, QIcon (), + tr ("&Edit Function"), SLOT (request_context_edit (bool))); + + _fileMenu->addSeparator (); + + _save_action = add_action (_fileMenu, QIcon (":/actions/icons/filesave.png"), + tr ("&Save File"), SLOT (request_save_file (bool))); + _save_as_action = add_action (_fileMenu, QIcon (":/actions/icons/filesaveas.png"), + tr ("Save File &As..."), SLOT (request_save_file_as (bool))); + + _fileMenu->addSeparator (); + + _close_action = add_action (_fileMenu, + QIcon::fromTheme("window-close",QIcon (":/actions/icons/fileclose.png")), + tr ("&Close"), SLOT (request_close_file (bool))); + _close_all_action = add_action (_fileMenu, + QIcon::fromTheme("window-close", QIcon (":/actions/icons/fileclose.png")), + tr ("Close All"), SLOT (request_close_all_files (bool))); + _close_others_action = add_action (_fileMenu, + QIcon::fromTheme("window-close", QIcon (":/actions/icons/fileclose.png")), + tr ("Close Other Files"), SLOT (request_close_other_files (bool))); + + _fileMenu->addSeparator (); + + _print_action = add_action (_fileMenu, QIcon (":/actions/icons/fileprint.png"), + tr ("Print..."), SLOT (request_print_file (bool))); + + _menu_bar->addMenu (_fileMenu); + + // edit menu + + QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); + + _undo_action = add_action (editMenu, QIcon (":/actions/icons/undo.png"), + tr ("&Undo"), SLOT (request_undo (bool))); + _redo_action = add_action (editMenu, QIcon (":/actions/icons/redo.png"), + tr ("&Redo"), SLOT (request_redo (bool))); - _run_action->setShortcutContext (Qt::WindowShortcut); - _save_action->setShortcutContext (Qt::WindowShortcut); - _save_as_action->setShortcutContext (Qt::WindowShortcut); + editMenu->addSeparator (); + + _copy_action = add_action (editMenu, QIcon (":/actions/icons/editcopy.png"), + tr ("&Copy"), SLOT (request_copy (bool))); + _copy_action->setEnabled (false); + _cut_action = add_action (editMenu, QIcon (":/actions/icons/editcut.png"), + tr ("Cu&t"), SLOT (request_cut (bool))); + _cut_action->setEnabled (false); + _paste_action = add_action (editMenu, QIcon (":/actions/icons/editpaste.png"), + tr ("Paste"), SLOT (request_paste (bool))); + + editMenu->addSeparator (); + + _selectall_action = add_action (editMenu, QIcon (), tr ("Select All"), + SLOT (request_selectall (bool))); + + editMenu->addSeparator (); + + _find_action = add_action (editMenu, QIcon (":/actions/icons/find.png"), + tr ("&Find and Replace..."), SLOT (request_find (bool))); + + editMenu->addSeparator (); + + _edit_cmd_menu = editMenu->addMenu (tr ("&Commands")); - _print_action->setShortcutContext (Qt::WindowShortcut); + _delete_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete Line"), SLOT (request_delete_line (bool))); + _copy_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Copy Line"), SLOT (request_copy_line (bool))); + _cut_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Cut Line"), SLOT (request_cut_line (bool))); + + _edit_cmd_menu->addSeparator (); + + _delete_start_word_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to Start of Word"), SLOT (request_delete_start_word (bool))); + _delete_end_word_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to End of Word"), SLOT (request_delete_end_word (bool))); + _delete_start_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to Start of Line"), SLOT (request_delete_start_line (bool))); + _delete_end_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to End of Line"), SLOT (request_delete_end_line (bool))); + + _edit_cmd_menu->addSeparator (); + + _duplicate_selection_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Duplicate Selection/Line"), SLOT (request_duplicate_selection (bool))); + _transpose_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Transpose Line"), SLOT (request_transpose_line (bool))); + + _edit_cmd_menu->addSeparator (); - _next_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _previous_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _comment_selection_action->setShortcutContext (Qt::WindowShortcut); - _uncomment_selection_action->setShortcutContext (Qt::WindowShortcut); - _indent_selection_action->setShortcutContext (Qt::WindowShortcut); - _unindent_selection_action->setShortcutContext (Qt::WindowShortcut); - _find_action->setShortcutContext (Qt::WindowShortcut); - _goto_line_action->setShortcutContext (Qt::WindowShortcut); - _completion_action->setShortcutContext (Qt::WindowShortcut); + _completion_action = add_action (_edit_cmd_menu, QIcon (), + tr ("&Show Completion List"), SLOT (request_completion (bool))); + + _edit_fmt_menu = editMenu->addMenu (tr ("&Format")); + + _upper_case_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Uppercase Selection"), SLOT (request_upper_case (bool))); + _lower_case_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Lowercase Selection"), SLOT (request_lower_case (bool))); + _comment_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Comment"), SLOT (request_comment_selected_text (bool))); + _uncomment_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool))); + _indent_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Indent"), SLOT (request_indent_selected_text (bool))); + _unindent_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Unindent"), SLOT (request_unindent_selected_text (bool))); + + _edit_nav_menu = editMenu->addMenu (tr ("Navi&gation")); + + _goto_line_action = add_action (_edit_nav_menu, QIcon (), + tr ("Go &to Line..."), SLOT (request_goto_line (bool))); + + _edit_nav_menu->addSeparator (); + + _next_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("&Next Bookmark"), SLOT (request_next_bookmark (bool))); + _previous_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("Pre&vious Bookmark"), SLOT (request_previous_bookmark (bool))); + _toggle_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("Toggle &Bookmark"), SLOT (request_toggle_bookmark (bool))); + _remove_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("&Remove All Bookmarks"), SLOT (request_remove_bookmark (bool))); + + editMenu->addSeparator (); + + _preferences_action = add_action (editMenu, + QIcon (":/actions/icons/configure.png"), + tr ("&Preferences..."), SLOT (request_preferences (bool))); + _styles_preferences_action = add_action (editMenu, + QIcon (":/actions/icons/configure.png"), + tr ("&Styles Preferences..."), SLOT (request_styles_preferences (bool))); + + _menu_bar->addMenu (editMenu); + + // view menu + + QMenu *view_menu = new QMenu (tr ("&View"), _menu_bar); + + _zoom_in_action = add_action (view_menu, QIcon (), + tr ("Zoom &In"), SLOT (zoom_in (bool))); + _zoom_out_action = add_action (view_menu, QIcon (), + tr ("Zoom &Out"), SLOT (zoom_out (bool))); + _zoom_normal_action = add_action (view_menu, QIcon (), + tr ("&Normal Size"), SLOT (zoom_normal (bool))); + + _menu_bar->addMenu (view_menu); + + // debug menu + + _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); + + _toggle_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_toggle.png"), tr ("Toggle &Breakpoint"), + SLOT (request_toggle_breakpoint (bool))); + _next_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_next.png"), tr ("&Next Breakpoint"), + SLOT (request_next_breakpoint (bool))); + _previous_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_prev.png"), tr ("Pre&vious Breakpoint"), + SLOT (request_previous_breakpoint (bool))); + _remove_all_breakpoints_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_rm_all.png"), tr ("&Remove All Breakpoints"), + SLOT (request_remove_breakpoint (bool))); + + _debug_menu->addSeparator (); + + // The other debug actions will be added by the main window. + + _menu_bar->addMenu (_debug_menu); + + // run menu + + QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); + + _run_action = add_action (_run_menu, QIcon (":/actions/icons/artsbuilderexecute.png"), + tr ("Save File and Run"), SLOT (request_run_file (bool))); + _run_selection_action = add_action (_run_menu, QIcon (), + tr ("Run &Selection"), SLOT (request_context_run (bool))); + _run_selection_action->setEnabled (false); + + _menu_bar->addMenu (_run_menu); + + // help menu + + QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); + + _context_help_action = add_action (_help_menu, QIcon (), + tr ("&Help on Keyword"), SLOT (request_context_help (bool))); + _context_doc_action = add_action (_help_menu, QIcon (), + tr ("&Documentation on Keyword"), SLOT (request_context_doc (bool))); + + _menu_bar->addMenu (_help_menu); // toolbar - _tool_bar->addAction (new_action); - _tool_bar->addAction (open_action); + + // new and open actions are inserted later from main window _tool_bar->addAction (_save_action); _tool_bar->addAction (_save_as_action); _tool_bar->addSeparator (); @@ -1175,159 +1308,10 @@ _tool_bar->addAction (_find_action); _tool_bar->addAction (_run_action); _tool_bar->addSeparator (); - _tool_bar->addAction (toggle_breakpoint_action); - _tool_bar->addAction (next_breakpoint_action); - _tool_bar->addAction (previous_breakpoint_action); - _tool_bar->addAction (remove_all_breakpoints_action); - - // menu bar - QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); - - _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), fileMenu); - for (int i = 0; i < MaxMRUFiles; ++i) - _mru_file_menu->addAction (_mru_file_actions[i]); - - fileMenu->addAction (new_action); - fileMenu->addAction (QIcon (), tr ("New &Function..."), - this, SLOT (request_new_function (bool))); - 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); - - fileMenu->addSeparator (); - _close_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("&Close"), this, SLOT (request_close_file (bool))); - _close_all_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("Close All"), - this, SLOT (request_close_all_files (bool))); - _close_others_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("Close Other Files"), - this, SLOT (request_close_other_files (bool))); - - fileMenu->addSeparator (); - fileMenu->addAction (_print_action); - - _menu_bar->addMenu (fileMenu); - - QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); - editMenu->addAction (_undo_action); - editMenu->addAction (_redo_action); - editMenu->addSeparator (); - editMenu->addAction (_copy_action); - editMenu->addAction (_cut_action); - editMenu->addAction (_paste_action); - editMenu->addSeparator (); - editMenu->addAction (_selectall_action); - editMenu->addSeparator (); - editMenu->addAction (_find_action); - editMenu->addSeparator (); - - _edit_cmd_menu = editMenu->addMenu (tr ("&Commands")); - - _delete_line_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Delete Line"), this, SLOT (request_delete_line (bool))); - _copy_line_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Copy Line"), this, SLOT (request_copy_line (bool))); - _cut_line_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Cut Line"), this, SLOT (request_cut_line (bool))); - - _edit_cmd_menu->addSeparator (); - - _delete_start_word_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Delete to Start of Word"), this, SLOT (request_delete_start_word (bool))); - _delete_end_word_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Delete to End of Word"), this, SLOT (request_delete_end_word (bool))); - _delete_start_line_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Delete to Start of Line"), this, SLOT (request_delete_start_line (bool))); - _delete_end_line_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Delete to End of Line"), this, SLOT (request_delete_end_line (bool))); - - _edit_cmd_menu->addSeparator (); - - _duplicate_selection_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Duplicate Selection/Line"), this, SLOT (request_duplicate_selection (bool))); - _transpose_line_action = _edit_cmd_menu->addAction ( - QIcon (), tr ("Transpose Line"), this, SLOT (request_transpose_line (bool))); - - _edit_fmt_menu = editMenu->addMenu (tr ("&Format")); - _upper_case_action = _edit_fmt_menu->addAction ( - QIcon (), tr ("&Uppercase Selection"), this, SLOT (request_upper_case (bool))); - _lower_case_action = _edit_fmt_menu->addAction ( - QIcon (), tr ("&Lowercase Selection"), this, SLOT (request_lower_case (bool))); - _edit_fmt_menu->addAction (_comment_selection_action); - _edit_fmt_menu->addAction (_uncomment_selection_action); - _edit_fmt_menu->addAction (_indent_selection_action); - _edit_fmt_menu->addAction (_unindent_selection_action); - - editMenu->addSeparator (); - editMenu->addAction (_completion_action); - editMenu->addSeparator (); - editMenu->addAction (_toggle_bookmark_action); - editMenu->addAction (_next_bookmark_action); - editMenu->addAction (_previous_bookmark_action); - editMenu->addAction (_remove_bookmark_action); - editMenu->addSeparator (); - editMenu->addAction (_goto_line_action); - editMenu->addSeparator (); - _preferences_action = - editMenu->addAction (QIcon (":/actions/icons/configure.png"), - tr ("&Preferences..."), - this, SLOT (request_preferences (bool))); - _styles_preferences_action = - editMenu->addAction (QIcon (":/actions/icons/configure.png"), - tr ("&Styles Preferences..."), - this, SLOT (request_styles_preferences (bool))); - _menu_bar->addMenu (editMenu); - - QMenu *view_menu = new QMenu (tr ("&View"), _menu_bar); - _zoom_in_action = view_menu->addAction (QIcon (), tr ("Zoom &In"), - this, SLOT (zoom_in (bool))); - _zoom_out_action = view_menu->addAction (QIcon (), tr ("Zoom &Out"), - this, SLOT (zoom_out (bool))); - _zoom_normal_action = view_menu->addAction (QIcon (), tr ("&Normal Size"), - this, SLOT (zoom_normal (bool))); - _menu_bar->addMenu (view_menu); - - _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); - _debug_menu->addAction (toggle_breakpoint_action); - _debug_menu->addAction (next_breakpoint_action); - _debug_menu->addAction (previous_breakpoint_action); - _debug_menu->addAction (remove_all_breakpoints_action); - _debug_menu->addSeparator (); - // The other debug actions will be added by the main window. - _menu_bar->addMenu (_debug_menu); - - QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); - _run_menu->addAction (_run_action); - _context_run_action = - _run_menu->addAction (QIcon (), tr ("Run &Selection"), - this, SLOT (request_context_run (bool))); - _context_run_action->setEnabled (false); - _menu_bar->addMenu (_run_menu); - - QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); - _context_help_action = - _help_menu->addAction (QIcon (), tr ("&Help on Keyword"), - this, SLOT (request_context_help (bool))); - _context_doc_action = - _help_menu->addAction (QIcon (), tr ("&Documentation on Keyword"), - this, SLOT (request_context_doc (bool))); - _menu_bar->addMenu (_help_menu); - - // shortcuts - set_shortcuts (true); + _tool_bar->addAction (_toggle_breakpoint_action); + _tool_bar->addAction (_next_breakpoint_action); + _tool_bar->addAction (_previous_breakpoint_action); + _tool_bar->addAction (_remove_all_breakpoints_action); // layout QVBoxLayout *vbox_layout = new QVBoxLayout (); @@ -1349,87 +1333,6 @@ connect (main_win (), SIGNAL (open_file_signal (const QString&)), this, SLOT (request_open_file (const QString&))); - connect (new_action, SIGNAL (triggered ()), - this, SLOT (request_new_file ())); - - connect (open_action, SIGNAL (triggered ()), - this, SLOT (request_open_file ())); - - connect (_undo_action, SIGNAL (triggered ()), - this, SLOT (request_undo ())); - - connect (_redo_action, SIGNAL (triggered ()), - this, SLOT (request_redo ())); - - connect (_copy_action, SIGNAL (triggered ()), - this, SLOT (request_copy ())); - - connect (_cut_action, SIGNAL (triggered ()), - this, SLOT (request_cut ())); - - connect (_paste_action, SIGNAL (triggered ()), - this, SLOT (request_paste ())); - - connect (_selectall_action, SIGNAL (triggered ()), - this, SLOT (request_selectall ())); - - connect (_save_action, SIGNAL (triggered ()), - this, SLOT (request_save_file ())); - - connect (_save_as_action, SIGNAL (triggered ()), - this, SLOT (request_save_file_as ())); - - connect (_print_action, SIGNAL (triggered ()), - this, SLOT (request_print_file ())); - - connect (_run_action, SIGNAL (triggered ()), - this, SLOT (request_run_file ())); - - connect (_toggle_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_toggle_bookmark ())); - - connect (_next_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_next_bookmark ())); - - connect (_previous_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_previous_bookmark ())); - - connect (_remove_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_remove_bookmark ())); - - connect (toggle_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_toggle_breakpoint ())); - - connect (next_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_next_breakpoint ())); - - connect (previous_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_previous_breakpoint ())); - - connect (remove_all_breakpoints_action, SIGNAL (triggered ()), - this, SLOT (request_remove_breakpoint ())); - - connect (_comment_selection_action, SIGNAL (triggered ()), - this, SLOT (request_comment_selected_text ())); - - connect (_uncomment_selection_action, SIGNAL (triggered ()), - this, SLOT (request_uncomment_selected_text ())); - - connect (_indent_selection_action, SIGNAL (triggered ()), - this, SLOT (request_indent_selected_text ())); - - connect (_unindent_selection_action, SIGNAL (triggered ()), - this, SLOT (request_unindent_selected_text ())); - - connect (_find_action, SIGNAL (triggered ()), - this, SLOT (request_find ())); - - connect (_goto_line_action, SIGNAL (triggered ()), - this, SLOT (request_goto_line ())); - - connect (_completion_action, SIGNAL (triggered ()), - this, SLOT (request_completion ())); - connect (_mru_file_menu, SIGNAL (triggered (QAction *)), this, SLOT (request_mru_open_file (QAction *))); @@ -1630,7 +1533,7 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_copy (); + request_copy (true); } } void @@ -1640,7 +1543,7 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_paste (); + request_paste (true); } } void @@ -1650,137 +1553,76 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_selectall (); + request_selectall (true); } } void -file_editor::set_shortcuts (bool set) +file_editor::set_shortcuts () { - if (set) - { - - // File menu - shortcut_manager::set_shortcut (_context_edit_action, "editor_file:edit_function"); - shortcut_manager::set_shortcut (_save_action, "editor_file:save"); - shortcut_manager::set_shortcut (_save_as_action, "editor_file:save_as"); - shortcut_manager::set_shortcut (_close_action, "editor_file:close"); - shortcut_manager::set_shortcut (_close_all_action, "editor_file:close_all"); - shortcut_manager::set_shortcut (_close_others_action, "editor_file:close_other"); - shortcut_manager::set_shortcut (_print_action, "editor_file:print"); - - // Edit menu - shortcut_manager::set_shortcut (_undo_action, "editor_edit:undo"); - shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo"); - shortcut_manager::set_shortcut (_copy_action, "editor_edit:copy"); - shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut"); - shortcut_manager::set_shortcut (_paste_action, "editor_edit:paste"); - shortcut_manager::set_shortcut (_selectall_action, "editor_edit:select_all"); - shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace"); + // File menu + shortcut_manager::set_shortcut (_edit_function_action, "editor_file:edit_function"); + shortcut_manager::set_shortcut (_save_action, "editor_file:save"); + shortcut_manager::set_shortcut (_save_as_action, "editor_file:save_as"); + shortcut_manager::set_shortcut (_close_action, "editor_file:close"); + shortcut_manager::set_shortcut (_close_all_action, "editor_file:close_all"); + shortcut_manager::set_shortcut (_close_others_action, "editor_file:close_other"); + shortcut_manager::set_shortcut (_print_action, "editor_file:print"); - 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"); - shortcut_manager::set_shortcut (_delete_start_line_action, "editor_edit:delete_start_line"); - shortcut_manager::set_shortcut (_delete_end_line_action, "editor_edit:delete_end_line"); - shortcut_manager::set_shortcut (_delete_line_action, "editor_edit:delete_line"); - shortcut_manager::set_shortcut (_copy_line_action, "editor_edit:copy_line"); - shortcut_manager::set_shortcut (_cut_line_action, "editor_edit:cut_line"); - shortcut_manager::set_shortcut (_duplicate_selection_action, "editor_edit:duplicate_selection"); - shortcut_manager::set_shortcut (_transpose_line_action, "editor_edit:transpose_line"); - shortcut_manager::set_shortcut (_comment_selection_action, "editor_edit:comment_selection"); - shortcut_manager::set_shortcut (_uncomment_selection_action, "editor_edit:uncomment_selection"); + // Edit menu + shortcut_manager::set_shortcut (_undo_action, "editor_edit:undo"); + shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo"); + shortcut_manager::set_shortcut (_copy_action, "editor_edit:copy"); + shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut"); + shortcut_manager::set_shortcut (_paste_action, "editor_edit:paste"); + shortcut_manager::set_shortcut (_selectall_action, "editor_edit:select_all"); + shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace"); - shortcut_manager::set_shortcut (_upper_case_action, "editor_edit:upper_case"); - shortcut_manager::set_shortcut (_lower_case_action, "editor_edit:lower_case"); - shortcut_manager::set_shortcut (_indent_selection_action, "editor_edit:indent_selection"); - shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection"); - shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list"); - shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark"); - shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark"); - shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark"); - shortcut_manager::set_shortcut (_remove_bookmark_action, "editor_edit:remove_bookmark"); - shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line"); - shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences"); - shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences"); - - - _context_help_action->setShortcut (QKeySequence::HelpContents); - _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1); - - _zoom_in_action->setShortcuts (QKeySequence::ZoomIn); - _zoom_out_action->setShortcuts (QKeySequence::ZoomOut); - _zoom_normal_action->setShortcut (Qt::ControlModifier + Qt::Key_Slash); - - - - _run_action->setShortcut (Qt::Key_F5); - _context_run_action->setShortcut (Qt::Key_F9); - - + 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"); + shortcut_manager::set_shortcut (_delete_start_line_action, "editor_edit:delete_start_line"); + shortcut_manager::set_shortcut (_delete_end_line_action, "editor_edit:delete_end_line"); + shortcut_manager::set_shortcut (_delete_line_action, "editor_edit:delete_line"); + shortcut_manager::set_shortcut (_copy_line_action, "editor_edit:copy_line"); + shortcut_manager::set_shortcut (_cut_line_action, "editor_edit:cut_line"); + shortcut_manager::set_shortcut (_duplicate_selection_action, "editor_edit:duplicate_selection"); + shortcut_manager::set_shortcut (_transpose_line_action, "editor_edit:transpose_line"); + shortcut_manager::set_shortcut (_comment_selection_action, "editor_edit:comment_selection"); + shortcut_manager::set_shortcut (_uncomment_selection_action, "editor_edit:uncomment_selection"); - } - else - { - QKeySequence no_key = QKeySequence (); - - // File menu - _context_edit_action->setShortcut (no_key); - _save_action->setShortcut (no_key); - _save_as_action->setShortcut (no_key); - _close_action->setShortcut (no_key); - _close_all_action->setShortcut (no_key); - _close_others_action->setShortcut (no_key); - _print_action->setShortcut (no_key); - - // Edit menu - _redo_action->setShortcut (no_key); - _undo_action->setShortcut (no_key); - _copy_action->setShortcut (no_key); - _cut_action->setShortcut (no_key); - _paste_action->setShortcut (no_key); - _selectall_action->setShortcut (no_key); - _find_action->setShortcut (no_key); + shortcut_manager::set_shortcut (_upper_case_action, "editor_edit:upper_case"); + shortcut_manager::set_shortcut (_lower_case_action, "editor_edit:lower_case"); + shortcut_manager::set_shortcut (_indent_selection_action, "editor_edit:indent_selection"); + shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection"); + shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list"); + shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line"); + shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark"); + shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark"); + shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark"); + shortcut_manager::set_shortcut (_remove_bookmark_action, "editor_edit:remove_bookmark"); + shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences"); + shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences"); - _delete_start_word_action->setShortcut (no_key); - _delete_end_word_action->setShortcut (no_key); - _delete_end_line_action->setShortcut (no_key); - _delete_start_line_action->setShortcut (no_key); - _delete_line_action->setShortcut (no_key); - _copy_line_action->setShortcut (no_key); - _cut_line_action->setShortcut (no_key); - _duplicate_selection_action->setShortcut (no_key); - _transpose_line_action->setShortcut (no_key); - _comment_selection_action->setShortcut (no_key); - _uncomment_selection_action->setShortcut (no_key); - - _upper_case_action->setShortcut (no_key); - _lower_case_action->setShortcut (no_key); - _indent_selection_action->setShortcut (no_key); - _unindent_selection_action->setShortcut (no_key); + // View menu + shortcut_manager::set_shortcut (_zoom_in_action, "edit_edit:zoom_in"); + shortcut_manager::set_shortcut (_zoom_out_action, "edit_edit:zoom_out"); + shortcut_manager::set_shortcut (_zoom_normal_action, "edit_edit:zoom_normal"); - _completion_action->setShortcut (no_key); - _toggle_bookmark_action->setShortcut (no_key); - _next_bookmark_action->setShortcut (no_key); - _previous_bookmark_action->setShortcut (no_key); - _remove_bookmark_action->setShortcut (no_key); - _goto_line_action->setShortcut (no_key); - _preferences_action->setShortcut (no_key); - _styles_preferences_action->setShortcut (no_key); - + // Debug menu + shortcut_manager::set_shortcut (_toggle_breakpoint_action, "editor_debug:toggle_breakpoint"); + shortcut_manager::set_shortcut (_next_breakpoint_action, "editor_debug:next_breakpoint"); + shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_debug:previous_breakpoint"); + shortcut_manager::set_shortcut (_remove_all_breakpoints_action, "editor_debug:remove_breakpoints"); - _context_help_action->setShortcut (no_key); - - _zoom_in_action->setShortcut (no_key); - _zoom_out_action->setShortcut (no_key); - _zoom_normal_action->setShortcut (no_key); + // Run menu + shortcut_manager::set_shortcut (_run_action, "editor_run:run_file"); + shortcut_manager::set_shortcut (_run_selection_action, "editor_run:run_selection"); - + // Help menu + shortcut_manager::set_shortcut (_context_help_action, "editor_help:help_keyword"); + shortcut_manager::set_shortcut (_context_doc_action, "editor_help:doc_keyword"); - _run_action->setShortcut (no_key); - _context_run_action->setShortcut (no_key); - - } } void @@ -1790,10 +1632,10 @@ _edit_cmd_menu->setEnabled (have_tabs); _edit_fmt_menu->setEnabled (have_tabs); + _edit_nav_menu->setEnabled (have_tabs); _comment_selection_action->setEnabled (have_tabs); _uncomment_selection_action->setEnabled (have_tabs); - _indent_selection_action->setEnabled (have_tabs); _unindent_selection_action->setEnabled (have_tabs); @@ -1806,18 +1648,10 @@ _zoom_normal_action->setEnabled (have_tabs); _find_action->setEnabled (have_tabs); - _goto_line_action->setEnabled (have_tabs); - _completion_action->setEnabled (have_tabs); - - _next_bookmark_action->setEnabled (have_tabs); - _previous_bookmark_action->setEnabled (have_tabs); - _toggle_bookmark_action->setEnabled (have_tabs); - _remove_bookmark_action->setEnabled (have_tabs); - _print_action->setEnabled (have_tabs); _run_action->setEnabled (have_tabs); - _context_edit_action->setEnabled (have_tabs); + _edit_function_action->setEnabled (have_tabs); _save_action->setEnabled (have_tabs); _save_as_action->setEnabled (have_tabs); _close_action->setEnabled (have_tabs); diff -r 8b9e99c061f9 -r 777281eeb3d4 libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h Fri Apr 18 15:04:39 2014 -0400 +++ b/libgui/src/m-editor/file-editor.h Wed Apr 23 08:42:19 2014 +0200 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,7 @@ QMenu *get_mru_menu (void) { return _mru_file_menu; } QMenu *debug_menu (void); QToolBar *toolbar (void); + void insert_new_open_actions (QAction*,QAction*,QAction*); void set_focus (void); void handle_enter_debug_mode (void); @@ -128,30 +130,30 @@ void request_close_all_files (bool); void request_close_other_files (bool); void request_mru_open_file (QAction *action); - void request_print_file (void); + void request_print_file (bool); - void request_undo (void); - void request_redo (void); - void request_copy (void); - void request_cut (void); - void request_paste (void); - void request_selectall (void); + void request_undo (bool); + void request_redo (bool); + void request_copy (bool); + void request_cut (bool); + void request_paste (bool); + void request_selectall (bool); void request_context_help (bool); void request_context_doc (bool); void request_context_edit (bool); - void request_save_file (void); - void request_save_file_as (void); - void request_run_file (void); + void request_save_file (bool); + void request_save_file_as (bool); + void request_run_file (bool); void request_context_run (bool); - void request_toggle_bookmark (void); - void request_next_bookmark (void); - void request_previous_bookmark (void); - void request_remove_bookmark (void); + void request_toggle_bookmark (bool); + void request_next_bookmark (bool); + void request_previous_bookmark (bool); + void request_remove_bookmark (bool); - void request_toggle_breakpoint (void); - void request_next_breakpoint (void); - void request_previous_breakpoint (void); - void request_remove_breakpoint (void); + void request_toggle_breakpoint (bool); + void request_next_breakpoint (bool); + void request_previous_breakpoint (bool); + void request_remove_breakpoint (bool); void request_delete_start_word (bool); void request_delete_end_word (bool); @@ -163,18 +165,18 @@ void request_duplicate_selection (bool); void request_transpose_line (bool); - void request_comment_selected_text (void); - void request_uncomment_selected_text (void); + void request_comment_selected_text (bool); + void request_uncomment_selected_text (bool); void request_upper_case (bool); void request_lower_case (bool); - void request_indent_selected_text (void); - void request_unindent_selected_text (void); + void request_indent_selected_text (bool); + void request_unindent_selected_text (bool); - void request_find (void); + void request_find (bool); - void request_goto_line (void); - void request_completion (void); + void request_goto_line (bool); + void request_completion (bool); void handle_file_name_changed (const QString& fileName, const QString& toolTip); @@ -196,8 +198,7 @@ // Tells the editor to react on changed settings. void notice_settings (const QSettings *settings); - // Tells the ditor to dis- or enable some shortcuts - void set_shortcuts (bool set_shortcuts); + void set_shortcuts (); void handle_visibility (bool visible); @@ -236,6 +237,8 @@ bool call_custom_editor (const QString& file_name = QString (), int line = -1); QWidget *find_tab_widget (const QString& openFileName) const; + QAction *add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member); std::map editor_tab_map; @@ -245,6 +248,10 @@ QToolBar *_tool_bar; QMenu *_debug_menu; + QAction *_new_action; + QAction *_new_function_action; + QAction *_open_action; + QAction *_upper_case_action; QAction *_lower_case_action; QAction *_comment_selection_action; @@ -284,9 +291,9 @@ QAction *_print_action; QAction *_run_action; - QAction *_context_run_action; + QAction *_run_selection_action; - QAction *_context_edit_action; + QAction *_edit_function_action; QAction *_save_action; QAction *_save_as_action; QAction *_close_action; @@ -299,8 +306,15 @@ QAction *_preferences_action; QAction *_styles_preferences_action; + QAction *_toggle_breakpoint_action; + QAction *_next_breakpoint_action; + QAction *_previous_breakpoint_action; + QAction *_remove_all_breakpoints_action; + QMenu *_edit_cmd_menu; QMenu *_edit_fmt_menu; + QMenu *_edit_nav_menu; + QMenu *_fileMenu; QTabWidget *_tab_widget; diff -r 8b9e99c061f9 -r 777281eeb3d4 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Fri Apr 18 15:04:39 2014 -0400 +++ b/libgui/src/main-window.cc Wed Apr 23 08:42:19 2014 +0200 @@ -1219,9 +1219,6 @@ connect (file_browser_window, SIGNAL (find_files_signal (const QString&)), this, SLOT (find_files (const QString&))); - connect (this, SIGNAL (set_widget_shortcuts_signal (bool)), - editor_window, SLOT (set_shortcuts (bool))); - connect_uiwidget_links (); setWindowTitle ("Octave"); @@ -1440,6 +1437,9 @@ tr ("Open...")); _open_action->setShortcutContext (Qt::ApplicationShortcut); + editor_window->insert_new_open_actions (_new_script_action, + _new_function_action, + _open_action); #ifdef HAVE_QSCINTILLA file_menu->addMenu (editor_window->get_mru_menu ()); @@ -2333,7 +2333,6 @@ } - emit set_widget_shortcuts_signal (set_shortcuts); } void diff -r 8b9e99c061f9 -r 777281eeb3d4 libgui/src/main-window.h --- a/libgui/src/main-window.h Fri Apr 18 15:04:39 2014 -0400 +++ b/libgui/src/main-window.h Wed Apr 23 08:42:19 2014 +0200 @@ -94,9 +94,8 @@ void pasteClipboard_signal (void); void selectAll_signal (void); - void set_widget_shortcuts_signal (bool); +public slots: -public slots: void report_status_message (const QString& statusMessage); void handle_save_workspace_request (void); void handle_load_workspace_request (const QString& file = QString ()); diff -r 8b9e99c061f9 -r 777281eeb3d4 libgui/src/shortcut-manager.cc --- a/libgui/src/shortcut-manager.cc Fri Apr 18 15:04:39 2014 -0400 +++ b/libgui/src/shortcut-manager.cc Wed Apr 23 08:42:19 2014 +0200 @@ -80,6 +80,8 @@ shortcut_manager::do_init_data () { // actions of the main window + + // file init (tr ("New File"), "main_file:new_file", QKeySequence::New ); init (tr ("New Function"), "main_file:new_function", QKeySequence ("Ctrl+Shift+N") ); init (tr ("New Figure"), "main_file:new_figure", QKeySequence () ); @@ -89,6 +91,7 @@ init (tr ("Preferences"), "main_file:preferences", QKeySequence () ); init (tr ("Exit Octave"), "main_file:exit", QKeySequence::Quit ); + // edit init (tr ("Copy"), "main_edit:copy", QKeySequence::Copy); init (tr ("Paste"), "main_edit:paste", QKeySequence::Paste); init (tr ("Undo"), "main_edit:undo", QKeySequence::Undo); @@ -100,6 +103,8 @@ init (tr ("Clear Workspace"), "main_edit:clear_workspace", QKeySequence () ); // actions of the editor + + // file init (tr ("Edit Function"), "editor_file:edit_function", QKeySequence (Qt::ControlModifier + Qt::Key_E) ); init (tr ("Save File"), "editor_file:save", QKeySequence::Save ); init (tr ("Save File As"), "editor_file:save_as", QKeySequence::SaveAs ); @@ -108,6 +113,7 @@ init (tr ("Close Other"), "editor_file:close_other", QKeySequence () ); init (tr ("Print"), "editor_file:print", QKeySequence::Print ); + // edit init (tr ("Undo"), "editor_edit:undo", QKeySequence::Undo ); init (tr ("Redo"), "editor_edit:redo", QKeySequence::Redo ); init (tr ("Copy"), "editor_edit:copy", QKeySequence::Copy ); @@ -125,6 +131,7 @@ init (tr ("Cut Line"), "editor_edit:cut_line", QKeySequence (Qt::ControlModifier + Qt::SHIFT + Qt::Key_X) ); init (tr ("Duplicate Selection/Line"), "editor_edit:duplicate_selection", QKeySequence (Qt::ControlModifier + Qt::Key_D) ); init (tr ("Transpose Line"), "editor_edit:transpose_line", QKeySequence (Qt::ControlModifier + Qt::Key_T) ); + init (tr ("Completion List"), "editor_edit:completion_list", QKeySequence (Qt::ControlModifier + Qt::Key_Space) ); init (tr ("Comment Selection"), "editor_edit:comment_selection", QKeySequence (Qt::ControlModifier + Qt::Key_R) ); init (tr ("Uncomment Selection"), "editor_edit:uncomment_selection", QKeySequence (Qt::SHIFT + Qt::ControlModifier + Qt::Key_R) ); @@ -133,14 +140,33 @@ init (tr ("Indent Selection"), "editor_edit:indent_selection", QKeySequence (Qt::ControlModifier + Qt::Key_Tab) ); init (tr ("Unindent Selection"), "editor_edit:unindent_selection", QKeySequence (Qt::SHIFT + Qt::ControlModifier + Qt::Key_Tab) ); - init (tr ("Completion List"), "editor_edit:completion_list", QKeySequence (Qt::ControlModifier + Qt::Key_Space) ); + init (tr ("Goto Line"), "editor_edit:goto_line", QKeySequence (Qt::ControlModifier+ Qt::Key_G) ); init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark", QKeySequence (Qt::Key_F7) ); init (tr ("Next Bookmark"), "editor_edit:next_bookmark", QKeySequence (Qt::Key_F2) ); init (tr ("Previous Bookmark"), "editor_edit:previous_bookmark", QKeySequence (Qt::SHIFT + Qt::Key_F2) ); init (tr ("Remove All Bookmark"), "editor_edit:remove_bookmark", QKeySequence () ); - init (tr ("Goto Line"), "editor_edit:goto_line", QKeySequence (Qt::ControlModifier+ Qt::Key_G) ); + init (tr ("Preferences"), "editor_edit:preferences", QKeySequence () ); init (tr ("Styles Preferences"), "editor_edit:styles_preferences", QKeySequence () ); + + // view + init (tr ("Zoom In"), "editor_view:zoom_in", QKeySequence::ZoomIn ); + init (tr ("Zoom Out"), "editor_view:zoom_out", QKeySequence::ZoomOut ); + init (tr ("Zoom Normal"), "editor_view:zoom_normal", QKeySequence (Qt::ControlModifier + Qt::Key_Slash) ); + + // debug + init (tr ("Toggle Breakpoint"), "editor_debug:toggle_breakpoint", QKeySequence () ); + init (tr ("Next Breakpoint"), "editor_debug:next_breakpoint", QKeySequence () ); + init (tr ("Previous Breakpoint"), "editor_debug:previous_breakpoint", QKeySequence () ); + init (tr ("Remove All Breakpoints"), "editor_debug:remove_breakpoints", QKeySequence () ); + + // run + init (tr ("Run File"), "editor_run:run_file", QKeySequence (Qt::Key_F5) ); + init (tr ("Run Selection"), "editor_run:run_selection", QKeySequence (Qt::Key_F9) ); + + // help + init (tr ("Help on Keyword"), "editor_help:help_keyword", QKeySequence::HelpContents ); + init (tr ("Document on Keyword"), "editor_help:doc_keyword", QKeySequence (Qt::SHIFT + Qt::Key_F1) ); } void