Mercurial > octave
diff libgui/src/main-window.cc @ 27860:cbd4d97100b3
add action and shortcut for switching to previews widget (bug #57447)
* gui-preferences-sc.h: new shortcut preference
* main-window.cc (main_window::main_window) initialize new class variable for
saving the previous dock widget with the command window;
(focus_changed): save current widget before setting it to the new one;
(go_to_previous_widget): new slot for the new action;
(construct_window_menu): add action for switching to previous widget;
(configure_shortcuts): set shortcut to new action
* main-window.h: new action with related slot, new varaible for saving the
previous dock widget
* shortcut-manager.cc (init_data): initialize the new shortcut
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 21 Dec 2019 20:23:50 +0100 |
parents | 28d7ec92bae6 |
children | 465ac679e976 |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Sun Dec 22 01:01:27 2019 +0100 +++ b/libgui/src/main-window.cc Sat Dec 21 20:23:50 2019 +0100 @@ -174,6 +174,8 @@ m_variable_editor_window = new variable_editor (this, m_octave_qobj); m_workspace_window = new workspace_view (this, m_octave_qobj); + m_previous_dock = m_command_window; + // Set active editor depending on editor window. If the latter is // not initialized (qscintilla not present), use the external editor. if (m_editor_window) @@ -365,6 +367,8 @@ else if (edit_dock_widget == m_active_dock) emit editor_focus_changed (false); + if (m_active_dock) + m_previous_dock = m_active_dock; m_active_dock = dock; } } @@ -955,6 +959,11 @@ write_settings (); } + void main_window::go_to_previous_widget (void) + { + m_previous_dock->activate (); + } + void main_window::reset_windows (void) { hide (); @@ -2621,6 +2630,11 @@ window_menu->addSeparator (); + m_previous_dock_action = add_action (window_menu, QIcon (), + tr ("Previous Widget"), SLOT (go_to_previous_widget (void))); + + window_menu->addSeparator (); + m_reset_windows_action = add_action (window_menu, QIcon (), tr ("Reset Default Window Layout"), SLOT (reset_windows (void))); } @@ -2786,6 +2800,7 @@ scmgr.set_shortcut (m_editor_action, sc_main_window_editor); scmgr.set_shortcut (m_documentation_action, sc_main_window_doc); scmgr.set_shortcut (m_variable_editor_action, sc_main_window_variable_editor); + scmgr.set_shortcut (m_previous_dock_action, sc_main_window_previous_dock); scmgr.set_shortcut (m_reset_windows_action, sc_main_window_reset); // help menu