26 #if defined (HAVE_CONFIG_H)
32 #include <QApplication>
38 #include <QTranslator>
43 #if defined (HAVE_QSCINTILLA)
64 #if defined (Q_OS_MAC)
65 # include <objc/runtime.h>
66 # include <objc/message.h>
76 #if defined (Q_OS_MAC)
77 static void disable_app_nap (
void)
79 Class process_info_class;
80 SEL process_info_selector;
81 SEL begin_activity_with_options_selector;
84 id osx_latencycritical_activity;
87 unsigned long long NSActivityUserInitiatedAllowingIdleSystemSleep = 0x00FFFFFFULL;
88 unsigned long long NSActivityLatencyCritical = 0xFF00000000ULL;
91 process_info_class =
reinterpret_cast<Class
> (objc_getClass (
"NSProcessInfo"));
92 if (process_info_class == nil)
95 process_info_selector = sel_getUid (
"processInfo");
96 if (class_getClassMethod (process_info_class, process_info_selector)
100 begin_activity_with_options_selector = sel_getUid (
"beginActivityWithOptions:reason:");
101 if (class_getInstanceMethod (process_info_class,
102 begin_activity_with_options_selector)
106 process_info =
reinterpret_cast<id (*) (
id,
SEL)
> (objc_msgSend)
107 (
reinterpret_cast<id> (process_info_class),
108 process_info_selector);
109 if (process_info == nil)
112 reason_string =
reinterpret_cast<id (*) (
id,
SEL)
> (objc_msgSend)
113 (
reinterpret_cast<id> (objc_getClass (
"NSString")),
114 sel_getUid (
"alloc"));
115 reason_string =
reinterpret_cast<id (*) (
id,
SEL,
const char *)
> (objc_msgSend)
116 (reason_string, sel_getUid (
"initWithUTF8String:"),
117 "App Nap causes pause() malfunction");
122 osx_latencycritical_activity =
123 reinterpret_cast<id (*) (
id,
SEL,
unsigned long long,
id)
> (objc_msgSend)
125 begin_activity_with_options_selector,
126 NSActivityUserInitiatedAllowingIdleSystemSleep
127 | NSActivityLatencyCritical,
147 return QApplication::notify (receiver, ev);
173 m_app_context (app_context),
174 m_argc (m_app_context.sys_argc ()),
175 m_argv (m_app_context.sys_argv ()),
177 m_resource_manager (),
178 m_shortcut_manager (*this),
179 m_qt_tr (new QTranslator ()),
180 m_gui_tr (new QTranslator ()),
181 m_qsci_tr (new QTranslator ()),
182 m_translators_installed (false),
185 m_main_thread (new
QThread ()),
187 m_interpreter_ready (false),
189 m_documentation_widget (),
190 m_file_browser_widget (),
192 m_workspace_widget (),
194 m_variable_editor_widget (),
195 m_main_window (nullptr)
197 std::string show_gui_msgs =
198 sys::env::getenv (
"OCTAVE_SHOW_GUI_MESSAGES");
202 if (show_gui_msgs.empty ())
206 #if ! defined (Q_OS_WIN32)
207 QTextCodec::setCodecForLocale (QTextCodec::codecForName (
"UTF-8"));
212 QCoreApplication::setApplicationName (
"GNU Octave");
217 qRegisterMetaType<octave_value_list> (
"octave_value_list");
220 #if defined (Q_OS_MAC)
233 Qt::QueuedConnection);
427 #if defined (Q_OS_MAC)
429 fprintf (stderr,
"\n");
450 QPointer<terminal_dock_widget>
464 #if defined (HAVE_QSCINTILLA)
502 QPointer<documentation_dock_widget>
529 QPointer<files_dock_widget>
547 QPointer<history_dock_widget>
582 QPointer<workspace_view>
608 [=] (
const QString& var_name) {
619 std::ostringstream buf;
625 QClipboard *clipboard = QApplication::clipboard ();
631 [=] (
const QString& old_name,
const QString& new_name) {
640 scope.
rename (old_name.toStdString (),
641 new_name.toStdString ());
656 [=] (
const QString& var_name) {
661 std::string name = var_name.toStdString ();
683 QPointer<file_editor_interface>
699 QPointer<variable_editor>
804 if (! widget->isVisible ())
819 if (! widget->isVisible ())
831 if (! widget->isVisible ())
843 if (! widget->isVisible ())
855 if (! widget->isVisible ())
869 if (! widget->isVisible ())
929 interp.
eval (command.toStdString (), 0);
953 interp.
quit (0,
false,
false);
1025 QClipboard *clipboard = QApplication::clipboard ();
1035 clipboard->setImage (img);
1038 QFile::remove (file);
void interrupt_signal(void)
cmdline_options options(void) const
bool experimental_terminal_widget(void) const
QPointer< files_dock_widget > m_file_browser_widget
QPointer< history_dock_widget > history_widget(main_window *mw=nullptr)
void interpreter_pause(void)
void show_variable_editor_window(const QString &name, const octave_value &value)
workspace_model * m_workspace_model
resource_manager m_resource_manager
QPointer< files_dock_widget > file_browser_widget(main_window *mw=nullptr)
void show_release_notes(void)
QPointer< community_news > community_news_widget(int serial=-1)
void connect_interpreter_events(T *widget)
void interpreter_ready(void)
void show_file_browser_window(void)
void execute_command(const QString &command)
virtual bool confirm_shutdown(void)
void interpreter_resume(void)
void copy_image_to_clipboard(const QString &file, bool remove_file)
QPointer< documentation_dock_widget > m_documentation_widget
void show_workspace_window(void)
bool experimental_terminal_widget(void) const
void handle_variable_editor_update(void)
bool gui_running(void) const
qt_application & m_app_context
QPointer< workspace_view > m_workspace_widget
main_window * m_main_window
qt_interpreter_events * qt_link(void)
QPointer< file_editor_interface > m_editor_widget
octave_qapplication * m_qapplication
void interpreter_interrupt(void)
void interpreter_stop(void)
void show_command_history_window(void)
QPointer< variable_editor > variable_editor_widget(main_window *mw=nullptr)
shortcut_manager m_shortcut_manager
void show_documentation_window(const QString &file)
void interpreter_event(const fcn_callback &fcn)
void show_community_news(int serial)
bool m_translators_installed
QPointer< file_editor_interface > editor_widget(main_window *mw=nullptr)
base_qobject(qt_application &app_context, bool gui_app=false)
QPointer< variable_editor > m_variable_editor_widget
QPointer< terminal_dock_widget > terminal_widget(main_window *mw=nullptr)
void show_terminal_window(void)
void start_main_thread(void)
QPointer< history_dock_widget > m_history_widget
void start_gui(bool gui_app)
interpreter_qobject * m_interpreter_qobj
void config_translators(void)
QPointer< release_notes > release_notes_widget(void)
QPointer< community_news > m_community_news
QPointer< workspace_view > workspace_widget(main_window *mw=nullptr)
QPointer< terminal_dock_widget > m_terminal_widget
QPointer< documentation_dock_widget > documentation_widget(main_window *mw=nullptr)
QPointer< release_notes > m_release_notes
Provides threadsafe access to octave.
bool edit_variable(const std::string &name, const octave_value &val)
OCTINTERP_API void set_workspace(void)
OCTINTERP_API void set_history(void)
void set_history(const QStringList &hist)
void append_history(const QString &hist_entry)
void interpreter_event(const fcn_callback &fcn)
void shutdown_finished(int)
octave_value varval(const std::string &name) const
event_manager & get_event_manager(void)
void quit(int exit_status, bool force=false, bool confirm=true)
application * get_app_context(void)
octave_value_list eval(const std::string &try_code, int nargout)
tree_evaluator & get_evaluator(void)
symbol_scope get_current_scope(void) const
Represents the main window.
void focus_window(const QString &win_name)
void close_gui_signal(void)
void show_community_news_signal(int serial)
bool confirm_shutdown(void)
void show_release_notes_signal(void)
void handle_octave_ready()
This class is a simple wrapper around QApplication so that we can reimplement QApplication::notify.
virtual bool notify(QObject *receiver, QEvent *e) override
Reimplement QApplication::notify.
void interpreter_event(const fcn_callback &fcn)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
bool is_undefined(void) const
This class inherits from the pure-virtual base class application and provides an implementation of th...
bool gui_running(void) const
void focus_window_signal(const QString &win_name)
void show_file_browser_signal(void)
void close_gui_signal(void)
void unregister_documentation_signal(const QString &file)
void set_workspace_signal(bool top_level, bool debug, const symbol_info_list &syminfo)
void interpreter_output_signal(const QString &msg)
void directory_changed_signal(const QString &dir)
void register_documentation_signal(const QString &file)
void clear_workspace_signal(void)
void set_history_signal(const QStringList &hist)
void copy_image_to_clipboard_signal(const QString &file, bool remove_file)
void new_command_line_signal(const QString &msg=QString())
void append_history_signal(const QString &hist_entry)
void edit_variable_signal(const QString &name, const octave_value &val)
void show_terminal_window_signal(void)
void show_command_history_signal(void)
void clear_history_signal(void)
void refresh_variable_editor_signal(void)
void update_prompt_signal(const QString &prompt)
void show_release_notes_signal(void)
void show_community_news_signal(int serial)
void show_workspace_signal(void)
void start_gui_signal(bool gui_app)
void show_documentation_signal(const QString &file)
void config_translators(QTranslator *qt_tr, QTranslator *qsci_tr, QTranslator *gui_tr)
void config_icon_theme(void)
void reload_settings(void)
static void delete_c_str_vec(const char *const *)
void rename(const std::string &old_name, const std::string &new_name)
symbol_info_list get_symbol_info(void)
void command_signal(const QString &cmd)
void edit_variable(const QString &name, const octave_value &val)
void clear_workspace(void)
void set_workspace(bool top_level, bool debug, const symbol_info_list &syminfo)
void rename_variable_signal(const QString &, const QString &)
Signal that user wants to rename a variable.
void edit_variable_signal(const QString &)
Signal that user wants to edit a variable.
void copy_variable_value_to_clipboard(const QString &)
Signal that user wnats to copy a variable value to the clipboard.
void handle_model_changed(void)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
std::function< void(void)> fcn_callback
std::function< void(interpreter &)> meth_callback
QString fromStdString(const std::string &s)
static void message_handler(QtMsgType, const QMessageLogContext &, const QString &)