# HG changeset patch # User Torsten Lilge # Date 1605898949 -3600 # Node ID 2a70a068c4aba4c6514f4b086f62443059d76436 # Parent 95ec5841c9d6f52ce28c167a7d501078a4123965 add option for using alt-modifer in command windows readline (bug #59478) * gui-preferences-sc.h: key and default value for new pref for disabling menu accelerators when command window has focus * main-window.cc (main_window): initial new boolean class variable storing the pref for disabling the menu accelerators; (focus_changed): check for editor and command window getting or losing focus and en-/disable menu accelerators accordingly; (notice_settings): get new preference, disable menu accelerators if desired and if command window has focus (construct): remove connection of editor focus changed signal with the slot in main window since the related slot is now directly called from focus_changed if required * main-window.h: new class variable m_prevent_readline_conflicts_menu * settings-dialog.cc (settings_dialog) read new pref and initialize the related check box; (write_changed_settings): store state of the check box in pref file * settings-dialog.ui: added check box for new preference diff -r 95ec5841c9d6 -r 2a70a068c4ab libgui/src/gui-preferences-sc.h --- a/libgui/src/gui-preferences-sc.h Fri Nov 20 18:22:56 2020 +0100 +++ b/libgui/src/gui-preferences-sc.h Fri Nov 20 20:02:29 2020 +0100 @@ -264,5 +264,7 @@ const gui_pref sc_prevent_rl_conflicts ("shortcuts/prevent_readline_conflicts", QVariant (true)); +const gui_pref +sc_prevent_rl_conflicts_menu ("shortcuts/prevent_readline_conflicts_menu", QVariant (false)); #endif diff -r 95ec5841c9d6 -r 2a70a068c4ab libgui/src/main-window.cc --- a/libgui/src/main-window.cc Fri Nov 20 18:22:56 2020 +0100 +++ b/libgui/src/main-window.cc Fri Nov 20 20:02:29 2020 +0100 @@ -119,7 +119,9 @@ m_find_files_dlg (nullptr), m_set_path_dlg (nullptr), m_release_notes_window (nullptr), m_community_news_window (nullptr), m_clipboard (QApplication::clipboard ()), - m_prevent_readline_conflicts (true), m_suppress_dbg_location (true), + m_prevent_readline_conflicts (true), + m_prevent_readline_conflicts_menu (false), + m_suppress_dbg_location (true), m_closing (false), m_file_encoding (QString ()) { resource_manager& rmgr = m_octave_qobj.get_resource_manager (); @@ -352,9 +354,12 @@ count++; // Limited number of trials } - // editor needs extra handling + // editor and terminal needs extra handling octave_dock_widget *edit_dock_widget = static_cast (m_editor_window); + octave_dock_widget *cmd_dock_widget + = static_cast (m_command_window); + // if new dock has focus, emit signal and store active focus // except editor changes to a dialog (dock=0) if ((dock || m_active_dock != edit_dock_widget) && (dock != m_active_dock)) @@ -369,10 +374,37 @@ dock->set_predecessor_widget (m_active_dock); } + int editor = 0; if (edit_dock_widget == dock) - emit editor_focus_changed (true); + { + emit editor_focus_changed (true); + editor = 1; + } else if (edit_dock_widget == m_active_dock) - emit editor_focus_changed (false); + { + emit editor_focus_changed (false); + editor = -1; + } + + int command = 0; + if (m_prevent_readline_conflicts_menu) + { + if (cmd_dock_widget == dock) + command = 1; + else if (cmd_dock_widget == m_active_dock) + command = -1; + } + + // If editor or command gets/looses focus, disable/enable + // main menu accelerators + if (editor || command) + { + int sum = editor + command; + if (sum > 0) + disable_menu_shortcuts (true); + else if (sum < 0) + disable_menu_shortcuts (false); + } if (m_active_dock) m_previous_dock = m_active_dock; @@ -916,6 +948,10 @@ = settings->value (sc_prevent_rl_conflicts.key, sc_prevent_rl_conflicts.def).toBool (); + m_prevent_readline_conflicts_menu + = settings->value (sc_prevent_rl_conflicts_menu.key, + sc_prevent_rl_conflicts_menu.def).toBool (); + m_suppress_dbg_location = ! settings->value (cs_dbg_location).toBool (); @@ -926,7 +962,13 @@ configure_shortcuts (); set_global_shortcuts (m_active_dock == m_command_window); - disable_menu_shortcuts (m_active_dock == m_editor_window); + + bool do_disable_main_menu_shortcuts + = (m_active_dock == m_editor_window) + || (m_prevent_readline_conflicts_menu + && (m_active_dock == m_command_window)); + + disable_menu_shortcuts (do_disable_main_menu_shortcuts); // Check whether some octave internal preferences have to be updated QString new_default_encoding @@ -2103,9 +2145,6 @@ this, SLOT (notice_settings (const gui_settings *))); connect (this, SIGNAL (editor_focus_changed (bool)), - this, SLOT (disable_menu_shortcuts (bool))); - - connect (this, SIGNAL (editor_focus_changed (bool)), m_editor_window, SLOT (enable_menu_shortcuts (bool))); connect (this, SIGNAL (step_into_file_signal (void)), diff -r 95ec5841c9d6 -r 2a70a068c4ab libgui/src/main-window.h --- a/libgui/src/main-window.h Fri Nov 20 18:22:56 2020 +0100 +++ b/libgui/src/main-window.h Fri Nov 20 20:02:29 2020 +0100 @@ -434,6 +434,7 @@ //! Some class global flags. //!@{ bool m_prevent_readline_conflicts; + bool m_prevent_readline_conflicts_menu; bool m_suppress_dbg_location; bool m_editor_has_tabs; diff -r 95ec5841c9d6 -r 2a70a068c4ab libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Fri Nov 20 18:22:56 2020 +0100 +++ b/libgui/src/settings-dialog.cc Fri Nov 20 20:02:29 2020 +0100 @@ -458,6 +458,9 @@ cb_prevent_readline_conflicts->setChecked ( settings->value (sc_prevent_rl_conflicts.key, sc_prevent_rl_conflicts.def).toBool ()); + cb_prevent_readline_conflicts_menu->setChecked ( + settings->value (sc_prevent_rl_conflicts_menu.key, + sc_prevent_rl_conflicts_menu.def).toBool ()); // initialize the tree view with all shortcut data scmgr.fill_treewidget (shortcuts_treewidget); @@ -1072,6 +1075,7 @@ // shortcuts settings->setValue (sc_prevent_rl_conflicts.key, cb_prevent_readline_conflicts->isChecked ()); + settings->setValue (sc_prevent_rl_conflicts_menu.key, cb_prevent_readline_conflicts_menu->isChecked ()); shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); scmgr.write_shortcuts (settings, closing); diff -r 95ec5841c9d6 -r 2a70a068c4ab libgui/src/settings-dialog.ui --- a/libgui/src/settings-dialog.ui Fri Nov 20 18:22:56 2020 +0100 +++ b/libgui/src/settings-dialog.ui Fri Nov 20 20:02:29 2020 +0100 @@ -32,7 +32,7 @@ - 7 + 6 @@ -51,7 +51,7 @@ 0 - 0 + -38 1021 607 @@ -2638,8 +2638,15 @@ 0 - - + + + 6 + + + + + + Select this option to prevent conflicts with readline shortcuts @@ -2652,6 +2659,13 @@ + + + + Disable menu accelerators of main window menus when Commmand Window has focus + + +