Mercurial > octave
annotate libgui/src/octave-gui.cc @ 23460:b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
* libinterp/corefcn/interpreter.cc (interpreter::interpreter):
Move calls to systep_init and install_defaults from here to
application initialization.
* libgui/octave-gui.cc (gui_application::gui_application):
Call systep_init and install_defaults here.
* libinterp/octave.cc (application::init):
Call systep_init and install_defaults here.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 02 May 2017 17:18:02 -0400 |
parents | 092078913d54 |
children | 5cb3a2bb5e1e |
rev | line source |
---|---|
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
1 /* |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
2 |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 2011-2017 Jacob Dawid |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
4 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
5 This file is part of Octave. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
6 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22677
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22677
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22677
diff
changeset
|
10 (at your option) any later version. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22677
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22677
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22677
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22677
diff
changeset
|
15 GNU General Public License for more details. |
15204
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
16 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
20 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
21 */ |
13501 | 22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21482
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
25 #endif |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
26 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
27 #include <QApplication> |
17647
7ec70c575ad6
* octave-gui.cc: set the encoding of qt strings to utf8
Torsten <ttl@justmail.de>
parents:
17569
diff
changeset
|
28 #include <QTextCodec> |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
29 #include <QThread> |
13501 | 30 #include <QTranslator> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
31 #include <QtGlobal> |
22611
95aff68c443d
gui: style fixes for pushbutton, radiobutton and checkbox (Bug #49247)
John D
parents:
22413
diff
changeset
|
32 #include <QStyleFactory> |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
33 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
34 #include <cstdio> |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
35 |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
36 #include <iostream> |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
37 |
16597
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
38 #if defined (HAVE_SYS_IOCTL_H) |
21203
710e700cdd7f
maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents:
20671
diff
changeset
|
39 # include <sys/ioctl.h> |
16597
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
40 #endif |
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
41 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15209
diff
changeset
|
42 #include "lo-utils.h" |
15597
9046ee786fe1
Use octave_env instead of setenv.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15425
diff
changeset
|
43 #include "oct-env.h" |
17569
9d0992c6df30
arrange to pass signals to the GUI subprocess
John W. Eaton <jwe@octave.org>
parents:
17568
diff
changeset
|
44 #include "oct-syscalls.h" |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
45 |
19868
c7c50030e76c
allow qt graphics toolkit to be used in --no-gui mode (bug #44116)
Stefan Mahr <dac922@gmx.de>
parents:
19861
diff
changeset
|
46 #include "builtin-defun-decls.h" |
23460
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
47 #include "defaults.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
48 #include "display.h" |
21374
1487a68a496a
untangle configuration of OpenGL, FLTK, and Qt (bug #47263)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
49 #if defined (HAVE_QT_GRAPHICS) |
1487a68a496a
untangle configuration of OpenGL, FLTK, and Qt (bug #47263)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
50 # include "__init_qt__.h" |
1487a68a496a
untangle configuration of OpenGL, FLTK, and Qt (bug #47263)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
51 #endif |
22088
c3823cb0ea02
eliminate unused class definition
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
52 #include "octave.h" |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22157
diff
changeset
|
53 #include "sysdep.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
54 #include "unistd-wrappers.h" |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
55 |
22088
c3823cb0ea02
eliminate unused class definition
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
56 #include "main-window.h" |
c3823cb0ea02
eliminate unused class definition
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
57 #include "octave-gui.h" |
c3823cb0ea02
eliminate unused class definition
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
58 #include "resource-manager.h" |
c3823cb0ea02
eliminate unused class definition
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
59 #include "shortcut-manager.h" |
c3823cb0ea02
eliminate unused class definition
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
60 #include "thread-manager.h" |
c3823cb0ea02
eliminate unused class definition
John W. Eaton <jwe@octave.org>
parents:
21979
diff
changeset
|
61 #include "welcome-wizard.h" |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
62 |
18618
c644cfa9cb3b
suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents:
18569
diff
changeset
|
63 // Disable all Qt messages by default. |
17737
d3bb7f1e3971
prevent the editor's file watcher from signaling fasle alarms (bug #40312)
Torsten <ttl@justmail.de>
parents:
17647
diff
changeset
|
64 |
18618
c644cfa9cb3b
suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents:
18569
diff
changeset
|
65 static void |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
66 #if defined (HAVE_QT4) |
19614
4c3ea57905fd
eliminate unused variable warnings in libgui
John W. Eaton <jwe@octave.org>
parents:
19594
diff
changeset
|
67 message_handler (QtMsgType, const char *) |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
68 #else |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
69 message_handler (QtMsgType, const QMessageLogContext &, const QString &) |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
70 #endif |
22413
8758addcf265
maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents:
22411
diff
changeset
|
71 { } |
17737
d3bb7f1e3971
prevent the editor's file watcher from signaling fasle alarms (bug #40312)
Torsten <ttl@justmail.de>
parents:
17647
diff
changeset
|
72 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
73 namespace octave |
13501 | 74 { |
23460
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
75 gui_application::gui_application (int argc, char **argv) |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
76 : application (argc, argv), m_argc (argc), m_argv (argv), |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
77 m_gui_running (false) |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
78 { |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
79 // This should probably happen early. |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
80 sysdep_init (); |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
81 |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
82 // Need to have global Vfoo variables defined early. |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
83 install_defaults (); |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
84 } |
b605146ed2ed
do sysdep init and init global vars in app, not interpreter (bug #50880)
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
85 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
86 bool gui_application::start_gui_p (void) const |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
87 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
88 if (m_options.no_window_system ()) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
89 return false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
90 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
91 std::string err_msg; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
92 if (! display_info::display_available (err_msg)) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
93 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
94 if (! (m_options.inhibit_startup_message () || err_msg.empty ())) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
95 warning (err_msg.c_str ()); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
96 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
97 return false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
98 } |
17922
b5bf26a054bd
interrupt interpreter thread in GUI instead of calling "raise (SIGINT)"
John W. Eaton <jwe@octave.org>
parents:
17804
diff
changeset
|
99 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
100 if (! m_options.line_editing ()) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
101 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
102 if (! (m_options.inhibit_startup_message () |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
103 || m_options.no_gui ())) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
104 warning ("--no-line-editing option given, disabling GUI"); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
105 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
106 return false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
107 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
108 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
109 if (m_options.force_gui ()) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
110 return true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
111 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
112 if (m_options.no_gui ()) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
113 return false; |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
114 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
115 if (m_options.persist ()) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
116 return true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
117 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
118 // If stdin is not a tty, then assume we are reading commands from a |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
119 // pipe or a redirected file and the GUI should not start. If this |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
120 // is not the case (for example, starting from a desktop "launcher" |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
121 // with no terminal) and you want to start the GUI, you may use the |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
122 // --force-gui option to start the GUI. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
123 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
124 if (! octave_isatty_wrapper (fileno (stdin))) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
125 return false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
126 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
127 // If we have code to eval or execute from a file, and we are going |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
128 // to exit immediately after executing it, don't start the gui. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
129 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
130 std::string code_to_eval = m_options.code_to_eval (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
131 if (! code_to_eval.empty () || m_have_script_file) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
132 return false; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
133 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
134 return true; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
135 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
136 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
137 int gui_application::execute (void) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
138 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
139 octave_thread_manager::block_interrupt_signal (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
140 |
22165
20e684ec108e
move system dependent code to sysdep.cc
John W. Eaton <jwe@octave.org>
parents:
22157
diff
changeset
|
141 set_application_id (); |
22153
bbaeaed0c584
set AppUserModelId for application in Windows (bug #47527)
John Donoghue
parents:
22089
diff
changeset
|
142 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
143 std::string show_gui_msgs = |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
144 octave::sys::env::getenv ("OCTAVE_SHOW_GUI_MESSAGES"); |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
145 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
146 // Installing our handler suppresses the messages. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
147 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
148 if (show_gui_msgs.empty ()) |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
149 { |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
150 #if defined (HAVE_QT4) |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
151 qInstallMsgHandler (message_handler); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
152 #else |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
153 qInstallMessageHandler (message_handler); |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
154 #endif |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
155 } |
14878
a6c44c28dabe
Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14804
diff
changeset
|
156 |
21374
1487a68a496a
untangle configuration of OpenGL, FLTK, and Qt (bug #47263)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
157 #if defined (HAVE_QT_GRAPHICS) |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
158 install___init_qt___functions (); |
19868
c7c50030e76c
allow qt graphics toolkit to be used in --no-gui mode (bug #44116)
Stefan Mahr <dac922@gmx.de>
parents:
19861
diff
changeset
|
159 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
160 Fregister_graphics_toolkit (ovl ("qt")); |
21374
1487a68a496a
untangle configuration of OpenGL, FLTK, and Qt (bug #47263)
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
161 #endif |
19868
c7c50030e76c
allow qt graphics toolkit to be used in --no-gui mode (bug #44116)
Stefan Mahr <dac922@gmx.de>
parents:
19861
diff
changeset
|
162 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
163 // If START_GUI is false, we still set up the QApplication so that |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
164 // we can use Qt widgets for plot windows. |
19949
857a8f018f53
set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents:
19868
diff
changeset
|
165 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
166 QApplication qt_app (m_argc, m_argv); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
167 QTranslator gui_tr, qt_tr, qsci_tr; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
168 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
169 // Set the codec for all strings (before wizard or any GUI object) |
19973 | 170 #if ! defined (Q_OS_WIN32) |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22165
diff
changeset
|
171 QTextCodec::setCodecForLocale (QTextCodec::codecForName ("UTF-8")); |
19949
857a8f018f53
set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents:
19868
diff
changeset
|
172 #endif |
857a8f018f53
set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents:
19868
diff
changeset
|
173 |
22677
f88de8f27259
fix text encoding in qt4 under Linux (bug #49118)
Hartmut Gimpel <hg_code@gmx.de>
parents:
22611
diff
changeset
|
174 #if defined (HAVE_QT4) |
f88de8f27259
fix text encoding in qt4 under Linux (bug #49118)
Hartmut Gimpel <hg_code@gmx.de>
parents:
22611
diff
changeset
|
175 QTextCodec::setCodecForCStrings (QTextCodec::codecForName ("UTF-8")); |
f88de8f27259
fix text encoding in qt4 under Linux (bug #49118)
Hartmut Gimpel <hg_code@gmx.de>
parents:
22611
diff
changeset
|
176 #endif |
f88de8f27259
fix text encoding in qt4 under Linux (bug #49118)
Hartmut Gimpel <hg_code@gmx.de>
parents:
22611
diff
changeset
|
177 |
22611
95aff68c443d
gui: style fixes for pushbutton, radiobutton and checkbox (Bug #49247)
John D
parents:
22413
diff
changeset
|
178 // set windows style for windows |
95aff68c443d
gui: style fixes for pushbutton, radiobutton and checkbox (Bug #49247)
John D
parents:
22413
diff
changeset
|
179 #if defined (Q_OS_WIN32) |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
180 qt_app.setStyle (QStyleFactory::create ("Windows")); |
22611
95aff68c443d
gui: style fixes for pushbutton, radiobutton and checkbox (Bug #49247)
John D
parents:
22413
diff
changeset
|
181 #endif |
95aff68c443d
gui: style fixes for pushbutton, radiobutton and checkbox (Bug #49247)
John D
parents:
22413
diff
changeset
|
182 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
183 bool start_gui = start_gui_p (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
184 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
185 // Show welcome wizard if this is the first run. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
186 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
187 if (resource_manager::is_first_run () && start_gui) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
188 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
189 // Before wizard. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
190 resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); |
20246
6fe746def1aa
Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19973
diff
changeset
|
191 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
192 qt_app.installTranslator (&qt_tr); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
193 qt_app.installTranslator (&gui_tr); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
194 qt_app.installTranslator (&qsci_tr); |
20246
6fe746def1aa
Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19973
diff
changeset
|
195 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
196 welcome_wizard welcomeWizard; |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
197 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
198 if (welcomeWizard.exec () == QDialog::Rejected) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
199 exit (1); |
20246
6fe746def1aa
Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19973
diff
changeset
|
200 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
201 // Install settings file. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
202 resource_manager::reload_settings (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
203 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
204 else |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
205 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
206 // Get settings file. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
207 resource_manager::reload_settings (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
208 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
209 // After settings. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
210 resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
211 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
212 qt_app.installTranslator (&qt_tr); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
213 qt_app.installTranslator (&gui_tr); |
20246
6fe746def1aa
Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19973
diff
changeset
|
214 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
215 if (start_gui) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
216 qt_app.installTranslator (&qsci_tr); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
217 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
218 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
219 if (start_gui) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
220 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
221 resource_manager::update_network_settings (); |
14878
a6c44c28dabe
Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents:
14804
diff
changeset
|
222 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
223 // We provide specific terminal capabilities, so ensure that |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
224 // TERM is always set appropriately. |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
225 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21941
diff
changeset
|
226 #if defined (OCTAVE_USE_WINDOWS_API) |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
227 octave::sys::env::putenv ("TERM", "cygwin"); |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
228 #else |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
229 octave::sys::env::putenv ("TERM", "xterm"); |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
230 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
231 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
232 shortcut_manager::init_data (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
233 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
18575
diff
changeset
|
234 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
235 // Force left-to-right alignment (see bug #46204) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
236 qt_app.setLayoutDirection (Qt::LeftToRight); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
237 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
238 // Create and show main window. |
20671
d29614aed16f
Force left-to-right alignment for the whole GUI (bug #46204)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20259
diff
changeset
|
239 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
240 main_window w (0, this); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
241 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
242 if (start_gui) |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
243 { |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
244 w.read_settings (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
245 |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
246 w.init_terminal_size (); |
20246
6fe746def1aa
Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19973
diff
changeset
|
247 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
248 // Connect signals for changes in visibility not before w |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
249 // is shown. |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
250 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
251 w.connect_visibility_changed (); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
252 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
253 w.focus_command_window (); |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
254 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
255 gui_running (true); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
256 } |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
257 else |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
258 qt_app.setQuitOnLastWindowClosed (false); |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18618
diff
changeset
|
259 |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
260 return qt_app.exec (); |
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
22088
diff
changeset
|
261 } |
13501 | 262 } |