Mercurial > octave
changeset 20986:00835323fb44
prevent shortcut ambiguity between main and editor window
* file-editor-interface.h: renamed insert_new_open_actions into
insert_global_actions
* file-editor-tab.h: no more signal for setting edit shortcuts
* file-editor.cc (file_editor): initialize actions that will be copied from
main window;
(request_undo, request_copy, request_paste, request_selectall): remove
slots for obsolete own action signals;
(do_undo, copyClipboard, pasteClipboard, selectAll): and move the relevant
code into these already existing slots of the related main window actions;
(handle_tab_remove_request): make sure that the focus stays in editor window
when tabs are closed;
(edit_status_update, handle_editor_state_changed): only enable undo or copy
action if already copied from main window;
(insert_global_actions) renamed from insert_new_open_actions, insert some
global actions and copy those global actions that are en/disabled depending
on editor state;
(enable_menu_shortcuts): when editor loses focus enable copy and undo
action since these are alwys active in the main window;
(construct): edit menu is stored in a class variable, actions that are
copied from the main menu are not added to the menus here;
(set_shortcuts): no shortcuts for the actions from the main menu;
(check_actions): do not disable paste-/select-all-action when no tab is open;
* file-editor.h: renamed insert_new_open_actions into insert_global_actions,
no more slots for the action that are now copied from the main window,
* octave-qscintilla.cc (octave_qscintilla): initialize undo and redo state
for editor actions;
(focusInEvent): emit undo and redo state for the editor actions;
* octave-qscintilla.h: focusInEvent
* main-window.cc (notice_settings): use renamed function for switching
menu_bar accelerators between main window and editor;
(construct): removed list and signal for adding common action to the dock
widgets, since these action are globally valid;
(construct_menu_bar): call function for inserting some action to the editor
here and not in construct_file_menu;
(disable_menu_shortcuts) renamed from enable_menu_shortcuts;
(construct_edit_menu): global edit actions with ApplicationShortcut context;
(set_global_edit_shortcuts): removed obsolete function since global edit
actions now only exist once
* main-window.h: removed obsolete function set_global_edit_shortcuts,
renamed function enable_menu_shortcuts into disable_menu_shortcuts,
* octave-dock-widget.cc (octave_dock_widget, add_actions): removed
obsolete slot for adding actions from the main window
* octave-dock-widget.h: removed slots add_actions
* shortcut-manager.cc (do_init_data): remove shortcuts for obsolete editor
actions which are now copied from the main window;
(init): do not store widget name in the shortcut hash since duplicate
shortcuts in different widgets are not possible anymore;
(do_fill_treewidget): adapt check for duplicate shortcuts accordingly;
(shortcut_dialog_finish): changes related to changed shortcut hash
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 25 Dec 2015 22:31:23 +0100 |
parents | 8a43428e13b2 |
children | f99cbd86a0f9 |
files | libgui/src/m-editor/file-editor-interface.h libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/m-editor/octave-qscintilla.cc libgui/src/m-editor/octave-qscintilla.h libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-dock-widget.cc libgui/src/octave-dock-widget.h libgui/src/shortcut-manager.cc |
diffstat | 11 files changed, 143 insertions(+), 177 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-interface.h Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/m-editor/file-editor-interface.h Fri Dec 25 22:31:23 2015 +0100 @@ -44,7 +44,8 @@ virtual QMenu *debug_menu () = 0; virtual QToolBar *toolbar () = 0; - virtual void insert_new_open_actions (QAction*,QAction*,QAction*) = 0; + virtual void insert_global_actions (QAction*,QAction*,QAction*,QAction*, + QAction*,QAction*,QAction*) = 0; virtual void handle_enter_debug_mode (void) = 0; virtual void handle_exit_debug_mode (void) = 0;
--- a/libgui/src/m-editor/file-editor-tab.h Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/m-editor/file-editor-tab.h Fri Dec 25 22:31:23 2015 +0100 @@ -140,7 +140,6 @@ void editor_check_conflict_save (const QString& saveFileName, bool remove_on_success); void run_file_signal (const QFileInfo& info); - void set_global_edit_shortcuts_signal (bool); void request_open_file (const QString&); protected:
--- a/libgui/src/m-editor/file-editor.cc Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/m-editor/file-editor.cc Fri Dec 25 22:31:23 2015 +0100 @@ -54,6 +54,13 @@ // files will change ced accordingly. ced = QDir::currentPath (); + // set action that are later added by the main window to null, + // preventing access to them when they are still undefined + _undo_action = 0; + _copy_action = 0; + _paste_action = 0; + _selectall_action = 0; + construct (); setVisible (false); @@ -662,10 +669,11 @@ } void -file_editor::request_undo (bool) +file_editor::do_undo () { - emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciScintillaBase::SCI_UNDO); + if (editor_tab_has_focus ()) + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_UNDO); } void @@ -676,10 +684,11 @@ } void -file_editor::request_copy (bool) +file_editor::copyClipboard () { - emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciScintillaBase::SCI_COPY); + if (editor_tab_has_focus ()) + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_COPY); } void @@ -690,17 +699,19 @@ } void -file_editor::request_paste (bool) +file_editor::pasteClipboard () { - emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciScintillaBase::SCI_PASTE); + if (editor_tab_has_focus ()) + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_PASTE); } void -file_editor::request_selectall (bool) +file_editor::selectAll () { - emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciScintillaBase::SCI_SELECTALL); + if (editor_tab_has_focus ()) + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_SELECTALL); } void @@ -1080,6 +1091,8 @@ } } check_actions (); + + focus (); // focus stays in editor when tab is closed } void @@ -1176,7 +1189,8 @@ void file_editor::edit_status_update (bool undo, bool redo) { - _undo_action->setEnabled (undo); + if (_undo_action) + _undo_action->setEnabled (undo); _redo_action->setEnabled (redo); } @@ -1188,7 +1202,8 @@ // all the file editor tabs, just process info from the current active tab. if (sender () == _tab_widget->currentWidget ()) { - _copy_action->setEnabled (copy_available); + if (_copy_action) + _copy_action->setEnabled (copy_available); _cut_action->setEnabled (copy_available); _run_selection_action->setEnabled (copy_available); _run_action->setEnabled (is_octave_file); @@ -1259,16 +1274,45 @@ emit request_settings_dialog ("editor_styles"); } +// insert global actions, that should also be displayed in the editor window, +// into the editor's menu and/or toolbar void -file_editor::insert_new_open_actions (QAction *new_action, - QAction *new_fcn_action, - QAction *open_action) +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) { + // actions/menus that have to be added to the toolbar or the menu _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 (_popdown_mru_action, open_action); _tool_bar->insertAction (open_action, new_action); + + // actions that are additionally enabled/disabled later by the editor + // undo + _undo_action = 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; + _tool_bar->insertAction (_cut_action,_copy_action); + _edit_menu->insertAction (_cut_action,_copy_action); + _copy_action->setEnabled (false); + // select all + _selectall_action = selectall_action; + _edit_menu->insertAction (_find_action,_selectall_action); + _edit_menu->insertSeparator (_find_action); + // paste + _paste_action = 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); } QAction* @@ -1291,16 +1335,26 @@ return a; } +// function enabling/disabling the menu accelerators depending on the +// focus of the editor void file_editor::enable_menu_shortcuts (bool enable) { QHash<QMenu*, QStringList>::const_iterator i = _hash_menu_text.constBegin(); - while (i != _hash_menu_text.constEnd()) - { - i.key ()->setTitle (i.value ().at (! enable)); - ++i; - } + while (i != _hash_menu_text.constEnd()) + { + i.key ()->setTitle (i.value ().at (! enable)); + ++i; + } + + // when editor loses focus, enable the actions, which are always active + // in the main window due to missing info on selected text and undo actions + if (! enable && _copy_action && _undo_action) + { + _copy_action->setEnabled (true); + _undo_action->setEnabled (true); + } } QMenu* @@ -1399,41 +1453,26 @@ _print_action = add_action (_fileMenu, resource_manager::icon ("document-print"), tr ("Print..."), SLOT (request_print_file (bool))); - // edit menu - - QMenu *editMenu = m_add_menu (_menu_bar, tr ("&Edit")); + // edit menu (undo, copy, paste and select all later via main window) - _undo_action = add_action (editMenu, resource_manager::icon ("edit-undo"), - tr ("&Undo"), SLOT (request_undo (bool))); - _undo_action->setEnabled (false); - _redo_action = add_action (editMenu, resource_manager::icon ("edit-redo"), + _edit_menu = m_add_menu (_menu_bar, tr ("&Edit")); + + _redo_action = add_action (_edit_menu, resource_manager::icon ("edit-redo"), tr ("&Redo"), SLOT (request_redo (bool))); _redo_action->setEnabled (false); - editMenu->addSeparator (); + _edit_menu->addSeparator (); - _copy_action = add_action (editMenu, resource_manager::icon ("edit-copy"), - tr ("&Copy"), SLOT (request_copy (bool))); - _copy_action->setEnabled (false); - _cut_action = add_action (editMenu, resource_manager::icon ("edit-cut"), + _cut_action = add_action (_edit_menu, resource_manager::icon ("edit-cut"), tr ("Cu&t"), SLOT (request_cut (bool))); _cut_action->setEnabled (false); - _paste_action = add_action (editMenu, resource_manager::icon ("edit-paste"), - 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, resource_manager::icon ("edit-find-replace"), + _find_action = add_action (_edit_menu, resource_manager::icon ("edit-find-replace"), tr ("&Find and Replace..."), SLOT (request_find (bool))); - editMenu->addSeparator (); + _edit_menu->addSeparator (); - _edit_cmd_menu = editMenu->addMenu (tr ("&Commands")); + _edit_cmd_menu = _edit_menu->addMenu (tr ("&Commands")); _delete_line_action = add_action (_edit_cmd_menu, QIcon (), tr ("Delete Line"), SLOT (request_delete_line (bool))); @@ -1465,7 +1504,7 @@ _completion_action = add_action (_edit_cmd_menu, QIcon (), tr ("&Show Completion List"), SLOT (request_completion (bool))); - _edit_fmt_menu = editMenu->addMenu (tr ("&Format")); + _edit_fmt_menu = _edit_menu->addMenu (tr ("&Format")); _upper_case_action = add_action (_edit_fmt_menu, QIcon (), tr ("&Uppercase Selection"), SLOT (request_upper_case (bool))); @@ -1498,7 +1537,7 @@ tr ("Convert Line Endings to &Mac (CR)"), SLOT (request_conv_eol_mac (bool))); - _edit_nav_menu = editMenu->addMenu (tr ("Navi&gation")); + _edit_nav_menu = _edit_menu->addMenu (tr ("Navi&gation")); _goto_line_action = add_action (_edit_nav_menu, QIcon (), tr ("Go &to Line..."), SLOT (request_goto_line (bool))); @@ -1521,11 +1560,11 @@ _remove_bookmark_action = add_action (_edit_nav_menu, QIcon (), tr ("&Remove All Bookmarks"), SLOT (request_remove_bookmark (bool))); - editMenu->addSeparator (); + _edit_menu->addSeparator (); - _preferences_action = add_action (editMenu, resource_manager::icon ("preferences-system"), + _preferences_action = add_action (_edit_menu, resource_manager::icon ("preferences-system"), tr ("&Preferences..."), SLOT (request_preferences (bool))); - _styles_preferences_action = add_action (editMenu, resource_manager::icon ("preferences-system"), + _styles_preferences_action = add_action (_edit_menu, resource_manager::icon ("preferences-system"), tr ("&Styles Preferences..."), SLOT (request_styles_preferences (bool))); // view menu @@ -1629,16 +1668,15 @@ _popdown_mru_action = _tool_bar->addWidget (popdown_button); _tool_bar->addAction (_save_action); _tool_bar->addAction (_save_as_action); - _tool_bar->addSeparator (); _tool_bar->addAction (_print_action); _tool_bar->addSeparator (); - _tool_bar->addAction (_undo_action); + // _undo_action: later via main window _tool_bar->addAction (_redo_action); - _tool_bar->addAction (_copy_action); + // _copy_action: later via the main window _tool_bar->addAction (_cut_action); - _tool_bar->addAction (_paste_action); + // _paste_action: later via the main window + _tool_bar->addAction (_find_action); _tool_bar->addSeparator (); - _tool_bar->addAction (_find_action); _tool_bar->addAction (_run_action); _tool_bar->addSeparator (); _tool_bar->addAction (_toggle_breakpoint_action); @@ -1778,9 +1816,6 @@ connect (f, SIGNAL (request_open_file (const QString&)), this, SLOT (request_open_file (const QString&))); - connect (f, SIGNAL (set_global_edit_shortcuts_signal (bool)), - main_win (), SLOT (set_global_edit_shortcuts (bool))); - // Signals from the file_editor non-trivial operations connect (this, SIGNAL (fetab_settings_changed (const QSettings *)), f, SLOT (notice_settings (const QSettings *))); @@ -1912,34 +1947,11 @@ } void -file_editor::copyClipboard () -{ - if (editor_tab_has_focus ()) - request_copy (true); -} -void -file_editor::pasteClipboard () -{ - if (editor_tab_has_focus ()) - request_paste (true); -} -void -file_editor::selectAll () -{ - if (editor_tab_has_focus ()) - request_selectall (true); -} - -void -file_editor::do_undo () -{ - if (editor_tab_has_focus ()) - request_undo (true); -} - -void file_editor::set_shortcuts () { + // Shortcuts also available in the main window, as well as the realted + // ahotcuts, are defined in main_window and added to the editor + // File menu shortcut_manager::set_shortcut (_edit_function_action, "editor_file:edit_function"); shortcut_manager::set_shortcut (_save_action, "editor_file:save"); @@ -1950,12 +1962,8 @@ 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"); shortcut_manager::set_shortcut (_delete_start_word_action, "editor_edit:delete_start_word"); @@ -2035,7 +2043,6 @@ _indent_selection_action->setEnabled (have_tabs); _unindent_selection_action->setEnabled (have_tabs); - _paste_action->setEnabled (have_tabs); _context_help_action->setEnabled (have_tabs); _context_doc_action->setEnabled (have_tabs); @@ -2054,8 +2061,6 @@ _close_action->setEnabled (have_tabs); _close_all_action->setEnabled (have_tabs); _close_others_action->setEnabled (have_tabs && _tab_widget->count () > 1); - - _selectall_action->setEnabled (have_tabs); } // empty_script determines whether we have to create an empty script
--- a/libgui/src/m-editor/file-editor.h Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/m-editor/file-editor.h Fri Dec 25 22:31:23 2015 +0100 @@ -85,7 +85,8 @@ 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 insert_global_actions (QAction*, QAction*, QAction*, QAction*, + QAction*, QAction*, QAction*); void handle_enter_debug_mode (void); void handle_exit_debug_mode (void); @@ -161,12 +162,8 @@ void request_mru_open_file (QAction *action); void request_print_file (bool); - 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); @@ -391,6 +388,7 @@ QAction *_previous_breakpoint_action; QAction *_remove_all_breakpoints_action; + QMenu *_edit_menu; QMenu *_edit_cmd_menu; QMenu *_edit_fmt_menu; QMenu *_edit_nav_menu;
--- a/libgui/src/m-editor/octave-qscintilla.cc Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/m-editor/octave-qscintilla.cc Fri Dec 25 22:31:23 2015 +0100 @@ -129,6 +129,9 @@ cmd_list_mac.at (i)->setAlternateKey (key); } #endif + + // init state of undo/redo action for this tab + emit status_update (isUndoAvailable (), isRedoAvailable ()); } octave_qscintilla::~octave_qscintilla () @@ -282,4 +285,12 @@ emit status_update (isUndoAvailable (), isRedoAvailable ()); } +// when edit area gets focus update information on undo/redo actions +void octave_qscintilla::focusInEvent(QFocusEvent *focusEvent) +{ + emit status_update (isUndoAvailable (), isRedoAvailable ()); + + QsciScintilla::focusInEvent(focusEvent); +} + #endif
--- a/libgui/src/m-editor/octave-qscintilla.h Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/m-editor/octave-qscintilla.h Fri Dec 25 22:31:23 2015 +0100 @@ -67,6 +67,8 @@ protected: + void focusInEvent(QFocusEvent *focusEvent); + private: QString _word_at_cursor;
--- a/libgui/src/main-window.cc Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/main-window.cc Fri Dec 25 22:31:23 2015 +0100 @@ -785,7 +785,7 @@ configure_shortcuts (); set_global_shortcuts (_active_dock == command_window); - set_global_edit_shortcuts (_active_dock == editor_window); + disable_menu_shortcuts (_active_dock == editor_window); } void @@ -1365,7 +1365,7 @@ this, SLOT (notice_settings (const QSettings *))); connect (this, SIGNAL (editor_focus_changed (bool)), - this, SLOT (set_global_edit_shortcuts (bool))); + this, SLOT (disable_menu_shortcuts (bool))); connect (this, SIGNAL (editor_focus_changed (bool)), editor_window, SLOT (enable_menu_shortcuts (bool))); @@ -1430,15 +1430,6 @@ octave_link::post_event (this, &main_window::resize_command_window_callback); configure_shortcuts (); - - // actions that should be available in floating dock widgets, too - QList<QAction *> action_list; - action_list.append (_copy_action); - action_list.append (_paste_action); - action_list.append (_select_all_action); - action_list.append (_undo_action); - emit add_actions_signal (action_list); // signal for adding these actions - } } @@ -1613,6 +1604,16 @@ construct_help_menu (menu_bar); 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); +#endif } QAction* @@ -1632,13 +1633,13 @@ } void -main_window::enable_menu_shortcuts (bool enable) +main_window::disable_menu_shortcuts (bool disable) { QHash<QMenu*, QStringList>::const_iterator i = _hash_menu_text.constBegin(); while (i != _hash_menu_text.constEnd()) { - i.key ()->setTitle (i.value ().at (! enable)); + i.key ()->setTitle (i.value ().at (disable)); ++i; } } @@ -1676,10 +1677,6 @@ _open_action->setToolTip (tr ("Open an existing file in editor")); #ifdef HAVE_QSCINTILLA - editor_window->insert_new_open_actions (_new_script_action, - _new_function_action, - _open_action); - file_menu->addMenu (editor_window->get_mru_menu ()); #endif @@ -1749,19 +1746,23 @@ _undo_action = edit_menu->addAction (resource_manager::icon ("edit-undo"), tr ("Undo")); + _undo_action->setShortcutContext (Qt::ApplicationShortcut); edit_menu->addSeparator (); _copy_action = edit_menu->addAction (resource_manager::icon ("edit-copy"), tr ("Copy"), this, SLOT (copyClipboard ())); + _copy_action->setShortcutContext (Qt::ApplicationShortcut); _paste_action = edit_menu->addAction (resource_manager::icon ("edit-paste"), tr ("Paste"), this, SLOT (pasteClipboard ())); + _paste_action->setShortcutContext (Qt::ApplicationShortcut); _select_all_action = edit_menu->addAction (tr ("Select All"), this, SLOT (selectAll ())); + _select_all_action->setShortcutContext (Qt::ApplicationShortcut); _clear_clipboard_action = edit_menu->addAction (tr ("Clear Clipboard"), this, @@ -2251,32 +2252,6 @@ } void -main_window::set_global_edit_shortcuts (bool editor_has_focus) -{ - // this slot is called when editor gets/loses focus - if (editor_has_focus) - { - // disable shortcuts that are also provided by the editor itself - QKeySequence no_key = QKeySequence (); - _copy_action->setShortcut (no_key); - _paste_action->setShortcut (no_key); - _undo_action->setShortcut (no_key); - _select_all_action->setShortcut (no_key); - } - else - { - // editor loses focus, set the global shortcuts - shortcut_manager::set_shortcut (_copy_action, "main_edit:copy"); - shortcut_manager::set_shortcut (_paste_action, "main_edit:paste"); - shortcut_manager::set_shortcut (_undo_action, "main_edit:undo"); - shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all"); - } - - // dis-/enable global menu depending on editor's focus - enable_menu_shortcuts (! editor_has_focus); -} - -void main_window::configure_shortcuts () { // file menu
--- a/libgui/src/main-window.h Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/main-window.h Fri Dec 25 22:31:23 2015 +0100 @@ -212,7 +212,6 @@ // setting global shortcuts void set_global_shortcuts (bool enable); - void set_global_edit_shortcuts (bool enable); void set_screen_size (int ht, int wd); @@ -224,6 +223,9 @@ QList<octave_dock_widget *> get_dock_widget_list () { return dock_widget_list (); } +private slots: + void disable_menu_shortcuts (bool disable); + protected: void closeEvent (QCloseEvent * closeEvent); @@ -236,7 +238,6 @@ QAction *add_action (QMenu *menu, const QIcon &icon, const QString &text, const char *member, const QWidget *receiver = 0); - void enable_menu_shortcuts (bool enable); QMenu* m_add_menu (QMenuBar *p, QString text); void construct_menu_bar (void); void construct_file_menu (QMenuBar *p);
--- a/libgui/src/octave-dock-widget.cc Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/octave-dock-widget.cc Fri Dec 25 22:31:23 2015 +0100 @@ -109,9 +109,6 @@ #endif - // adding actions of the main window - connect (p, SIGNAL (add_actions_signal (QList<QAction *>)), - this, SLOT (add_actions (QList<QAction *>))); // copy & paste handling connect (p, SIGNAL (copyClipboard_signal ()), this, SLOT (copyClipboard ())); @@ -486,14 +483,6 @@ } } -// slot for adding actions from the main window -void -octave_dock_widget::add_actions (QList<QAction *> action_list) -{ - if (objectName () != "FileEditor") - addActions (action_list); -} - // close event void octave_dock_widget::closeEvent (QCloseEvent *e)
--- a/libgui/src/octave-dock-widget.h Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/octave-dock-widget.h Fri Dec 25 22:31:23 2015 +0100 @@ -102,8 +102,6 @@ // event filter for double clicks into the window decoration elements bool eventFilter(QObject *obj, QEvent *e); - virtual void add_actions (QList<QAction *> action_list); - private slots: void change_floating (bool);
--- a/libgui/src/shortcut-manager.cc Fri Dec 25 20:07:28 2015 +0100 +++ b/libgui/src/shortcut-manager.cc Fri Dec 25 22:31:23 2015 +0100 @@ -199,12 +199,8 @@ 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); init (tr ("Cut"), "editor_edit:cut", QKeySequence::Cut); - init (tr ("Paste"), "editor_edit:paste", QKeySequence::Paste); - init (tr ("Select All"), "editor_edit:select_all", QKeySequence::SelectAll); init (tr ("Find and Replace"), "editor_edit:find_replace", QKeySequence::Find); init (tr ("Delete to Start of Word"), "editor_edit:delete_start_word", @@ -343,11 +339,10 @@ shortcut_info.default_sc = def_sc; _sc << shortcut_info; - // insert shortcut prepended by widget in order check for duplicates later - QString widget = key.section ('_',0,0); // get widget that uses the shortcut + // insert shortcut in order check for duplicates later if (! actual.isEmpty ()) - _shortcut_hash[widget + ":" + actual.toString ()] = _sc.count (); // offset of 1 to avoid 0 - _action_hash[key] = _sc.count (); // offset of 1 to avoid 0 + _shortcut_hash[actual.toString ()] = _sc.count (); + _action_hash[key] = _sc.count (); } void @@ -359,7 +354,7 @@ tree_view->header ()->setResizeMode (QHeaderView::ResizeToContents); QTreeWidgetItem *main = new QTreeWidgetItem (tree_view); - main->setText (0, tr ("Main")); + main->setText (0, tr ("Global")); main->setExpanded (true); QTreeWidgetItem *main_file = new QTreeWidgetItem (main); main_file->setText (0, tr ("File")); @@ -556,13 +551,7 @@ return; // check for duplicate - - // get the widget for which this shortcut is defined - QString widget = _sc.at (_handled_index).settings_key.section ('_',0,0); - // and look for shortcut - QString sep = ":"; - - int double_index = _shortcut_hash[widget + sep + _edit_actual->text()] - 1; + int double_index = _shortcut_hash[_edit_actual->text()] - 1; if (double_index >= 0 && double_index != _handled_index) { @@ -588,16 +577,14 @@ shortcut_t shortcut = _sc.at (_handled_index); if (! shortcut.actual_sc.isEmpty ()) - _shortcut_hash.remove (widget + sep + - shortcut.actual_sc.toString ()); + _shortcut_hash.remove (shortcut.actual_sc.toString ()); shortcut.actual_sc = _edit_actual->text(); _sc.replace (_handled_index, shortcut); _index_item_hash[_handled_index]->setText (2, shortcut.actual_sc); if (! shortcut.actual_sc.isEmpty ()) - _shortcut_hash[widget + sep + shortcut.actual_sc.toString ()] = - _handled_index + 1; + _shortcut_hash[shortcut.actual_sc.toString ()] = _handled_index + 1; } void