Mercurial > octave-libgccjit
annotate libgui/src/octave-gui.cc @ 18611:086093fbdc1a gui-release
first implementation of a shortcut manager (bug #41217)
* file-editor.cc (set_shortcuts): use shortcut-manager to set some shortcuts
* main_window.cc (set_global_shortcuts): use shortcut-manager to set some
shortcuts;
(construct_file_menu): all actions as class variables;
(construct_edit_menu): all actions as class variables;
* main_window.h: actions as class variables
* module.mk: new files shortcut_manager.cc, shortcut_manager.h
* octave-gui.cc (octave_start_gui): initialize the shortcut_manager
* settings-dialog.cc (constructor): call shortcut-manager for shortcut table
(write_changed_settings): call shortcut-manager for writing shortcuts
* settings-dialog.ui: new tab with a tree widget for the shortcuts
* shortcut_manager.cc (constructor, destructor): new class;
(instance_ok): checks if instance is valid, creates a new one otherwise;
(do_init_data): initialize the list with all shortcut's data;
(init): internal function for initializing the data list;
(do_fill_treewidget): fills the tree widget in the settings dialog;
(do_write_shortcuts): writes shortcuts from settings dialog into file;
(do_set_shortcut): setting the shortcut for an action;
(handle_double_clicked): slot for double clicking into the tree widget;
(shortcut_dialog): dialog for entering a new shortcut;
(shortcut_dialog_finished): processing the dialog's result;
(shortcut_dialog_set_default): setting the shortcut to it's default;
(enter_shortcut::enter_shortcut): new class derived from QLineEdit;
(enter_shortcut::handle_direct_shortcut): switch between normal editing and
directly entering a shortcut;
(enter_shortcut::keyPressEvent): event handler filtering the shortcuts;
* shortcut_manager.h (init_data): static function calling do_init_data;
(write_shortcuts): static function calling do_write_shortcuts;
(fill_treewidget): static function calling do_fill_treewidget;
(set_shortcut): static function calling do_set_shortcut;
author | Torsten <ttl@justmail.de> |
---|---|
date | Tue, 01 Apr 2014 21:29:48 +0200 |
parents | ebd063b7b1c6 |
children | f1b91e3137b9 |
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 |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17737
diff
changeset
|
3 Copyright (C) 2011-2013 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 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
10 option) any later version. |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
11 |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
359098ad343e
update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents:
15196
diff
changeset
|
15 for more details. |
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 |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
24 #include <config.h> |
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> |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
31 |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
32 #include <iostream> |
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
33 |
16657
c1d5bf2eb3b6
go back to fork and setsid, but not on OS X systems
John W. Eaton <jwe@octave.org>
parents:
16598
diff
changeset
|
34 #include <unistd.h> |
16597
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
35 #include <fcntl.h> |
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
36 |
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
37 #if defined (HAVE_SYS_IOCTL_H) |
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
38 #include <sys/ioctl.h> |
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
39 #endif |
49832f60282e
if available, use ioctl to give up controlling terminal
Ben Abbott <bpabbott@mac.com>
parents:
16486
diff
changeset
|
40 |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15209
diff
changeset
|
41 #include "lo-utils.h" |
15597
9046ee786fe1
Use octave_env instead of setenv.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15425
diff
changeset
|
42 #include "oct-env.h" |
17569
9d0992c6df30
arrange to pass signals to the GUI subprocess
John W. Eaton <jwe@octave.org>
parents:
17568
diff
changeset
|
43 #include "oct-syscalls.h" |
15368
36ececf69385
avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents:
15209
diff
changeset
|
44 #include "syswait.h" |
15155
9e62d5a3a45e
partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents:
15139
diff
changeset
|
45 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
46 #include "octave.h" |
17569
9d0992c6df30
arrange to pass signals to the GUI subprocess
John W. Eaton <jwe@octave.org>
parents:
17568
diff
changeset
|
47 #include "sighandlers.h" |
9d0992c6df30
arrange to pass signals to the GUI subprocess
John W. Eaton <jwe@octave.org>
parents:
17568
diff
changeset
|
48 |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
49 #include "welcome-wizard.h" |
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
50 #include "resource-manager.h" |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
18575
diff
changeset
|
51 #include "shortcut-manager.h" |
14707
674740c44c09
Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
14703
diff
changeset
|
52 #include "main-window.h" |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
53 #include "octave-gui.h" |
17922
b5bf26a054bd
interrupt interpreter thread in GUI instead of calling "raise (SIGINT)"
John W. Eaton <jwe@octave.org>
parents:
17804
diff
changeset
|
54 #include "thread-manager.h" |
13501 | 55 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
56 // Allow the Octave interpreter to start as in CLI mode with a |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
57 // QApplication context so that it can use Qt for things like plotting |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
58 // and UI widgets. |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
59 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
60 class octave_cli_thread : public QThread |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
61 { |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
62 public: |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
63 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
64 octave_cli_thread (int argc, char **argv) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
65 : m_argc (argc), m_argv (argv), m_result (0) { } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
66 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
67 int result (void) const { return m_result; } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
68 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
69 protected: |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
70 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
71 void run (void) |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
72 { |
17925
345a8027dc8b
unblock sigint in cli thread when using --no-gui
John W. Eaton <jwe@octave.org>
parents:
17922
diff
changeset
|
73 octave_thread_manager::unblock_interrupt_signal (); |
345a8027dc8b
unblock sigint in cli thread when using --no-gui
John W. Eaton <jwe@octave.org>
parents:
17922
diff
changeset
|
74 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
75 octave_initialize_interpreter (m_argc, m_argv, 0); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
76 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
77 m_result = octave_execute_interpreter (); |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
78 |
17944
1ed269bdea58
octave-gui.cc: use QApplication instead of QCoreApplication in --no-gui mode.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17930
diff
changeset
|
79 QApplication::exit (m_result); |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
80 } |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
81 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
82 private: |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
83 |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
84 int m_argc; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
85 char** m_argv; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
86 int m_result; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
87 }; |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
88 |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
89 #if ! defined (__WIN32__) || defined (__CYGWIN__) |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
90 static int fdstderr = -1; |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
91 #endif |
17737
d3bb7f1e3971
prevent the editor's file watcher from signaling fasle alarms (bug #40312)
Torsten <ttl@justmail.de>
parents:
17647
diff
changeset
|
92 |
17747 | 93 // Custom message handler for filtering some messages from Qt. |
94 | |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
95 void |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
96 message_handler (QtMsgType type, const char *msg) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
97 { |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
98 #if ! defined (__WIN32__) || defined (__CYGWIN__) |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
99 static FILE *errstream = fdopen (fdstderr, "a+"); |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
100 #else |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
101 static FILE *errstream = stderr; |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
102 #endif |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
103 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
104 switch (type) |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
105 { |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
106 case QtDebugMsg: |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
107 gnulib::fprintf (errstream, "Debug: %s\n", msg); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
108 break; |
17747 | 109 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
110 case QtWarningMsg: |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
111 gnulib::fprintf (errstream, "Warning: %s\n", msg); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
112 break; |
17747 | 113 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
114 case QtCriticalMsg: |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
115 gnulib::fprintf (errstream, "Critical: %s\n", msg); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
116 break; |
17747 | 117 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
118 case QtFatalMsg: |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
119 gnulib::fprintf (errstream, "Fatal: %s\n", msg); |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
120 abort (); |
17747 | 121 |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
122 default: |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
123 break; |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
124 } |
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
125 } |
17737
d3bb7f1e3971
prevent the editor's file watcher from signaling fasle alarms (bug #40312)
Torsten <ttl@justmail.de>
parents:
17647
diff
changeset
|
126 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
127 // If START_GUI is false, we still set up the QApplication so that we |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
128 // can use Qt widgets for plot windows. |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
129 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
130 int |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
131 octave_start_gui (int argc, char *argv[], bool start_gui) |
13501 | 132 { |
17922
b5bf26a054bd
interrupt interpreter thread in GUI instead of calling "raise (SIGINT)"
John W. Eaton <jwe@octave.org>
parents:
17804
diff
changeset
|
133 octave_thread_manager::block_interrupt_signal (); |
b5bf26a054bd
interrupt interpreter thread in GUI instead of calling "raise (SIGINT)"
John W. Eaton <jwe@octave.org>
parents:
17804
diff
changeset
|
134 |
18569
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
135 #if ! defined (__WIN32__) || defined (__CYGWIN__) |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
136 // Store the file descriptor associated with the STDERR stream. Send |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
137 // Qt messages there instead of to the STDERR stream that will be |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
138 // associated with the GUI command window. |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
139 fdstderr = gnulib::dup (STDERR_FILENO); |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
140 #endif |
90dbbafb0502
prevent X11 errors from appearing in GUI command window
John W. Eaton <jwe@octave.org>
parents:
18027
diff
changeset
|
141 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
142 qInstallMsgHandler (message_handler); |
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
|
143 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
144 if (start_gui) |
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
|
145 { |
17804
f3e25230b1f3
use QCoreApplication if starting with --no-gui
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
146 QApplication application (argc, argv); |
18027
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
147 QTranslator gui_tr, qt_tr, qsci_tr; |
17804
f3e25230b1f3
use QCoreApplication if starting with --no-gui
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
148 |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
17944
diff
changeset
|
149 // Set the codec for all strings (before wizard) |
17790
86c6ae5f969e
Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents:
17778
diff
changeset
|
150 QTextCodec::setCodecForCStrings (QTextCodec::codecForName ("UTF-8")); |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
151 |
18020
5d42ffc6850a
load translators before welcome wizard and take system language as default
Torsten <ttl@justmail.de>
parents:
17944
diff
changeset
|
152 // show wizard if this is the first run |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
153 if (resource_manager::is_first_run ()) |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
154 { |
18027
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
155 resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); // before wizard |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
156 application.installTranslator (&qt_tr); |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
157 application.installTranslator (&qsci_tr); |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
158 application.installTranslator (&gui_tr); |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
159 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
160 welcome_wizard welcomeWizard; |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
161 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
162 if (welcomeWizard.exec () == QDialog::Rejected) |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
163 exit (1); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
164 |
18027
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
165 resource_manager::reload_settings (); // install settings file |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
166 } |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
167 else |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
168 { |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
169 resource_manager::reload_settings (); // get settings file |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
170 |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
171 resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); // after settings |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
172 application.installTranslator (&qt_tr); |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
173 application.installTranslator (&qsci_tr); |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
174 application.installTranslator (&gui_tr); |
f1d791ffeeb4
install translators before welcome wizard but after loading settings
Torsten <ttl@justmail.de>
parents:
18020
diff
changeset
|
175 } |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
176 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
177 // update network-settings |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
178 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
|
179 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
180 #if ! defined (__WIN32__) || defined (__CYGWIN__) |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
181 // If we were started from a launcher, TERM might not be |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
182 // defined, but we provide a terminal with xterm |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
183 // capabilities. |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
184 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
185 std::string term = octave_env::getenv ("TERM"); |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
186 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
187 if (term.empty ()) |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
188 octave_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
|
189 #else |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
190 std::string term = octave_env::getenv ("TERM"); |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
191 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
192 if (term.empty ()) |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
193 octave_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
|
194 #endif |
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
195 |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
18575
diff
changeset
|
196 // shortcut manager |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
18575
diff
changeset
|
197 shortcut_manager::init_data (); |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
18575
diff
changeset
|
198 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
199 // Create and show main window. |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
200 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
201 main_window w; |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
202 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
203 w.read_settings (); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
204 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
205 // Connect signals for changes in visibility not before w |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
206 // is shown. |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
207 |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
208 w.connect_visibility_changed (); |
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
209 |
18561
6b4f9cab88d6
*octave-gui.cc: focus terminal after all other actions at startup (bug #41814)
Torsten <ttl@justmail.de>
parents:
18027
diff
changeset
|
210 w.focus_command_window (); |
6b4f9cab88d6
*octave-gui.cc: focus terminal after all other actions at startup (bug #41814)
Torsten <ttl@justmail.de>
parents:
18027
diff
changeset
|
211 |
17930
ffdbb82a0c78
allow welcome wizard dialog to be canceled
John W. Eaton <jwe@octave.org>
parents:
17925
diff
changeset
|
212 return application.exec (); |
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
|
213 } |
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
|
214 else |
15139
bfc220d1de67
include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents:
15137
diff
changeset
|
215 { |
17944
1ed269bdea58
octave-gui.cc: use QApplication instead of QCoreApplication in --no-gui mode.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17930
diff
changeset
|
216 QApplication application (argc, argv); |
15137
16a6b0a6855d
GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents:
15081
diff
changeset
|
217 |
17804
f3e25230b1f3
use QCoreApplication if starting with --no-gui
John W. Eaton <jwe@octave.org>
parents:
17790
diff
changeset
|
218 octave_cli_thread main_thread (argc, argv); |
17944
1ed269bdea58
octave-gui.cc: use QApplication instead of QCoreApplication in --no-gui mode.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17930
diff
changeset
|
219 |
1ed269bdea58
octave-gui.cc: use QApplication instead of QCoreApplication in --no-gui mode.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17930
diff
changeset
|
220 application.setQuitOnLastWindowClosed (false); |
17543
dbda6edfe01d
* octave-gui.cc: install translators before showing the wlecome wizard
Torsten <ttl@justmail.de>
parents:
17360
diff
changeset
|
221 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
222 main_thread.start (); |
16598
e84b77df8940
ensure TERM environment variable is set when GUI starts
John W. Eaton <jwe@octave.org>
parents:
16597
diff
changeset
|
223 |
17778
b5d58667d32d
new main program wrapper to handle giving up controlling tty
John W. Eaton <jwe@octave.org>
parents:
17748
diff
changeset
|
224 return application.exec (); |
13668
421afeae929b
Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13658
diff
changeset
|
225 } |
13501 | 226 } |