Mercurial > octave
changeset 29439:fe06fafb4cac
fix en-/disabling some editor actions depending on file type (bug #60214)
* file-editor-tab.cc (handle_request_add_breakpoint): just return if
the file is not an octave file
* file-editor.cc (check_actions): en-/disable the run action and debug
actions depending on tabs and file type, emit signal of changed tabs
also with flag if octave file or not;
(handle_editor_state_changed): store if current file is an octave file,
emit signal with possibly changed file type;
* file-editor.h: signal editor_tabs_changed_signal with two args,
new flag m_is_octave_file
* main-window.cc (handle_exit_debugger): en/-disable step action depending on
editor tabs and file type;
(construct): slot editor_tabs_changed has two args now;
(editor_tabs_changed): two args, store editor file type in flag and
en-/disable step action accordingly
* main-window.h: slot editor_tabs_changed with two args,
new flag m_editor_is_octave_file
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sun, 14 Mar 2021 22:45:42 +0100 |
parents | 2031c0f76d02 |
children | c7853cc87c19 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/main-window.cc libgui/src/main-window.h |
diffstat | 5 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc Sat Mar 13 10:56:43 2021 +0100 +++ b/libgui/src/m-editor/file-editor-tab.cc Sun Mar 14 22:45:42 2021 +0100 @@ -1152,6 +1152,9 @@ void file_editor_tab::handle_request_add_breakpoint (int line, const QString& condition) { + if (! m_is_octave_file) + return; + bp_info info (m_file_name, line, condition); add_breakpoint_event (info);
--- a/libgui/src/m-editor/file-editor.cc Sat Mar 13 10:56:43 2021 +0100 +++ b/libgui/src/m-editor/file-editor.cc Sun Mar 14 22:45:42 2021 +0100 @@ -206,6 +206,7 @@ void file_editor::check_actions (void) { + // Do not include shared actions not only related to the editor bool have_tabs = m_tab_widget->count () > 0; m_edit_cmd_menu->setEnabled (have_tabs); @@ -231,7 +232,13 @@ m_find_next_action->setEnabled (have_tabs); m_find_previous_action->setEnabled (have_tabs); m_print_action->setEnabled (have_tabs); - m_run_action->setEnabled (have_tabs); + + m_run_action->setEnabled (have_tabs && m_is_octave_file); + + m_toggle_breakpoint_action->setEnabled (have_tabs && m_is_octave_file); + m_next_breakpoint_action->setEnabled (have_tabs && m_is_octave_file); + m_previous_breakpoint_action->setEnabled (have_tabs && m_is_octave_file); + m_remove_all_breakpoints_action->setEnabled (have_tabs && m_is_octave_file); m_edit_function_action->setEnabled (have_tabs); m_save_action->setEnabled (have_tabs); @@ -241,7 +248,7 @@ m_close_others_action->setEnabled (have_tabs && m_tab_widget->count () > 1); m_sort_tabs_action->setEnabled (have_tabs && m_tab_widget->count () > 1); - emit editor_tabs_changed_signal (have_tabs); + emit editor_tabs_changed_signal (have_tabs, m_is_octave_file); } // empty_script determines whether we have to create an empty script @@ -985,8 +992,12 @@ if (m_copy_action) m_copy_action->setEnabled (copy_available); m_cut_action->setEnabled (copy_available); + m_run_selection_action->setEnabled (copy_available); m_run_action->setEnabled (is_octave_file); + m_is_octave_file = is_octave_file; + + emit editor_tabs_changed_signal (true, m_is_octave_file); } m_copy_action_enabled = m_copy_action->isEnabled ();
--- a/libgui/src/m-editor/file-editor.h Sat Mar 13 10:56:43 2021 +0100 +++ b/libgui/src/m-editor/file-editor.h Sun Mar 14 22:45:42 2021 +0100 @@ -171,7 +171,7 @@ void request_open_file_external (const QString& file_name, int line); void file_loaded_signal (void); - void editor_tabs_changed_signal (bool); + void editor_tabs_changed_signal (bool, bool); void request_dbcont_signal (void); void enter_debug_mode_signal (void); @@ -449,6 +449,7 @@ bool m_copy_action_enabled; bool m_undo_action_enabled; + bool m_is_octave_file; QMenu *m_edit_menu; QMenu *m_edit_cmd_menu;
--- a/libgui/src/main-window.cc Sat Mar 13 10:56:43 2021 +0100 +++ b/libgui/src/main-window.cc Sun Mar 14 22:45:42 2021 +0100 @@ -1179,7 +1179,7 @@ m_debug_continue->setEnabled (false); m_debug_step_into->setEnabled (false); - m_debug_step_over->setEnabled (m_editor_has_tabs); + m_debug_step_over->setEnabled (m_editor_has_tabs && m_editor_is_octave_file); m_debug_step_out->setEnabled (false); m_debug_quit->setEnabled (false); } @@ -2059,8 +2059,8 @@ connect (this, SIGNAL (step_into_file_signal (void)), m_editor_window, SLOT (request_step_into_file (void))); - connect (m_editor_window, SIGNAL (editor_tabs_changed_signal (bool)), - this, SLOT (editor_tabs_changed (bool))); + connect (m_editor_window, SIGNAL (editor_tabs_changed_signal (bool, bool)), + this, SLOT (editor_tabs_changed (bool, bool))); connect (m_editor_window, SIGNAL (request_open_file_external (const QString&, int)), @@ -2534,11 +2534,12 @@ tr ("&Show Profile Data"), SLOT (profiler_show ())); } - void main_window::editor_tabs_changed (bool have_tabs) + void main_window::editor_tabs_changed (bool have_tabs, bool is_octave) { // Set state of actions which depend on the existence of editor tabs m_editor_has_tabs = have_tabs; - m_debug_step_over->setEnabled (have_tabs); + m_editor_is_octave_file = is_octave; + m_debug_step_over->setEnabled (have_tabs && is_octave); } QAction * main_window::construct_window_menu_item (QMenu *p,
--- a/libgui/src/main-window.h Sat Mar 13 10:56:43 2021 +0100 +++ b/libgui/src/main-window.h Sun Mar 14 22:45:42 2021 +0100 @@ -183,7 +183,7 @@ void debug_step_over (void); void debug_step_out (void); void debug_quit (void); - void editor_tabs_changed (bool); + void editor_tabs_changed (bool, bool); void request_open_file (void); void request_new_script (const QString& commands = QString ()); @@ -438,6 +438,7 @@ bool m_prevent_readline_conflicts_menu; bool m_suppress_dbg_location; bool m_editor_has_tabs; + bool m_editor_is_octave_file; //! Flag for closing the whole application.