Mercurial > octave
comparison libgui/src/main-window.cc @ 22089:c2c668b3051b
use classes for octave application and interpreter
* main-cli.cc (main): Simplify using class objects.
* main-gui.cc (main): Likeiwse.
* octave.h, octave.cc (octave::cmdline_options, octave::application,
octave::cli_application, octave::embedded_application,
octave::interpreter): New classes. Replace ordinary functions and
static/global data with objects. Access global application data
through application object.
* octave-gui.h, octave-gui.cc (octave::gui_application): New class.
Replace ordinary functions and static/global data with objects.
* main-window.cc (main_window::m_app_context): New data member.
(main_window::main_window): Pass application object instead of
start_gui flag.
(main_window::construct_octave_qt_link): Pass m_app_context to
octave_qt_link constructor.
* octave-interpreter.h, octave-interpreter.cc
(octave_interpreter::m_app_context,
octave_interpreter::m_exit_status): New data members.
(octave_interpreter::execute): Use class object to start interpreter.
Save exit status.
* octave-qt-link.h, octave-qt-link.cc (octave_qt_link::m_app_context):
New data member.
(octave_qt_link::do_set_default_prompts): Make prompt settings
conditional on whether the GUI is running.
* input.h, input.cc (interactive, forced_interactive):
Delete global data.
* dirfns.cc, error.cc, input.cc, oct-stream.cc, pager.cc,
sighandlers.cc, sysdep.cc, toplev.cc, lex.ll: Access interactive and
forced_interactive through global application object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 10 Jul 2016 07:15:21 -0400 |
parents | 278fc29b69ca |
children | 6e9f5408c0db |
comparison
equal
deleted
inserted
replaced
22088:c3823cb0ea02 | 22089:c2c668b3051b |
---|---|
58 #include "cmd-edit.h" | 58 #include "cmd-edit.h" |
59 #include "url-transfer.h" | 59 #include "url-transfer.h" |
60 | 60 |
61 #include "builtin-defun-decls.h" | 61 #include "builtin-defun-decls.h" |
62 #include "defaults.h" | 62 #include "defaults.h" |
63 #include "octave.h" | |
63 #include "symtab.h" | 64 #include "symtab.h" |
64 #include "version.h" | 65 #include "version.h" |
65 #include "utils.h" | 66 #include "utils.h" |
66 | 67 |
67 static file_editor_interface * | 68 static file_editor_interface * |
72 #else | 73 #else |
73 return 0; | 74 return 0; |
74 #endif | 75 #endif |
75 } | 76 } |
76 | 77 |
77 main_window::main_window (QWidget *p, bool start_gui) | 78 main_window::main_window (QWidget *p, octave::gui_application *app_context) |
78 : QMainWindow (p), | 79 : QMainWindow (p), m_app_context (app_context), _workspace_model (0), |
79 _workspace_model (start_gui ? new workspace_model () : 0), | 80 status_bar (0), command_window (0), history_window (0), |
80 status_bar (start_gui ? new QStatusBar () : 0), | 81 file_browser_window (0), doc_browser_window (0), editor_window (0), |
81 command_window (start_gui ? new terminal_dock_widget (this) : 0), | 82 workspace_window (0), _settings_dlg (0), find_files_dlg (0), |
82 history_window (start_gui ? new history_dock_widget (this) : 0), | 83 release_notes_window (0), community_news_window (0), _octave_qt_link (0), |
83 file_browser_window (start_gui ? new files_dock_widget (this) : 0), | |
84 doc_browser_window (start_gui ? new documentation_dock_widget (this) : 0), | |
85 editor_window (start_gui ? create_default_editor (this) : 0), | |
86 workspace_window (start_gui ? new workspace_view (this) : 0), | |
87 _settings_dlg (0), | |
88 find_files_dlg (0), | |
89 release_notes_window (0), | |
90 community_news_window (0), | |
91 _octave_qt_link (0), | |
92 _clipboard (QApplication::clipboard ()), | 84 _clipboard (QApplication::clipboard ()), |
93 _prevent_readline_conflicts (true), | 85 _prevent_readline_conflicts (true), |
94 _suppress_dbg_location (true), | 86 _suppress_dbg_location (true), |
95 _start_gui (start_gui) | 87 _start_gui (app_context && app_context->start_gui_p ()) |
96 { | 88 { |
89 if (_start_gui) | |
90 { | |
91 _workspace_model = new workspace_model (); | |
92 status_bar = new QStatusBar (); | |
93 command_window = new terminal_dock_widget (this); | |
94 history_window = new history_dock_widget (this); | |
95 file_browser_window = new files_dock_widget (this); | |
96 doc_browser_window = new documentation_dock_widget (this); | |
97 editor_window = create_default_editor (this); | |
98 workspace_window = new workspace_view (this); | |
99 } | |
100 | |
97 QSettings *settings = resource_manager::get_settings (); | 101 QSettings *settings = resource_manager::get_settings (); |
98 | 102 |
99 bool connect_to_web = true; | 103 bool connect_to_web = true; |
100 QDateTime last_checked; | 104 QDateTime last_checked; |
101 int serial = 0; | 105 int serial = 0; |
113 } | 117 } |
114 | 118 |
115 QDateTime current = QDateTime::currentDateTime (); | 119 QDateTime current = QDateTime::currentDateTime (); |
116 QDateTime one_day_ago = current.addDays (-1); | 120 QDateTime one_day_ago = current.addDays (-1); |
117 | 121 |
118 if (start_gui && connect_to_web | 122 if (_start_gui && connect_to_web |
119 && (! last_checked.isValid () || one_day_ago > last_checked)) | 123 && (! last_checked.isValid () || one_day_ago > last_checked)) |
120 load_and_display_community_news (serial); | 124 load_and_display_community_news (serial); |
121 | 125 |
122 // We have to set up all our windows, before we finally launch octave. | 126 // We have to set up all our windows, before we finally launch octave. |
123 construct (); | 127 construct (); |
1477 } | 1481 } |
1478 | 1482 |
1479 void | 1483 void |
1480 main_window::construct_octave_qt_link (void) | 1484 main_window::construct_octave_qt_link (void) |
1481 { | 1485 { |
1482 _octave_qt_link = new octave_qt_link (this); | 1486 _octave_qt_link = new octave_qt_link (this, m_app_context); |
1483 | 1487 |
1484 connect (_octave_qt_link, SIGNAL (exit_app_signal (int)), | 1488 connect (_octave_qt_link, SIGNAL (exit_app_signal (int)), |
1485 this, SLOT (exit_app (int))); | 1489 this, SLOT (exit_app (int))); |
1486 | 1490 |
1487 connect (_octave_qt_link, SIGNAL (confirm_shutdown_signal ()), | 1491 connect (_octave_qt_link, SIGNAL (confirm_shutdown_signal ()), |