annotate libgui/src/interpreter-qobject.cc @ 29542:3d34b70b5a49

connect many Qt signals and slots without SIGNAL and SLOT macros This changes switches most code in the libgui/src and libgui/graphics directories to use the new Qt style of connecting signals and slots that uses pointers to member functions or function objects instead of strings to refer to the signal and slot functions. For an introduction, see https://wiki.qt.io/New_Signal_Slot_Syntax. There are many connections left to adapt. In some cases, there are overloaded functions (or default parameters) that need to be handled. Use of QOverload<> or an anonymous function should fix these. In others, we are connecting to parent objects where we only have a pointer to QWidget instead of a specific type of object. To fix those, we need to either move the code that makes th connection to a place where the actual types of both objects are known or pass more specific types as the parent object. In a few cases, there appear to real mismatches in the types of objects and the signal/slot functions. Files affected: ButtonControl.cc, ButtonGroup.cc, ContextMenu.cc, EditControl.cc, Figure.cc, ListBoxControl.cc, Menu.cc, Object.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushTool.cc, SliderControl.cc, Table.cc, ToggleTool.cc, ToolBar.cc, annotation-dialog.cc, qt-graphics-toolkit.cc, color-picker.cc, command-widget.cc, dialog.cc, documentation-bookmarks.cc, documentation.cc, files-dock-widget.cc, find-files-dialog.cc, history-dock-widget.cc, interpreter-qobject.cc, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, find-dialog.cc, octave-qscintilla.cc, main-window.cc, octave-dock-widget.cc, octave-qobject.cc, qt-interpreter-events.cc, set-path-dialog.cc, set-path-model.cc, settings-dialog.cc, shortcut-manager.cc, tab-bar.cc, variable-editor-model.cc, variable-editor.cc, welcome-wizard.cc, welcome-wizard.h, workspace-view.cc, and workspace-view.h.
author John W. Eaton <jwe@octave.org>
date Fri, 16 Apr 2021 23:06:32 -0400
parents 3bfec185c9e2
children f6ad83cbe3c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 28347
diff changeset
3 // Copyright (C) 2011-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 # include "config.h"
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "interpreter-qobject.h"
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27197
diff changeset
31 #include "octave-qobject.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27302
diff changeset
32 #include "qt-application.h"
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27262
diff changeset
33 #include "qt-interpreter-events.h"
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
27697
5e8891dceec7 backout changesets cdb681adc85a and b3401292e101 (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27695
diff changeset
35 #include "graphics-init.h"
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "input.h"
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "interpreter.h"
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 namespace octave
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 {
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
41 interpreter_qobject::interpreter_qobject (base_qobject& oct_qobj)
27697
5e8891dceec7 backout changesets cdb681adc85a and b3401292e101 (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27695
diff changeset
42 : QObject (), m_octave_qobj (oct_qobj), m_interpreter (nullptr)
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
43 { }
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
44
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
45 void interpreter_qobject::execute (void)
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27197
diff changeset
46 {
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
47 // The Octave application context owns the interpreter.
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
48
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
49 qt_application& app_context = m_octave_qobj.app_context ();
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
50
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
51 interpreter& interp = app_context.create_interpreter ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
52
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27262
diff changeset
53 event_manager& evmgr = interp.get_event_manager ();
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
54
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
55 evmgr.connect_link (m_octave_qobj.get_qt_interpreter_events ());
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27262
diff changeset
56 evmgr.enable ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27197
diff changeset
57
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29503
diff changeset
58 connect (this, &interpreter_qobject::ready,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29503
diff changeset
59 &m_octave_qobj, &base_qobject::interpreter_ready);
29219
c2f3a0832cf0 fix possible glitch when interpreter is ready when main window is created
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29163
diff changeset
60
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 int exit_status = 0;
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 try
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 {
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 // Final initialization.
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 interp.initialize ();
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
69 if (app_context.start_gui_p ()
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
70 && ! m_octave_qobj.experimental_terminal_widget ())
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 {
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 input_system& input_sys = interp.get_input_system ();
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 input_sys.PS1 (">> ");
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 input_sys.PS2 ("");
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 }
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 if (interp.initialized ())
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 {
27697
5e8891dceec7 backout changesets cdb681adc85a and b3401292e101 (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27695
diff changeset
80 // The interpreter should be completely ready at this point so let
5e8891dceec7 backout changesets cdb681adc85a and b3401292e101 (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27695
diff changeset
81 // the GUI know.
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
83 m_interpreter = &interp;
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
84
28347
00a9a49c7670 improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
85 emit ready ();
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
27697
5e8891dceec7 backout changesets cdb681adc85a and b3401292e101 (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27695
diff changeset
87 graphics_init (interp, m_octave_qobj);
27695
cdb681adc85a improve exit behavior with qt graphics toolkit (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27694
diff changeset
88
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 // Start executing commands in the command window.
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 exit_status = interp.execute ();
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 }
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 }
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 28347
diff changeset
94 catch (const exit_exception& xe)
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 {
29163
8f67ad8b3103 maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents: 28347
diff changeset
96 exit_status = xe.exit_status ();
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 }
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
99 if (m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
100 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
101 interp.shutdown ();
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
102
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
103 emit shutdown_finished (exit_status);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
104 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
105 else
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
106 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
107 // Signal that the interpreter is done executing code in the
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
108 // main REPL, from script files, or command line eval arguments.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
109 // By using a signal here, we give the GUI a chance to process
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
110 // any pending events, then signal that it is safe to shutdown
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
111 // the interpreter. Our notification here allows the GUI to
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
112 // insert the request to shutdown the interpreter in the event
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
113 // queue after any other pending signals. The application
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
114 // context owns the interpreter and will be responsible for
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
115 // deleting it later, when the application object destructor is
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
116 // executed.
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
117
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
118 emit execution_finished (exit_status);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
119 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
120 }
27694
b3401292e101 store Qt graphics toolkit object in interpreter_qobject
John W. Eaton <jwe@octave.org>
parents: 27646
diff changeset
121
28347
00a9a49c7670 improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
122 void interpreter_qobject::shutdown (int exit_status)
00a9a49c7670 improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
123 {
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
124 if (! m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
125 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
126 if (m_interpreter)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
127 m_interpreter->shutdown ();
27695
cdb681adc85a improve exit behavior with qt graphics toolkit (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27694
diff changeset
128
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
129 // Signal that the interpreter has executed shutdown actions.
28347
00a9a49c7670 improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
130
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
131 emit shutdown_finished (exit_status);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
132 }
27695
cdb681adc85a improve exit behavior with qt graphics toolkit (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27694
diff changeset
133 }
cdb681adc85a improve exit behavior with qt graphics toolkit (bug #56952)
John W. Eaton <jwe@octave.org>
parents: 27694
diff changeset
134
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
135 void interpreter_qobject::interpreter_event (const fcn_callback& fcn)
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
136 {
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
137 if (! m_interpreter)
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
138 return;
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
139
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
140 event_manager& evmgr = m_interpreter->get_event_manager ();
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
141
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
142 evmgr.post_event (fcn);
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
143 }
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
144
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
145 void interpreter_qobject::interpreter_event (const meth_callback& meth)
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
146 {
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
147 if (! m_interpreter)
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
148 return;
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
149
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
150 event_manager& evmgr = m_interpreter->get_event_manager ();
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
151
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
152 evmgr.post_event (meth);
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
153 }
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
154
29292
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
155 void interpreter_qobject::interrupt (void)
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
156 {
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
157 if (! m_interpreter)
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
158 return;
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
159
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
160 // The following is a direct function call across threads.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
161 // We need to ensure that it uses thread-safe functions.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
162
29292
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
163 m_interpreter->interrupt ();
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
164 }
eb1e10abe9d5 use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents: 29219
diff changeset
165
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
166 void interpreter_qobject::pause (void)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
167 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
168 // FIXME: Should we make this action work with the old terminal
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
169 // widget?
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
170
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
171 if (m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
172 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
173 if (! m_interpreter)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
174 return;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
175
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
176 // The following is a direct function call across threads.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
177 // We need to ensure that it uses thread-safe functions.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
178
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
179 m_interpreter->pause ();
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
180 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
181 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
182
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
183 void interpreter_qobject::stop (void)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
184 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
185 // FIXME: Should we make this action work with the old terminal
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
186 // widget?
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
187
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
188 if (m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
189 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
190 if (! m_interpreter)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
191 return;
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
192
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
193 // The following is a direct function call across threads.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
194 // We need to ensure that it uses thread-safe functions.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
195
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
196 m_interpreter->stop ();
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
197 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
198 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
199
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
200 void interpreter_qobject::resume (void)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
201 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
202 // FIXME: Should we make this action work with the old terminal
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
203 // widget?
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
204
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
205 if (m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
206 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
207 // FIXME: This action should only be available when the
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
208 // interpreter is paused.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
209
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
210 interpreter_event
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
211 ([=] (interpreter& interp)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
212 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
213 // INTERPRETER THREAD
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
214
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
215 interp.resume ();
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
216 });
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
217 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
218 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
219
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
220 qt_interpreter_events * interpreter_qobject::qt_link (void)
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27197
diff changeset
221 {
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
222 return m_octave_qobj.qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27197
diff changeset
223 }
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224 }