# HG changeset patch # User Torsten # Date 1451159168 -3600 # Node ID 98e75f952a36125a5a8e583e7d6ccb1eefff1ce2 # Parent 8b8d8c6c0e64e81c36d828039b8a05a44e89a242 add find files action also to the editor menu * file-editor-interface.h: new declaration of insert_global_actions * file-editor.cc (insert_global_actions): now using a QList for global actions that are also added tot editor menu or tool bar * file-editor.h: new declaration of insert_global_actions using a list of pointers to the global actions together with an enum for the indexes, new action for finding files * main-window.cc (construct_menu_bar): use new function insert_global_actions with a list of functions to be added to the editor diff -r 8b8d8c6c0e64 -r 98e75f952a36 libgui/src/m-editor/file-editor-interface.h --- a/libgui/src/m-editor/file-editor-interface.h Sat Dec 26 07:58:08 2015 -0800 +++ b/libgui/src/m-editor/file-editor-interface.h Sat Dec 26 20:46:08 2015 +0100 @@ -44,8 +44,7 @@ virtual QMenu *debug_menu () = 0; virtual QToolBar *toolbar () = 0; - virtual void insert_global_actions (QAction*,QAction*,QAction*,QAction*, - QAction*,QAction*,QAction*) = 0; + virtual void insert_global_actions (QList) = 0; virtual void handle_enter_debug_mode (void) = 0; virtual void handle_exit_debug_mode (void) = 0; diff -r 8b8d8c6c0e64 -r 98e75f952a36 libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Sat Dec 26 07:58:08 2015 -0800 +++ b/libgui/src/m-editor/file-editor.cc Sat Dec 26 20:46:08 2015 +0100 @@ -1277,15 +1277,12 @@ // insert global actions, that should also be displayed in the editor window, // into the editor's menu and/or toolbar void -file_editor::insert_global_actions (QAction *new_action, - QAction *new_fcn_action, - QAction *open_action, - QAction *undo_action, - QAction *copy_action, - QAction *paste_action, - QAction *selectall_action) +file_editor::insert_global_actions (QList shared_actions) { // actions/menus that have to be added to the toolbar or the menu + QAction *open_action = shared_actions.at (OPEN_ACTION); + QAction *new_action = shared_actions.at (NEW_SCRIPT_ACTION); + QAction *new_fcn_action = shared_actions.at (NEW_FUNCTION_ACTION); _fileMenu->insertAction (_mru_file_menu->menuAction (), open_action); _fileMenu->insertAction (open_action, new_fcn_action); _fileMenu->insertAction (new_fcn_action, new_action); @@ -1294,25 +1291,28 @@ // actions that are additionally enabled/disabled later by the editor // undo - _undo_action = undo_action; + _undo_action = shared_actions.at (UNDO_ACTION); _tool_bar->insertAction (_redo_action,_undo_action); _edit_menu->insertAction (_redo_action,_undo_action); _undo_action->setEnabled (false); // copy - _copy_action = copy_action; + _copy_action = shared_actions.at (COPY_ACTION); _tool_bar->insertAction (_cut_action,_copy_action); _edit_menu->insertAction (_cut_action,_copy_action); _copy_action->setEnabled (false); // select all - _selectall_action = selectall_action; + _selectall_action = shared_actions.at (SELECTALL_ACTION); _edit_menu->insertAction (_find_action,_selectall_action); _edit_menu->insertSeparator (_find_action); // paste - _paste_action = paste_action; + _paste_action = shared_actions.at (PASTE_ACTION); _tool_bar->insertAction (_find_action,_paste_action); _edit_menu->insertAction (_selectall_action,_paste_action); _edit_menu->insertSeparator (_selectall_action); _paste_action->setEnabled (false); + // find files + _find_files_action = shared_actions.at (FIND_FILES_ACTION); + _edit_menu->insertAction (_find_action, _find_files_action); } QAction* diff -r 8b8d8c6c0e64 -r 98e75f952a36 libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h Sat Dec 26 07:58:08 2015 -0800 +++ b/libgui/src/m-editor/file-editor.h Sat Dec 26 20:46:08 2015 +0100 @@ -85,8 +85,19 @@ QMenu *get_mru_menu (void) { return _mru_file_menu; } QMenu *debug_menu (void); QToolBar *toolbar (void); - void insert_global_actions (QAction*, QAction*, QAction*, QAction*, - QAction*, QAction*, QAction*); + + void insert_global_actions (QList); + enum shared_actions_idx + { + NEW_SCRIPT_ACTION = 0, + NEW_FUNCTION_ACTION, + OPEN_ACTION, + FIND_FILES_ACTION, + UNDO_ACTION, + COPY_ACTION, + PASTE_ACTION, + SELECTALL_ACTION + }; void handle_enter_debug_mode (void); void handle_exit_debug_mode (void); @@ -350,6 +361,7 @@ QAction *_transpose_line_action; QAction *_find_action; + QAction *_find_files_action; QAction *_goto_line_action; QAction *_completion_action; diff -r 8b8d8c6c0e64 -r 98e75f952a36 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Sat Dec 26 07:58:08 2015 -0800 +++ b/libgui/src/main-window.cc Sat Dec 26 20:46:08 2015 +0100 @@ -1606,16 +1606,22 @@ construct_news_menu (menu_bar); #ifdef HAVE_QSCINTILLA - editor_window->insert_global_actions (_new_script_action, - _new_function_action, - _open_action, - _undo_action, - _copy_action, - _paste_action, - _select_all_action); + // call the editor to add actions which should also be available in the + // editor's menu and tool bar + QList shared_actions; + shared_actions << _new_script_action + << _new_function_action + << _open_action + << _find_files_action + << _undo_action + << _copy_action + << _paste_action + <<_select_all_action; + editor_window->insert_global_actions (shared_actions); #endif } + QAction* main_window::add_action (QMenu *menu, const QIcon &icon, const QString &text, const char *member, const QWidget *receiver)