# HG changeset patch # User Torsten # Date 1387552400 -3600 # Node ID 14acb08d75fae928db2d8162c51fe63b25f27570 # Parent 5971c8f515a789f903122709ab91b9f73e407a27 gui: optionally set focus to console when a command is run from another widget * settings-dialog.ui: new checkbox for focus switching to console * settings-dialog.cc (constructor): read new setting and init check box, (write_changed_settings): write state from check box into settings file * main-window.cc (focus_console_after_command): new functions checking settings file for new settings, (execute_command_in_terminal): focus console if desired, (run_file_in_terminal): focus console if desired * main-window.h: new function focus_console_after_command diff -r 5971c8f515a7 -r 14acb08d75fa libgui/src/main-window.cc --- a/libgui/src/main-window.cc Thu Dec 19 17:32:38 2013 -0800 +++ b/libgui/src/main-window.cc Fri Dec 20 16:13:20 2013 +0100 @@ -241,17 +241,27 @@ octave_link::post_event (this, &main_window::clear_history_callback); } +bool +main_window::focus_console_after_command () +{ + QSettings *settings = resource_manager::get_settings (); + return settings->value ("terminal/focus_after_command",false).toBool (); +} + void main_window::execute_command_in_terminal (const QString& command) { queue_command (command); - focus_command_window (); + if (focus_console_after_command ()) + focus_command_window (); } void main_window::run_file_in_terminal (const QFileInfo& info) { octave_link::post_event (this, &main_window::run_file_callback, info); + if (focus_console_after_command ()) + focus_command_window (); } void diff -r 5971c8f515a7 -r 14acb08d75fa libgui/src/main-window.h --- a/libgui/src/main-window.h Thu Dec 19 17:32:38 2013 -0800 +++ b/libgui/src/main-window.h Fri Dec 20 16:13:20 2013 +0100 @@ -250,6 +250,7 @@ void execute_command_callback (); void run_file_callback (const QFileInfo& info); + bool focus_console_after_command (); void new_figure_callback (void); diff -r 5971c8f515a7 -r 14acb08d75fa libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Thu Dec 19 17:32:38 2013 -0800 +++ b/libgui/src/settings-dialog.cc Fri Dec 20 16:13:20 2013 +0100 @@ -168,6 +168,8 @@ settings->value ("terminal/cursorBlinking",true).toBool ()); ui->terminal_cursorUseForegroundColor->setChecked ( settings->value ("terminal/cursorUseForegroundColor",true).toBool ()); + ui->terminal_focus_command->setChecked ( + settings->value ("terminal/focus_after_command",false).toBool ()); QString cursorType = settings->value ("terminal/cursorType", "ibeam").toString (); @@ -537,6 +539,8 @@ ui->terminal_cursorBlinking->isChecked ()); settings->setValue ("terminal/cursorUseForegroundColor", ui->terminal_cursorUseForegroundColor->isChecked ()); + settings->setValue ("terminal/focus_after_command", + ui->terminal_focus_command->isChecked ()); // the cursor QString cursorType; diff -r 5971c8f515a7 -r 14acb08d75fa libgui/src/settings-dialog.ui --- a/libgui/src/settings-dialog.ui Thu Dec 19 17:32:38 2013 -0800 +++ b/libgui/src/settings-dialog.ui Fri Dec 20 16:13:20 2013 +0100 @@ -32,7 +32,7 @@ - 6 + 3 @@ -855,67 +855,113 @@ Terminal - - - - 10 - 50 - 631 - 31 - - - - - - - Cursor type: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Cursor blinking - - - - - - - Use foreground color - - - - - 10 - 90 + 10 631 - 291 + 371 - + + + + + Font + + + + + + + false + + + QFontComboBox::MonospacedFonts + + + + + + + Font size + + + + + + + 2 + + + 96 + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Cursor type: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cursor blinking + + + + + + + Use foreground color + + + + + + + Qt::Horizontal @@ -948,6 +994,20 @@ + + + Set focus to terminal when running a command from within another widget + + + + + + + Qt::Horizontal + + + + Qt::Vertical @@ -962,68 +1022,6 @@ - - - - 10 - 10 - 631 - 31 - - - - - - - Font - - - - - - - false - - - QFontComboBox::MonospacedFonts - - - - - - - Font size - - - - - - - 2 - - - 96 - - - 10 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - -