Mercurial > octave
changeset 27669:271b5cd640d7
Add functions to show GUI windows (bug #57213)
* event-manager.h (interpreter_events::focus_window): New empty method.
(event_manager::focus_window): New vistual method that executes the instance's
focus_window method.
* event_manager.cc (commandwindow, commandhistory, filebrowser, workspace): New
builtin interpreter functions.
* qt-interpreter-events.[h, cc] (qt_interpreter_events::focus_window_signal):
New signal.
(qt_interpreter_events::focus_window): Implements event_manager::focus_window,
emits focus_window_signal.
* main-window.[h, cc] (main_window::focus_window): New slot that activates the
named window.
* octave-qobject.cc (gui_qobject::gui_qobject): Connect
qt_interpreter_events::focus_window_signal to main_window::focus_window.
* __unimplemented__.m: Remove commandwindow, commandhistory, filebrowser, and
workspace from the list.
* gui.txi: Add commandwindow, commandhistory, filebrowser, workspace docstrings.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Tue, 12 Nov 2019 14:54:25 +0100 |
parents | 7ffe081140ef |
children | a780677b845c |
files | doc/interpreter/gui.txi libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-qobject.cc libgui/src/octave-qobject.h libgui/src/qt-interpreter-events.cc libgui/src/qt-interpreter-events.h libinterp/corefcn/event-manager.cc libinterp/corefcn/event-manager.h scripts/help/__unimplemented__.m |
diffstat | 10 files changed, 99 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/gui.txi Mon Nov 11 20:22:52 2019 +0100 +++ b/doc/interpreter/gui.txi Tue Nov 12 14:54:25 2019 +0100 @@ -143,6 +143,14 @@ @DOCSTRING(movegui) @c Not sure where this should go... +@DOCSTRING(commandhistory) + +@DOCSTRING(commandwindow) + +@DOCSTRING(filebrowser) + +@DOCSTRING(workspace) + @DOCSTRING(openvar) @DOCSTRING(uiwait)
--- a/libgui/src/main-window.cc Mon Nov 11 20:22:52 2019 +0100 +++ b/libgui/src/main-window.cc Tue Nov 12 14:54:25 2019 +0100 @@ -266,6 +266,18 @@ m_command_window->activate (); } + void main_window::focus_window (const QString& win_name) + { + if (win_name == "command") + m_command_window->activate (); + else if (win_name == "history") + m_history_window->activate (); + else if (win_name == "workspace") + m_workspace_window->activate (); + else if (win_name == "filebrowser") + m_file_browser_window->activate (); + } + bool main_window::confirm_shutdown (void) { bool closenow = true;
--- a/libgui/src/main-window.h Mon Nov 11 20:22:52 2019 +0100 +++ b/libgui/src/main-window.h Tue Nov 12 14:54:25 2019 +0100 @@ -125,6 +125,7 @@ public slots: void focus_changed (QWidget *w_old, QWidget *w_new); + void focus_window (const QString& win_name); void request_reload_settings (void); void report_status_message (const QString& statusMessage);
--- a/libgui/src/octave-qobject.cc Mon Nov 11 20:22:52 2019 +0100 +++ b/libgui/src/octave-qobject.cc Tue Nov 12 14:54:25 2019 +0100 @@ -352,6 +352,10 @@ connect (m_interpreter_qobj, SIGNAL (octave_ready_signal (void)), m_main_window, SLOT (handle_octave_ready (void))); + connect (qt_link (), + SIGNAL (focus_window_signal (const QString&)), + m_main_window, SLOT (focus_window (const QString&))); + m_app_context.gui_running (true); start_main_thread ();
--- a/libgui/src/octave-qobject.h Mon Nov 11 20:22:52 2019 +0100 +++ b/libgui/src/octave-qobject.h Tue Nov 12 14:54:25 2019 +0100 @@ -200,4 +200,3 @@ } #endif -
--- a/libgui/src/qt-interpreter-events.cc Mon Nov 11 20:22:52 2019 +0100 +++ b/libgui/src/qt-interpreter-events.cc Tue Nov 12 14:54:25 2019 +0100 @@ -422,6 +422,11 @@ return true; } + void qt_interpreter_events::focus_window (const std::string win_name) + { + emit focus_window_signal (QString::fromStdString (win_name)); + } + void qt_interpreter_events::execute_command_in_terminal (const std::string& command) {
--- a/libgui/src/qt-interpreter-events.h Mon Nov 11 20:22:52 2019 +0100 +++ b/libgui/src/qt-interpreter-events.h Tue Nov 12 14:54:25 2019 +0100 @@ -132,6 +132,8 @@ bool copy_image_to_clipboard (const std::string& file); + void focus_window (const std::string win_name); + void execute_command_in_terminal (const std::string& command); void register_doc (const std::string& file); @@ -191,6 +193,8 @@ void copy_image_to_clipboard_signal (const QString& file, bool remove_file); + void focus_window_signal (const QString& win_name); + void edit_file_signal (const QString& file); void directory_changed_signal (const QString& dir);
--- a/libinterp/corefcn/event-manager.cc Mon Nov 11 20:22:52 2019 +0100 +++ b/libinterp/corefcn/event-manager.cc Tue Nov 12 14:54:25 2019 +0100 @@ -591,3 +591,59 @@ evmgr.copy_image_to_clipboard (file); return ovl (); } + +DEFMETHOD (commandwindow, interp, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} commandwindow () +Show the the GUI command window and give it the keyboard focus. +@end deftypefn */) +{ + if (args.length () != 0) + print_usage (); + + octave::event_manager& evmgr = interp.get_event_manager (); + evmgr.focus_window ("command"); + return ovl (); +} + +DEFMETHOD (commandhistory, interp, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} commandhistory () +Show the the GUI command history window and give it the keyboard focus. +@end deftypefn */) +{ + if (args.length () != 0) + print_usage (); + + octave::event_manager& evmgr = interp.get_event_manager (); + evmgr.focus_window ("history"); + return ovl (); +} + +DEFMETHOD (workspace, interp, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} workspace () +Show the the GUI workspace window and give it the keyboard focus. +@end deftypefn */) +{ + if (args.length () != 0) + print_usage (); + + octave::event_manager& evmgr = interp.get_event_manager (); + evmgr.focus_window ("workspace"); + return ovl (); +} + +DEFMETHOD (filebrowser, interp, args, , + doc: /* -*- texinfo -*- +@deftypefn {} {} filebrowser () +Show the the GUI file browser window and give it the keyboard focus. +@end deftypefn */) +{ + if (args.length () != 0) + print_usage (); + + octave::event_manager& evmgr = interp.get_event_manager (); + evmgr.focus_window ("filebrowser"); + return ovl (); +}
--- a/libinterp/corefcn/event-manager.h Mon Nov 11 20:22:52 2019 +0100 +++ b/libinterp/corefcn/event-manager.h Tue Nov 12 14:54:25 2019 +0100 @@ -184,6 +184,9 @@ return false; } + virtual void focus_window (const std::string /*win_name*/) + { } + virtual void execute_command_in_terminal (const std::string& /*command*/) { } @@ -458,6 +461,12 @@ return enabled () ? instance->copy_image_to_clipboard (file) : false; } + virtual void focus_window (const std::string win_name) + { + if (enabled ()) + instance->focus_window (win_name); + } + // Preserves pending input. void execute_command_in_terminal (const std::string& command) {
--- a/scripts/help/__unimplemented__.m Mon Nov 11 20:22:52 2019 +0100 +++ b/scripts/help/__unimplemented__.m Tue Nov 12 14:54:25 2019 +0100 @@ -658,8 +658,6 @@ "collapse", "colordef", "colormapeditor", - "commandhistory", - "commandwindow", "compose", "condensation", "coneplot", @@ -747,7 +745,6 @@ "Feval", "fewerbins", "figurepalette", - "filebrowser", "FileDatastore", "filemarker", "fileMode", @@ -1338,7 +1335,6 @@ "winopen", "withtol", "wordcloud", - "workspace", "write", "writeChecksum", "writeCol",