Mercurial > octave-libtiff
changeset 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 | 1a75fca6ad5d |
children | 3fada47cc58a |
files | libgui/src/gui-preferences-sc.h libgui/src/main-window.cc libgui/src/main-window.h libgui/src/shortcut-manager.cc |
diffstat | 4 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/gui-preferences-sc.h Sun Dec 22 01:01:27 2019 +0100 +++ b/libgui/src/gui-preferences-sc.h Sat Dec 21 20:23:50 2019 +0100 @@ -102,6 +102,7 @@ const sc_pref sc_main_window_editor (sc_main_window + ":editor", PRE + CTRL + Qt::Key_4); const sc_pref sc_main_window_doc (sc_main_window + ":doc", PRE + CTRL + Qt::Key_5); const sc_pref sc_main_window_variable_editor (sc_main_window + ":variable_editor", PRE + CTRL + Qt::Key_6); +const sc_pref sc_main_window_previous_dock (sc_main_window + ":previous_widget", PRE + CTRL_ALT + Qt::Key_0); const sc_pref sc_main_window_reset (sc_main_window + ":reset", QKeySequence::UnknownKey); // help
--- 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
--- a/libgui/src/main-window.h Sun Dec 22 01:01:27 2019 +0100 +++ b/libgui/src/main-window.h Sat Dec 21 20:23:50 2019 +0100 @@ -157,6 +157,7 @@ void show_about_octave (void); void notice_settings (const gui_settings *settings); void prepare_to_exit (void); + void go_to_previous_widget (void); void reset_windows (void); void update_octave_directory (const QString& dir); @@ -320,6 +321,7 @@ external_editor_interface *m_external_editor; QWidget *m_active_editor; + octave_dock_widget *m_previous_dock; octave_dock_widget *m_active_dock; QString m_release_notes_icon; @@ -368,6 +370,7 @@ QAction *m_editor_action; QAction *m_documentation_action; QAction *m_variable_editor_action; + QAction *m_previous_dock_action; QAction *m_reset_windows_action; QAction *m_ondisk_doc_action;
--- a/libgui/src/shortcut-manager.cc Sun Dec 22 01:01:27 2019 +0100 +++ b/libgui/src/shortcut-manager.cc Sat Dec 21 20:23:50 2019 +0100 @@ -174,6 +174,7 @@ init (tr ("Editor"), sc_main_window_editor); init (tr ("Documentation"), sc_main_window_doc); init (tr ("Variable Editor"), sc_main_window_variable_editor); + init (tr ("Previous Widget"), sc_main_window_previous_dock); init (tr ("Reset Default Window Layout"), sc_main_window_reset); // help