26 #if defined (HAVE_CONFIG_H)
32 #include <QApplication>
38 #include <QTranslator>
49 #if defined (Q_OS_MAC)
50 # include <objc/runtime.h>
51 # include <objc/message.h>
61 #if defined (Q_OS_MAC)
62 static void disable_app_nap (
void)
64 Class process_info_class;
65 SEL process_info_selector;
66 SEL begin_activity_with_options_selector;
69 id osx_latencycritical_activity;
72 unsigned long long NSActivityUserInitiatedAllowingIdleSystemSleep = 0x00FFFFFFULL;
73 unsigned long long NSActivityLatencyCritical = 0xFF00000000ULL;
76 process_info_class =
static_cast<Class
> (objc_getClass (
"NSProcessInfo"));
77 if (process_info_class == nil)
80 process_info_selector = sel_getUid (
"processInfo");
81 if (class_getClassMethod (process_info_class, process_info_selector)
85 begin_activity_with_options_selector = sel_getUid (
"beginActivityWithOptions:reason:");
86 if (class_getInstanceMethod (process_info_class,
87 begin_activity_with_options_selector)
91 process_info =
reinterpret_cast<id (*) (
id,
SEL)
> (objc_msgSend)
92 (
reinterpret_cast<id> (process_info_class),
93 process_info_selector);
94 if (process_info == nil)
97 reason_string =
reinterpret_cast<id (*) (
id,
SEL)
> (objc_msgSend)
98 (
reinterpret_cast<id> (objc_getClass (
"NSString")),
99 sel_getUid (
"alloc"));
100 reason_string =
reinterpret_cast<id (*) (
id,
SEL,
const char *)
> (objc_msgSend)
101 (reason_string, sel_getUid (
"initWithUTF8String:"),
102 "App Nap causes pause() malfunction");
107 osx_latencycritical_activity =
108 reinterpret_cast<id (*) (
id,
SEL,
unsigned long long,
id)
> (objc_msgSend)
110 begin_activity_with_options_selector,
111 NSActivityUserInitiatedAllowingIdleSystemSleep
112 | NSActivityLatencyCritical,
122 #if defined (QTMESSAGEHANDLER_ACCEPTS_QMESSAGELOGCONTEXT)
123 message_handler (QtMsgType,
const QMessageLogContext &,
const QString &)
136 return QApplication::notify (receiver, ev);
162 :
QObject (), m_app_context (app_context),
163 m_argc (m_app_context.sys_argc ()),
164 m_argv (m_app_context.sys_argv ()),
166 m_resource_manager (), m_shortcut_manager (*this),
167 m_qt_tr (new QTranslator ()), m_gui_tr (new QTranslator ()),
168 m_qsci_tr (new QTranslator ()), m_translators_installed (false),
173 std::string show_gui_msgs =
178 if (show_gui_msgs.empty ())
180 #if defined (HAVE_QINSTALLMESSAGEHANDLER)
188 #if ! defined (Q_OS_WIN32)
189 QTextCodec::setCodecForLocale (QTextCodec::codecForName (
"UTF-8"));
192 #if defined (HAVE_QT4)
193 QTextCodec::setCodecForCStrings (QTextCodec::codecForName (
"UTF-8"));
198 QCoreApplication::setApplicationName (
"GNU Octave");
203 qRegisterMetaType<octave_value_list> (
"octave_value_list");
207 #if defined (Q_OS_MAC)
238 SIGNAL (copy_image_to_clipboard_signal (
const QString&,
bool)),
299 #if defined (Q_OS_MAC)
301 fprintf (stderr,
"\n");
307 qApp->exit (exit_status);
337 QClipboard *clipboard = QApplication::clipboard ();
347 clipboard->setImage (img);
350 QFile::remove (file);
374 SIGNAL (focus_window_signal (
const QString&)),
Base class for Octave interfaces that use Qt.
void copy_image_to_clipboard(const QString &file, bool remove_file)
void handle_interpreter_execution_finished(int)
interpreter_qobject * m_interpreter_qobj
qt_interpreter_events * qt_link(void)
qt_application & m_app_context
bool m_translators_installed
base_qobject(qt_application &app_context)
void start_main_thread(void)
resource_manager m_resource_manager
void request_interpreter_shutdown(int)
void handle_interpreter_shutdown_finished(int)
virtual bool confirm_shutdown(void)
octave_qapplication * m_qapplication
void config_translators(void)
void interpreter_event(const fcn_callback &fcn)
cli_qobject(qt_application &app_context)
bool confirm_shutdown(void)
main_window * m_main_window
gui_qobject(qt_application &app_context)
void interpreter_event(const fcn_callback &fcn)
Represents the main window.
bool confirm_shutdown(void)
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)
This class inherits from the pure-virtual base class octave::application and provides an implementati...
bool gui_running(void) const
void config_translators(QTranslator *qt_tr, QTranslator *qsci_tr, QTranslator *gui_tr)
void reload_settings(void)
static std::string getenv(const std::string &name)
static void delete_c_str_vec(const char *const *)
std::function< void(octave::interpreter &)> meth_callback
static void message_handler(QtMsgType, const char *)
std::function< void(void)> fcn_callback