diff libgui/src/main-window.cc @ 27556:410622ac120f

improve run selection from editor (bug #42705) * file-editor-tab.cc (file_editor_tab): relay interpreter event signals to the ones of the editor widget * file-editor.cc (make_file_editor_tab): connect signal of edit area for giving focus to console window to the new slot in main_window * octave-qscintilla.cc: include headers required for interpreter threads and for additionally used Qt libs; (octave_qscintilla): connect new signals for finished run selection action to the new related slot; (contextmenu_run_temp_error): new method displaying a message box on error handling temp. files; (contextmenu_run): create a temp. file with all selected lines extended by commands for displaying each line and add it to the command history, disable opening a file at breakpoints, run this temp. file by the interpreter and emit new signal when running this file is finished; (ctx_menu_run_finished): slot when running the temp. file is finished, removing temp. files and reset modified editor preferences; * octave-qscintilla.h: include QSettings and interpreter-events, interpreter signal, signal for focusing console window and signal when running temp file is finished, new slot for the latter * main-window.cc (focus_console_after_command): do not return the related setting, but actually give console window the focus if desired, (run_file_in_terminal, execute_command_in_terminal): use this new form * main-window.h: change focus_console_method from private method into public slot * resource-manager.cc (resource_manager): initialize new list of created temp. files; (~resource_manager): remove any temp. files that are still existing; (do_create_tmp_file): create a new temp. file with the given contents and store its smart pointer into a list for removing the file later; (do_remove_tmp_file): remove given temp. file and remove it from the list; * resource-manager.h: include QPointer and QTemporaryFile, (create_tmp_file): new static method calling internal do_create_tmp_file; (remove_tmp_file): new static method calling internal do_create_tmp_file; new internal methods do_create_tmp_file and do_remove_tmp_file, new list for storing temp. file pointers
author Torsten Lilge <ttl-octave@mailbox.org>
date Fri, 25 Oct 2019 07:36:37 +0200
parents 9e526393d80a
children 3fcc650de22f
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Thu Oct 24 22:33:37 2019 +0200
+++ b/libgui/src/main-window.cc	Fri Oct 25 07:36:37 2019 +0200
@@ -1037,8 +1037,7 @@
          command_editor::accept_line ();
        });
 
-    if (focus_console_after_command ())
-      focus_command_window ();
+    focus_console_after_command ();
   }
 
   void main_window::run_file_in_terminal (const QFileInfo& info)
@@ -1082,8 +1081,7 @@
          command_editor::accept_line ();
        });
 
-    if (focus_console_after_command ())
-      focus_command_window ();
+    focus_console_after_command ();
   }
 
   void main_window::handle_new_figure_request (void)
@@ -2749,10 +2747,11 @@
     qt_link->wake_all ();
   }
 
-  bool main_window::focus_console_after_command (void)
+  void main_window::focus_console_after_command (void)
   {
     QSettings *settings = resource_manager::get_settings ();
-    return settings->value ("terminal/focus_after_command",false).toBool ();
+    if (settings->value ("terminal/focus_after_command",false).toBool ())
+      focus_command_window ();
   }
 
   void main_window::configure_shortcuts (void)