Mercurial > octave
comparison libgui/src/octave-qobject.h @ 31648:29d734430e5f stable
maint: Re-indent code after switch to using namespace macros.
* BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h,
ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h,
CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h,
ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h,
Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc,
GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h,
ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc,
Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc,
ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc,
PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h,
PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h,
RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc,
SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h,
TextEdit.cc, TextEdit.h, ToggleButtonControl.cc,
ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc,
ToolBar.h, ToolBarButton.cc, ToolBarButton.h, annotation-dialog.cc,
annotation-dialog.h, gl-select.cc, gl-select.h, qopengl-functions.h,
qt-graphics-toolkit.cc, qt-graphics-toolkit.h, module.mk, QTerminal.h,
color-picker.cc, color-picker.h, command-widget.cc, command-widget.h,
community-news.cc, community-news.h, dialog.cc, dialog.h,
documentation-bookmarks.cc, documentation-bookmarks.h,
documentation-dock-widget.cc, documentation-dock-widget.h,
documentation.cc, documentation.h, dw-main-window.cc,
dw-main-window.h, external-editor-interface.cc,
external-editor-interface.h, files-dock-widget.cc,
files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h,
find-files-model.cc, find-files-model.h, graphics-init.cc,
graphics-init.h, gui-settings.cc, gui-settings.h, gui-utils.cc,
gui-utils.h, history-dock-widget.cc, history-dock-widget.h,
interpreter-qobject.cc, interpreter-qobject.h, led-indicator.cc,
led-indicator.h, file-editor-interface.h, file-editor-tab.cc,
file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc,
find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc,
octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h,
main-window.cc, main-window.h, news-reader.cc, news-reader.h,
octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc,
octave-qobject.h, qt-application.cc, qt-application.h,
qt-interpreter-events.cc, qt-interpreter-events.h, qt-utils.h,
release-notes.cc, release-notes.h, resource-manager.cc,
resource-manager.h, set-path-dialog.cc, set-path-dialog.h,
set-path-model.cc, set-path-model.h, settings-dialog.cc,
settings-dialog.h, shortcut-manager.cc, shortcut-manager.h,
tab-bar.cc, tab-bar.h, terminal-dock-widget.cc,
terminal-dock-widget.h, variable-editor-model.cc,
variable-editor-model.h, variable-editor.cc, variable-editor.h,
welcome-wizard.cc, welcome-wizard.h, workspace-model.cc,
workspace-model.h, workspace-view.cc, workspace-view.h:
Re-indent code after switch to using namespace macros.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Dec 2022 14:53:00 -0500 |
parents | c6d54dd31a7e |
children | 1a1f47f17ed4 597f3ee61a48 |
comparison
equal
deleted
inserted
replaced
31646:c6d54dd31a7e | 31648:29d734430e5f |
---|---|
38 #include "resource-manager.h" | 38 #include "resource-manager.h" |
39 #include "shortcut-manager.h" | 39 #include "shortcut-manager.h" |
40 | 40 |
41 OCTAVE_BEGIN_NAMESPACE(octave) | 41 OCTAVE_BEGIN_NAMESPACE(octave) |
42 | 42 |
43 class community_news; | 43 class community_news; |
44 class main_window; | 44 class main_window; |
45 class qt_application; | 45 class qt_application; |
46 class qt_interpreter_events; | 46 class qt_interpreter_events; |
47 class release_notes; | 47 class release_notes; |
48 | 48 |
49 //! This class is a simple wrapper around QApplication so that we can | 49 //! This class is a simple wrapper around QApplication so that we can |
50 //! reimplement QApplication::notify. The octave_qapplication object | 50 //! reimplement QApplication::notify. The octave_qapplication object |
51 //! should behave identically to a QApplication object except that it | 51 //! should behave identically to a QApplication object except that it |
52 //! overrides the notify method so we can handle forward Octave | 52 //! overrides the notify method so we can handle forward Octave |
53 //! execution_exception exceptions from the GUI thread to the | 53 //! execution_exception exceptions from the GUI thread to the |
54 //! interpreter thread. | 54 //! interpreter thread. |
55 | 55 |
56 class octave_qapplication : public QApplication | 56 class octave_qapplication : public QApplication |
57 { | 57 { |
58 Q_OBJECT | 58 Q_OBJECT |
59 | 59 |
60 public: | 60 public: |
61 | 61 |
62 octave_qapplication (int& argc, char **argv) | 62 octave_qapplication (int& argc, char **argv) |
63 : QApplication (argc, argv) | 63 : QApplication (argc, argv) |
64 { } | 64 { } |
65 | 65 |
66 virtual bool notify (QObject *receiver, QEvent *e) override; | 66 virtual bool notify (QObject *receiver, QEvent *e) override; |
67 | 67 |
68 ~octave_qapplication (void) { }; | 68 ~octave_qapplication (void) { }; |
69 | 69 |
70 signals: | 70 signals: |
71 | 71 |
72 void interpreter_event (const fcn_callback& fcn); | 72 void interpreter_event (const fcn_callback& fcn); |
73 void interpreter_event (const meth_callback& meth); | 73 void interpreter_event (const meth_callback& meth); |
74 }; | 74 }; |
75 | 75 |
76 //! Container for windows that may be created from the command line or | 76 //! Container for windows that may be created from the command line or |
77 //! docked with the main GUI window. Any of these windows that are | 77 //! docked with the main GUI window. Any of these windows that are |
78 //! created in command line mode will be adopted by the main window if | 78 //! created in command line mode will be adopted by the main window if |
79 //! it is opened from the command line. Any that are undocked from | 79 //! it is opened from the command line. Any that are undocked from |
80 //! the main window will remain open if control returns to the command | 80 //! the main window will remain open if control returns to the command |
81 //! line. | 81 //! line. |
82 | 82 |
83 class base_qobject; | 83 class base_qobject; |
84 class documentation_dock_widget; | 84 class documentation_dock_widget; |
85 class file_editor_interface; | 85 class file_editor_interface; |
86 class files_dock_widget; | 86 class files_dock_widget; |
87 class history_dock_widget; | 87 class history_dock_widget; |
88 class terminal_dock_widget; | 88 class terminal_dock_widget; |
89 class variable_editor; | 89 class variable_editor; |
90 class workspace_model; | 90 class workspace_model; |
91 class workspace_view; | 91 class workspace_view; |
92 | 92 |
93 //! Base class for Octave interfaces that use Qt. There are two | 93 //! Base class for Octave interfaces that use Qt. There are two |
94 //! classes derived from this one. One provides a command-line | 94 //! classes derived from this one. One provides a command-line |
95 //! interface that may use Qt graphics and another provides the | 95 //! interface that may use Qt graphics and another provides the |
96 //! full GUI experience. | 96 //! full GUI experience. |
97 | 97 |
98 class base_qobject : public QObject | 98 class base_qobject : public QObject |
99 { | 99 { |
100 Q_OBJECT | 100 Q_OBJECT |
101 | 101 |
102 public: | 102 public: |
103 | 103 |
104 // Note: the GUI_APP argument is not needed with the new | 104 // Note: the GUI_APP argument is not needed with the new |
105 // experimental terminal widget. | 105 // experimental terminal widget. |
106 base_qobject (qt_application& app_context, bool gui_app = false); | 106 base_qobject (qt_application& app_context, bool gui_app = false); |
107 | 107 |
108 ~base_qobject (void); | 108 ~base_qobject (void); |
109 | 109 |
110 void config_translators (void); | 110 void config_translators (void); |
111 | 111 |
112 void start_main_thread (void); | 112 void start_main_thread (void); |
113 | 113 |
114 int exec (void); | 114 int exec (void); |
115 | 115 |
116 // The Octave application context. | 116 // The Octave application context. |
117 qt_application& app_context (void) { return m_app_context; } | 117 qt_application& app_context (void) { return m_app_context; } |
118 | 118 |
119 // The Qt QApplication. | 119 // The Qt QApplication. |
120 QApplication * qapplication (void) { return m_qapplication; }; | 120 QApplication * qapplication (void) { return m_qapplication; }; |
121 | 121 |
122 // Provided for convenience. Will be removed once we eliminate the | 122 // Provided for convenience. Will be removed once we eliminate the |
123 // old terminal widget. | 123 // old terminal widget. |
124 bool experimental_terminal_widget (void) const; | 124 bool experimental_terminal_widget (void) const; |
125 | 125 |
126 // Provided for convenience. | 126 // Provided for convenience. |
127 bool gui_running (void) const; | 127 bool gui_running (void) const; |
128 | 128 |
129 bool have_terminal_window (void) const | 129 bool have_terminal_window (void) const |
130 { | 130 { |
131 return ! m_terminal_widget.isNull (); | 131 return ! m_terminal_widget.isNull (); |
132 } | 132 } |
133 | 133 |
134 main_window * get_main_window (void) | 134 main_window * get_main_window (void) |
135 { | 135 { |
136 return m_main_window; | 136 return m_main_window; |
137 } | 137 } |
138 | 138 |
139 resource_manager& get_resource_manager (void) | 139 resource_manager& get_resource_manager (void) |
140 { | 140 { |
141 return m_resource_manager; | 141 return m_resource_manager; |
142 } | 142 } |
143 | 143 |
144 shortcut_manager& get_shortcut_manager (void) | 144 shortcut_manager& get_shortcut_manager (void) |
145 { | 145 { |
146 return m_shortcut_manager; | 146 return m_shortcut_manager; |
147 } | 147 } |
148 | 148 |
149 std::shared_ptr<qt_interpreter_events> get_qt_interpreter_events (void) | 149 std::shared_ptr<qt_interpreter_events> get_qt_interpreter_events (void) |
150 { | 150 { |
151 return m_qt_interpreter_events; | 151 return m_qt_interpreter_events; |
152 } | 152 } |
153 | 153 |
154 qt_interpreter_events * qt_link (void) | 154 qt_interpreter_events * qt_link (void) |
155 { | 155 { |
156 return m_qt_interpreter_events.get (); | 156 return m_qt_interpreter_events.get (); |
157 } | 157 } |
158 | 158 |
159 interpreter_qobject * interpreter_qobj (void) | 159 interpreter_qobject * interpreter_qobj (void) |
160 { | 160 { |
161 return m_interpreter_qobj; | 161 return m_interpreter_qobj; |
162 } | 162 } |
163 | 163 |
164 workspace_model * get_workspace_model (void) | 164 workspace_model * get_workspace_model (void) |
165 { | 165 { |
166 return m_workspace_model; | 166 return m_workspace_model; |
167 } | 167 } |
168 | 168 |
169 QPointer<terminal_dock_widget> | 169 QPointer<terminal_dock_widget> |
170 terminal_widget (main_window *mw = nullptr); | 170 terminal_widget (main_window *mw = nullptr); |
171 | 171 |
172 QPointer<documentation_dock_widget> | 172 QPointer<documentation_dock_widget> |
173 documentation_widget (main_window *mw = nullptr); | 173 documentation_widget (main_window *mw = nullptr); |
174 | 174 |
175 QPointer<files_dock_widget> | 175 QPointer<files_dock_widget> |
176 file_browser_widget (main_window *mw = nullptr); | 176 file_browser_widget (main_window *mw = nullptr); |
177 | 177 |
178 QPointer<history_dock_widget> | 178 QPointer<history_dock_widget> |
179 history_widget (main_window *mw = nullptr); | 179 history_widget (main_window *mw = nullptr); |
180 | 180 |
181 QPointer<workspace_view> | 181 QPointer<workspace_view> |
182 workspace_widget (main_window *mw = nullptr); | 182 workspace_widget (main_window *mw = nullptr); |
183 | 183 |
184 // FIXME: The file_editor_interface needs to be a proper generic | 184 // FIXME: The file_editor_interface needs to be a proper generic |
185 // interface for all editors (internal and external) for this to | 185 // interface for all editors (internal and external) for this to |
186 // work properly. | 186 // work properly. |
187 QPointer<file_editor_interface> | 187 QPointer<file_editor_interface> |
188 editor_widget (main_window *mw = nullptr); | 188 editor_widget (main_window *mw = nullptr); |
189 | 189 |
190 QPointer<variable_editor> | 190 QPointer<variable_editor> |
191 variable_editor_widget (main_window *mw = nullptr); | 191 variable_editor_widget (main_window *mw = nullptr); |
192 | 192 |
193 QPointer<community_news> community_news_widget (int serial = -1); | 193 QPointer<community_news> community_news_widget (int serial = -1); |
194 | 194 |
195 QPointer<release_notes> release_notes_widget (void); | 195 QPointer<release_notes> release_notes_widget (void); |
196 | 196 |
197 QThread * main_thread (void) { return m_main_thread; } | 197 QThread * main_thread (void) { return m_main_thread; } |
198 | 198 |
199 // Declared virtual so that a derived class may redefine this | 199 // Declared virtual so that a derived class may redefine this |
200 // method. | 200 // method. |
201 | 201 |
202 virtual bool confirm_shutdown (void); | 202 virtual bool confirm_shutdown (void); |
203 | 203 |
204 bool is_gui_app (void) const { return m_gui_app; } | 204 bool is_gui_app (void) const { return m_gui_app; } |
205 | 205 |
206 template <typename T> void connect_interpreter_events (T *widget) | 206 template <typename T> void connect_interpreter_events (T *widget) |
207 { | 207 { |
208 connect (widget, QOverload<const fcn_callback&>::of (&T::interpreter_event), | 208 connect (widget, QOverload<const fcn_callback&>::of (&T::interpreter_event), |
209 this, QOverload<const fcn_callback&>::of (&base_qobject::interpreter_event)); | 209 this, QOverload<const fcn_callback&>::of (&base_qobject::interpreter_event)); |
210 | 210 |
211 connect (widget, QOverload<const meth_callback&>::of (&T::interpreter_event), | 211 connect (widget, QOverload<const meth_callback&>::of (&T::interpreter_event), |
212 this, QOverload<const meth_callback&>::of (&base_qobject::interpreter_event)); | 212 this, QOverload<const meth_callback&>::of (&base_qobject::interpreter_event)); |
213 } | 213 } |
214 | 214 |
215 public slots: | 215 public slots: |
216 | 216 |
217 void execute_command (const QString& command); | 217 void execute_command (const QString& command); |
218 | 218 |
219 // Note: START_GUI and CLOSE_GUI don't currently perform any work | 219 // Note: START_GUI and CLOSE_GUI don't currently perform any work |
220 // with the old terminal widget. | 220 // with the old terminal widget. |
221 void start_gui (bool gui_app); | 221 void start_gui (bool gui_app); |
222 void close_gui (void); | 222 void close_gui (void); |
223 | 223 |
224 void show_terminal_window (void); | 224 void show_terminal_window (void); |
225 | 225 |
226 void show_documentation_window (const QString& file); | 226 void show_documentation_window (const QString& file); |
227 | 227 |
228 void show_file_browser_window (void); | 228 void show_file_browser_window (void); |
229 | 229 |
230 void show_command_history_window (void); | 230 void show_command_history_window (void); |
231 | 231 |
232 void show_workspace_window (void); | 232 void show_workspace_window (void); |
233 | 233 |
234 void show_variable_editor_window (const QString& name, | 234 void show_variable_editor_window (const QString& name, |
235 const octave_value& value); | 235 const octave_value& value); |
236 | 236 |
237 void handle_variable_editor_update (void); | 237 void handle_variable_editor_update (void); |
238 | 238 |
239 void show_community_news (int serial); | 239 void show_community_news (int serial); |
240 | 240 |
241 void show_release_notes (void); | 241 void show_release_notes (void); |
242 | 242 |
243 void interpreter_ready (void); | 243 void interpreter_ready (void); |
244 | 244 |
245 void interpreter_event (const fcn_callback& fcn); | 245 void interpreter_event (const fcn_callback& fcn); |
246 | 246 |
247 void interpreter_event (const meth_callback& meth); | 247 void interpreter_event (const meth_callback& meth); |
248 | 248 |
249 void interpreter_interrupt (void); | 249 void interpreter_interrupt (void); |
250 | 250 |
251 // Note: these currently only work with the new experimental | 251 // Note: these currently only work with the new experimental |
252 // terminal widget. | 252 // terminal widget. |
253 void interpreter_pause (void); | 253 void interpreter_pause (void); |
254 void interpreter_stop (void); | 254 void interpreter_stop (void); |
255 void interpreter_resume (void); | 255 void interpreter_resume (void); |
256 | 256 |
257 void copy_image_to_clipboard (const QString& file, bool remove_file); | 257 void copy_image_to_clipboard (const QString& file, bool remove_file); |
258 | 258 |
259 protected: | 259 protected: |
260 | 260 |
261 qt_application& m_app_context; | 261 qt_application& m_app_context; |
262 | 262 |
263 // Use these to ensure that argc and argv exist for as long as the | 263 // Use these to ensure that argc and argv exist for as long as the |
264 // QApplication object. | 264 // QApplication object. |
265 | 265 |
266 int m_argc; | 266 int m_argc; |
267 char **m_argv; | 267 char **m_argv; |
268 | 268 |
269 octave_qapplication *m_qapplication; | 269 octave_qapplication *m_qapplication; |
270 | 270 |
271 resource_manager m_resource_manager; | 271 resource_manager m_resource_manager; |
272 | 272 |
273 shortcut_manager m_shortcut_manager; | 273 shortcut_manager m_shortcut_manager; |
274 | 274 |
275 QTranslator *m_qt_tr; | 275 QTranslator *m_qt_tr; |
276 QTranslator *m_gui_tr; | 276 QTranslator *m_gui_tr; |
277 QTranslator *m_qsci_tr; | 277 QTranslator *m_qsci_tr; |
278 | 278 |
279 bool m_translators_installed; | 279 bool m_translators_installed; |
280 | 280 |
281 std::shared_ptr<qt_interpreter_events> m_qt_interpreter_events; | 281 std::shared_ptr<qt_interpreter_events> m_qt_interpreter_events; |
282 | 282 |
283 interpreter_qobject *m_interpreter_qobj; | 283 interpreter_qobject *m_interpreter_qobj; |
284 | 284 |
285 QThread *m_main_thread; | 285 QThread *m_main_thread; |
286 | 286 |
287 bool m_gui_app; | 287 bool m_gui_app; |
288 | 288 |
289 bool m_interpreter_ready; | 289 bool m_interpreter_ready; |
290 | 290 |
291 workspace_model *m_workspace_model; | 291 workspace_model *m_workspace_model; |
292 | 292 |
293 // Dock widgets that may be used from the command line. They are | 293 // Dock widgets that may be used from the command line. They are |
294 // adopted by the desktop (main window) if it is also started from | 294 // adopted by the desktop (main window) if it is also started from |
295 // the command line. | 295 // the command line. |
296 | 296 |
297 QPointer<terminal_dock_widget> m_terminal_widget; | 297 QPointer<terminal_dock_widget> m_terminal_widget; |
298 | 298 |
299 QPointer<documentation_dock_widget> m_documentation_widget; | 299 QPointer<documentation_dock_widget> m_documentation_widget; |
300 | 300 |
301 QPointer<files_dock_widget> m_file_browser_widget; | 301 QPointer<files_dock_widget> m_file_browser_widget; |
302 | 302 |
303 QPointer<history_dock_widget> m_history_widget; | 303 QPointer<history_dock_widget> m_history_widget; |
304 | 304 |
305 QPointer<workspace_view> m_workspace_widget; | 305 QPointer<workspace_view> m_workspace_widget; |
306 | 306 |
307 QPointer<file_editor_interface> m_editor_widget; | 307 QPointer<file_editor_interface> m_editor_widget; |
308 | 308 |
309 QPointer<variable_editor> m_variable_editor_widget; | 309 QPointer<variable_editor> m_variable_editor_widget; |
310 | 310 |
311 QPointer<community_news> m_community_news; | 311 QPointer<community_news> m_community_news; |
312 | 312 |
313 QPointer<release_notes> m_release_notes; | 313 QPointer<release_notes> m_release_notes; |
314 | 314 |
315 main_window *m_main_window; | 315 main_window *m_main_window; |
316 }; | 316 }; |
317 | 317 |
318 OCTAVE_END_NAMESPACE(octave) | 318 OCTAVE_END_NAMESPACE(octave) |
319 | 319 |
320 #endif | 320 #endif |