Mercurial > octave
changeset 29621:a5ee1fec49ba
provide access to qt_interpreter_event handlers from event_manager class
This is a temporary change until the event manager class can be
revised, probably by doing something like what is described here:
https://octave.discourse.group/t/redesigning-the-event-manager-class/707/3
It is sometimes useful to have a custom set of handlers installed
but to still want Qt GUI functions like showing the documentation
or the variable editor windows. This change allows access to the
Qt handler functions so that they may be called from the custom set of
handlers.
* interpreter-qobject.cc (interpreter_qobject::execute): Install link
to Qt event handlers in event_manager object.
* event-manager.h, event-manager.cc
(event_manager::m_qt_event_handlers): New data member.
(event_manager::install_qt_event_handlers,
(event_manager::qt_event_handlers): New functions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 05 May 2021 20:37:55 -0400 |
parents | ad720f9c12b3 |
children | a49e8c0ce9a3 |
files | libgui/src/interpreter-qobject.cc libinterp/corefcn/event-manager.cc libinterp/corefcn/event-manager.h |
diffstat | 3 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/interpreter-qobject.cc Wed May 05 20:30:09 2021 -0400 +++ b/libgui/src/interpreter-qobject.cc Wed May 05 20:37:55 2021 -0400 @@ -53,6 +53,7 @@ event_manager& evmgr = interp.get_event_manager (); evmgr.connect_link (m_octave_qobj.get_qt_interpreter_events ()); + evmgr.install_qt_event_handlers (m_octave_qobj.get_qt_interpreter_events ()); evmgr.enable (); connect (this, &interpreter_qobject::ready,
--- a/libinterp/corefcn/event-manager.cc Wed May 05 20:30:09 2021 -0400 +++ b/libinterp/corefcn/event-manager.cc Wed May 05 20:37:55 2021 -0400 @@ -66,6 +66,7 @@ event_manager::event_manager (interpreter& interp) : m_interpreter (interp), instance (new interpreter_events ()), + m_qt_event_handlers (), event_queue_mutex (new mutex ()), gui_event_queue (), debugging (false), link_enabled (true) {
--- a/libinterp/corefcn/event-manager.h Wed May 05 20:30:09 2021 -0400 +++ b/libinterp/corefcn/event-manager.h Wed May 05 20:37:55 2021 -0400 @@ -317,6 +317,19 @@ return link_enabled; } + // Make the Qt actions available for others. This is a temporary + // solution to allow Qt actions like opening the documentation + // browser when the primary interpreter_events object is not the one + // defined for the Qt GUI. + OCTINTERP_API void + install_qt_event_handlers (const std::shared_ptr<interpreter_events>& obj) + { + m_qt_event_handlers = obj; + } + + OCTINTERP_API std::shared_ptr<interpreter_events> + qt_event_handlers (void) const { return m_qt_event_handlers; } + // If disable is TRUE, then no additional events will be processed // other than exit. @@ -719,6 +732,8 @@ std::shared_ptr<interpreter_events> instance; + std::shared_ptr<interpreter_events> m_qt_event_handlers; + protected: // Semaphore to lock access to the event queue.