Mercurial > octave
annotate libgui/src/octave-qobject.cc @ 29835:a946d742fb97
allow community news window to be opened from command line
* libgui/src/community-news.h, libgui/src/community-news.cc:
New files with community news widget extracted from main-window.cc.
* libgui/src/module.mk: Update.
* main-window.h, main-window.cc
(main_window::m_community_news_window): Delete member variable and all uses.
(main_window::load_and_display_community_news,
main_window::display_community_news): Delete.
(main_window::show_community_news_signal): New signal.
(main_window::main_window): To display community news, emit
show_community_news_signal instead of calling
load_and_display_community_news.
(main_window::construct_news_menu): Use lambda expression in menu
action to emit show_community_news_signal.
* event-manager.h, event-manager.cc
(interpreter_events::show_community_news,
event_manager::show_community_news): New functions.
(F__event_manager_show_community_news__): New function.
* qt-interpreter-events.h, qt-interpreter-events.cc
(qt_interpreter_events::show_community_news): New function.
qt_interpreter_events::show_community_news_signal): New signal.
* octave-qobject.h, octave-qobject.cc
(base_qobject::m_community_news): New data member.
(base_qobject::community_news_widget,
base_qobject::show_community_news): New functions.
(base_qobject::base_qobject): Connect qt_interpreter_events
show_community_news_signal to base_object show_community_news slot.
If creating main_window, also connect main_window
show_community_news_signal to base_object show_community_news slot.
(base_qobject::start_gui): Connect main_window
show_community_news_signal to base_object show_community_news slot.
(base_qobject::~base_qobject): Also close m_community_news window and
delete object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 25 Jun 2021 17:27:17 -0400 |
parents | 0923ae48a4f7 |
children | 56465c0739fa |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29346
diff
changeset
|
3 // Copyright (C) 2011-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
30 #include <utility> |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
31 |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <QApplication> |
27648
2952471e29a7
eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents:
27630
diff
changeset
|
33 #include <QClipboard> |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <QFile> |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include <QTextCodec> |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include <QThread> |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
37 #include <QTimer> |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include <QTranslator> |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
40 // QTerminal includes |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
41 #include "QTerminal.h" |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
42 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
43 #include "command-widget.h" |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
44 #include "community-news.h" |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
45 #include "documentation-dock-widget.h" |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
46 #include "files-dock-widget.h" |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
47 #include "history-dock-widget.h" |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 #include "interpreter-qobject.h" |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 #include "main-window.h" |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "octave-qobject.h" |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
51 #include "qt-application.h" |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27261
diff
changeset
|
52 #include "qt-interpreter-events.h" |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 #include "resource-manager.h" |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27624
diff
changeset
|
54 #include "shortcut-manager.h" |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
55 #include "terminal-dock-widget.h" |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
56 #include "variable-editor.h" |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
57 #include "workspace-model.h" |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
58 #include "workspace-view.h" |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
27616
1c13a0f36160
Temporarily disable code in cset d0fe6e344c41 (bug #55940)
Rik <rik@octave.org>
parents:
27604
diff
changeset
|
60 // Bug #55940 (Disable App Nap on Mac) |
27575
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
61 #if defined (Q_OS_MAC) |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
62 # include <objc/runtime.h> |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
63 # include <objc/message.h> |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
64 #endif |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
65 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
66 #include "interpreter.h" |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
67 #include "oct-env.h" |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 #include "version.h" |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
70 #include "ovl.h" |
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27393
diff
changeset
|
71 |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
72 |
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
73 // Bug #55940 (Disable App Nap on Mac) |
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
74 #if defined (Q_OS_MAC) |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
75 static void disable_app_nap (void) |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
76 { |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
77 Class process_info_class; |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
78 SEL process_info_selector; |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
79 SEL begin_activity_with_options_selector; |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
80 id process_info; |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
81 id reason_string; |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
82 id osx_latencycritical_activity; |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
83 |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
84 // Option codes found at https://stackoverflow.com/questions/22784886/what-can-make-nanosleep-drift-with-exactly-10-sec-on-mac-os-x-10-9/32729281#32729281 |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
85 unsigned long long NSActivityUserInitiatedAllowingIdleSystemSleep = 0x00FFFFFFULL; |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
86 unsigned long long NSActivityLatencyCritical = 0xFF00000000ULL; |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
87 |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
88 // Avoid errors on older versions of OS X |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
89 process_info_class = static_cast<Class> (objc_getClass ("NSProcessInfo")); |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
90 if (process_info_class == nil) |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
91 return; |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
92 |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
93 process_info_selector = sel_getUid ("processInfo"); |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
94 if (class_getClassMethod (process_info_class, process_info_selector) |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
95 == nullptr) |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
96 return; |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
97 |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
98 begin_activity_with_options_selector = sel_getUid ("beginActivityWithOptions:reason:"); |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
99 if (class_getInstanceMethod (process_info_class, |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
100 begin_activity_with_options_selector) |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
101 == nullptr) |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
102 return; |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
103 |
28063
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
104 process_info = reinterpret_cast<id (*) (id, SEL)> (objc_msgSend) |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
105 (reinterpret_cast<id> (process_info_class), |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
106 process_info_selector); |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
107 if (process_info == nil) |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
108 return; |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
109 |
28063
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
110 reason_string = reinterpret_cast<id (*) (id, SEL)> (objc_msgSend) |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
111 (reinterpret_cast<id> (objc_getClass ("NSString")), |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
112 sel_getUid ("alloc")); |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
113 reason_string = reinterpret_cast<id (*) (id, SEL, const char *)> (objc_msgSend) |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
114 (reason_string, sel_getUid ("initWithUTF8String:"), |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
115 "App Nap causes pause() malfunction"); |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
116 |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
117 // Start an Activity that suppresses App Nap. This Activity will run for |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
118 // the entire duration of the Octave process. This is intentional, |
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
119 // not a leak. |
28063
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
120 osx_latencycritical_activity = |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
121 reinterpret_cast<id (*) (id, SEL, unsigned long long, id)> (objc_msgSend) |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
122 (process_info, |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
123 begin_activity_with_options_selector, |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
124 NSActivityUserInitiatedAllowingIdleSystemSleep |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
125 | NSActivityLatencyCritical, |
60e4a9909fac
Fix App Nap for new prototype of "objc_msgSend" in OS X Mojave (bug #57754).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27935
diff
changeset
|
126 reason_string); |
27624
d6b561842eeb
maint: Fix indentation in static function to disable App Nap.
Andrew Janke <andrew@apjanke.net>
parents:
27621
diff
changeset
|
127 } |
27621
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
128 #endif |
39fac14ab25a
Enable App Nap disabling on macOS (bug #55490).
Andrew Janke <andrew@apjanke.net>
parents:
27620
diff
changeset
|
129 |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 namespace octave |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 { |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 // Disable all Qt messages by default. |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 static void |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 message_handler (QtMsgType, const QMessageLogContext &, const QString &) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 { } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 //! Reimplement QApplication::notify. Octave's own exceptions are |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 //! caught and rethrown in the interpreter thread. |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 bool octave_qapplication::notify (QObject *receiver, QEvent *ev) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 { |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 try |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
144 { |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 return QApplication::notify (receiver, ev); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 } |
27481
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
147 catch (execution_exception& ee) |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 { |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
149 emit interpreter_event |
28851
1ac5a76ae91d
use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents:
28799
diff
changeset
|
150 ([=] (void) |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
151 { |
27393
efe72866b483
mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents:
27302
diff
changeset
|
152 // INTERPRETER THREAD |
27481
458adc344819
avoid possible crash due to execution_exception in GUI thread
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
153 throw ee; |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
154 }); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
157 return false; |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 // We will create a QApplication object, even if START_GUI is false, |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 // so that we can use Qt widgets for plot windows when running in |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 // command-line mode. Note that we are creating an |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 // octave_qapplication object but handling it as a QApplication object |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 // because the octave_qapplication should behave identically to a |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 // QApplication object except that it overrides the notify method so |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 // we can handle forward Octave interpreter exceptions from the GUI |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 // thread to the interpreter thread. |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 |
29153
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
169 base_qobject::base_qobject (qt_application& app_context, bool gui_app) |
29549
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
170 : QObject (), |
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
171 m_app_context (app_context), |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 m_argc (m_app_context.sys_argc ()), |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 m_argv (m_app_context.sys_argv ()), |
27218
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
174 m_qapplication (new octave_qapplication (m_argc, m_argv)), |
29549
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
175 m_resource_manager (), |
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
176 m_shortcut_manager (*this), |
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
177 m_qt_tr (new QTranslator ()), |
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
178 m_gui_tr (new QTranslator ()), |
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
179 m_qsci_tr (new QTranslator ()), |
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
180 m_translators_installed (false), |
27588
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27582
diff
changeset
|
181 m_qt_interpreter_events (new qt_interpreter_events (*this)), |
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27582
diff
changeset
|
182 m_interpreter_qobj (new interpreter_qobject (*this)), |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
183 m_main_thread (new QThread ()), |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
184 m_gui_app (gui_app), |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
185 m_interpreter_ready (false), |
29785
8ba6f4d0373c
eliminate unused reference to base_qobject in workspace_model
John W. Eaton <jwe@octave.org>
parents:
29783
diff
changeset
|
186 m_workspace_model (new workspace_model ()), |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
187 m_documentation_widget (), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
188 m_file_browser_widget (), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
189 m_history_widget (), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
190 m_workspace_widget (), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
191 m_editor_widget (), |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
192 m_variable_editor_widget (), |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
193 m_main_window (nullptr) |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 { |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 std::string show_gui_msgs = |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 sys::env::getenv ("OCTAVE_SHOW_GUI_MESSAGES"); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 // Installing our handler suppresses the messages. |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 if (show_gui_msgs.empty ()) |
29549
cf02394695b3
* octave-qobject.cc: Minor style fixes.
John W. Eaton <jwe@octave.org>
parents:
29548
diff
changeset
|
201 qInstallMessageHandler (message_handler); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 // Set the codec for all strings (before wizard or any GUI object) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 #if ! defined (Q_OS_WIN32) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 QTextCodec::setCodecForLocale (QTextCodec::codecForName ("UTF-8")); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 #endif |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 // Initialize global Qt application metadata. |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 QCoreApplication::setApplicationName ("GNU Octave"); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 QCoreApplication::setApplicationVersion (OCTAVE_VERSION); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 // Register octave_value_list for connecting thread crossing signals. |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 qRegisterMetaType<octave_value_list> ("octave_value_list"); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
27616
1c13a0f36160
Temporarily disable code in cset d0fe6e344c41 (bug #55940)
Rik <rik@octave.org>
parents:
27604
diff
changeset
|
217 // Bug #55940 (Disable App Nap on Mac) |
27575
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
218 #if defined (Q_OS_MAC) |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
219 // Mac App Nap feature causes pause() and sleep() to misbehave. |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
220 // Disable it for the entire program run. |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
221 disable_app_nap (); |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
222 #endif |
d0fe6e344c41
Disable Mac App Nap feature so that pause, sleep work correctly (bug #55940).
Andrew Janke <andrew@apjanke.net>
parents:
27551
diff
changeset
|
223 |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
224 // Force left-to-right alignment (see bug #46204) |
27218
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
225 m_qapplication->setLayoutDirection (Qt::LeftToRight); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 |
29548
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
227 // Qt docs recommend using Qt::QueuedConnection when connecting to |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
228 // the QCoreApplication::exit slot. |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
229 connect (m_interpreter_qobj, &interpreter_qobject::shutdown_finished, |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
230 m_qapplication, &octave_qapplication::exit, |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
231 Qt::QueuedConnection); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 |
29786
63c515ff762f
eliminate more signal connections to parent objects
John W. Eaton <jwe@octave.org>
parents:
29785
diff
changeset
|
233 connect (m_interpreter_qobj, &interpreter_qobject::ready, |
63c515ff762f
eliminate more signal connections to parent objects
John W. Eaton <jwe@octave.org>
parents:
29785
diff
changeset
|
234 this, &base_qobject::interpreter_ready); |
63c515ff762f
eliminate more signal connections to parent objects
John W. Eaton <jwe@octave.org>
parents:
29785
diff
changeset
|
235 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
236 connect (m_main_thread, &QThread::finished, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
237 m_main_thread, &QThread::deleteLater); |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
238 |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
239 // Handle any interpreter_event signal from the octave_qapplication |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
240 // object here. |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
241 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
242 connect (m_qapplication, QOverload<const fcn_callback&>::of (&octave_qapplication::interpreter_event), |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
243 this, QOverload<const fcn_callback&>::of (&base_qobject::interpreter_event)); |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
244 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
245 connect (m_qapplication, QOverload<const meth_callback&>::of (&octave_qapplication::interpreter_event), |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
246 this, QOverload<const meth_callback&>::of (&base_qobject::interpreter_event)); |
27588
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27582
diff
changeset
|
247 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
248 if (m_app_context.experimental_terminal_widget ()) |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
249 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
250 connect (qt_link (), &qt_interpreter_events::start_gui_signal, |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
251 this, &base_qobject::start_gui); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
252 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
253 connect (qt_link (), &qt_interpreter_events::show_terminal_window_signal, |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
254 this, &base_qobject::show_terminal_window); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
255 } |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
256 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
257 connect (qt_link (), &qt_interpreter_events::copy_image_to_clipboard_signal, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
258 this, &base_qobject::copy_image_to_clipboard); |
29153
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
259 |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
260 // Get settings file. |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
261 m_resource_manager.reload_settings (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
262 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
263 // After settings. |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
264 config_translators (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
265 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
266 connect (qt_link (), &qt_interpreter_events::show_documentation_signal, |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
267 this, &base_qobject::show_documentation_window); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
268 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
269 connect (qt_link (), &qt_interpreter_events::show_file_browser_signal, |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
270 this, &base_qobject::show_file_browser_window); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
271 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
272 connect (qt_link (), &qt_interpreter_events::show_command_history_signal, |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
273 this, &base_qobject::show_command_history_window); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
274 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
275 connect (qt_link (), &qt_interpreter_events::show_workspace_signal, |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
276 this, &base_qobject::show_workspace_window); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
277 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
278 connect (qt_link (), &qt_interpreter_events::edit_variable_signal, |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
279 this, &base_qobject::show_variable_editor_window); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
280 |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
281 connect (qt_link (), &qt_interpreter_events::show_community_news_signal, |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
282 this, &base_qobject::show_community_news); |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
283 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
284 if (m_app_context.experimental_terminal_widget ()) |
29153
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
285 { |
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
286 m_qapplication->setQuitOnLastWindowClosed (false); |
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
287 } |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
288 else |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
289 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
290 if (gui_app) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
291 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
292 m_main_window = new main_window (*this); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
293 |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
294 connect (m_main_window, &main_window::show_community_news_signal, |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
295 this, &base_qobject::show_community_news); |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
296 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
297 if (m_interpreter_ready) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
298 m_main_window->handle_octave_ready (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
299 else |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
300 connect (m_interpreter_qobj, &interpreter_qobject::ready, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
301 m_main_window, &main_window::handle_octave_ready); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
302 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
303 connect (qt_link (), &qt_interpreter_events::focus_window_signal, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
304 m_main_window, &main_window::focus_window); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
305 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
306 m_app_context.gui_running (true); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
307 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
308 else |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
309 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
310 // Get settings file. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
311 m_resource_manager.reload_settings (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
312 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
313 // After settings. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
314 config_translators (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
315 |
29780
d79f65e37e89
provide shortcuts in widgets launched from the cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29775
diff
changeset
|
316 // Initilize the shortcut-manager |
d79f65e37e89
provide shortcuts in widgets launched from the cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29775
diff
changeset
|
317 m_shortcut_manager.init_data (); |
d79f65e37e89
provide shortcuts in widgets launched from the cli
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29775
diff
changeset
|
318 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
319 m_qapplication->setQuitOnLastWindowClosed (false); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
320 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
321 } |
29153
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
322 |
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
323 start_main_thread (); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
326 base_qobject::~base_qobject (void) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 { |
27219
b88d66c631c8
delete translator objects in base_qobject destructor
John W. Eaton <jwe@octave.org>
parents:
27218
diff
changeset
|
328 // Note that we don't delete m_main_thread here. That is handled by |
b88d66c631c8
delete translator objects in base_qobject destructor
John W. Eaton <jwe@octave.org>
parents:
27218
diff
changeset
|
329 // deleteLater slot that is called when the m_main_thread issues a |
b88d66c631c8
delete translator objects in base_qobject destructor
John W. Eaton <jwe@octave.org>
parents:
27218
diff
changeset
|
330 // finished signal. |
b88d66c631c8
delete translator objects in base_qobject destructor
John W. Eaton <jwe@octave.org>
parents:
27218
diff
changeset
|
331 |
29757
f8322ca49578
delete main window before dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29756
diff
changeset
|
332 // FIXME: Why are dock widget settings and/or the main window |
f8322ca49578
delete main window before dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29756
diff
changeset
|
333 // configuration not saved correctly if the main window is deleted |
f8322ca49578
delete main window before dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29756
diff
changeset
|
334 // after the dock widgets? |
f8322ca49578
delete main window before dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29756
diff
changeset
|
335 |
f8322ca49578
delete main window before dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29756
diff
changeset
|
336 |
29756
7db4a4e94556
use deleteLater to delete dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29755
diff
changeset
|
337 // Calling close will cause settings to be saved. |
29758
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
338 // If m_main_window exists, the widgets are closed by the main window |
29755
23cf249a0ad8
explicitly close all dock widgets in base_qobject destructor (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29754
diff
changeset
|
339 |
29758
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
340 if (! m_main_window) |
29756
7db4a4e94556
use deleteLater to delete dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29755
diff
changeset
|
341 { |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
342 if (m_terminal_widget) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
343 m_terminal_widget->close (); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
344 |
29758
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
345 if (m_documentation_widget) |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
346 m_documentation_widget->close (); |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
347 |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
348 if (m_file_browser_widget) |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
349 m_file_browser_widget->close (); |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
350 |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
351 if (m_history_widget) |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
352 m_history_widget->close (); |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
353 |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
354 if (m_workspace_widget) |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
355 m_workspace_widget->close (); |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
356 |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
357 if (m_editor_widget) |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
358 m_editor_widget->close (); |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
359 |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
360 if (m_variable_editor_widget) |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
361 m_variable_editor_widget->close (); |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
362 |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
363 if (m_community_news) |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
364 m_community_news->close (); |
29756
7db4a4e94556
use deleteLater to delete dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29755
diff
changeset
|
365 } |
29758
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
366 else |
29756
7db4a4e94556
use deleteLater to delete dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29755
diff
changeset
|
367 { |
29758
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
368 delete m_main_window; |
29756
7db4a4e94556
use deleteLater to delete dock widgets (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29755
diff
changeset
|
369 } |
29755
23cf249a0ad8
explicitly close all dock widgets in base_qobject destructor (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29754
diff
changeset
|
370 |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
371 delete m_terminal_widget; |
29758
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
372 delete m_documentation_widget; |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
373 delete m_file_browser_widget; |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
374 delete m_history_widget; |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
375 delete m_workspace_widget; |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
376 delete m_editor_widget; |
1511b7cd3474
only close dock widgets when main window does not exist (bug #60646)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29757
diff
changeset
|
377 delete m_variable_editor_widget; |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
378 delete m_community_news; |
29755
23cf249a0ad8
explicitly close all dock widgets in base_qobject destructor (bug #60646)
John W. Eaton <jwe@octave.org>
parents:
29754
diff
changeset
|
379 |
27218
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
380 delete m_interpreter_qobj; |
27219
b88d66c631c8
delete translator objects in base_qobject destructor
John W. Eaton <jwe@octave.org>
parents:
27218
diff
changeset
|
381 delete m_qsci_tr; |
b88d66c631c8
delete translator objects in base_qobject destructor
John W. Eaton <jwe@octave.org>
parents:
27218
diff
changeset
|
382 delete m_gui_tr; |
b88d66c631c8
delete translator objects in base_qobject destructor
John W. Eaton <jwe@octave.org>
parents:
27218
diff
changeset
|
383 delete m_qt_tr; |
27218
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
384 delete m_qapplication; |
28799
6aba3944b608
fix deleting pointer when octave exists
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28795
diff
changeset
|
385 delete m_workspace_model; |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 string_vector::delete_c_str_vec (m_argv); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 void base_qobject::config_translators (void) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
391 { |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 if (m_translators_installed) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 return; |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27619
diff
changeset
|
395 m_resource_manager.config_translators (m_qt_tr, m_qsci_tr, m_gui_tr); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 |
27218
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
397 m_qapplication->installTranslator (m_qt_tr); |
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
398 m_qapplication->installTranslator (m_gui_tr); |
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
399 m_qapplication->installTranslator (m_qsci_tr); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 m_translators_installed = true; |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
404 void base_qobject::start_main_thread (void) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 { |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
406 // Note: if using the new experimental terminal widget, we defer |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
407 // initializing and executing the interpreter until the main event |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
408 // loop begins executing. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
409 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
410 // With the old terminal widget, we defer initializing and executing |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
411 // the interpreter until after the main window and QApplication are |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
412 // running to prevent race conditions. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
413 |
29544
4eeef8cdaa2c
Backout changes to octave-qobject.cc in cset 3d34b70b5a49 (bug #60420)
Rik <rik@octave.org>
parents:
29542
diff
changeset
|
414 QTimer::singleShot (0, m_interpreter_qobj, SLOT (execute (void))); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 |
27218
a044202208af
more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents:
27197
diff
changeset
|
416 m_interpreter_qobj->moveToThread (m_main_thread); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 m_main_thread->start (); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 int base_qobject::exec (void) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 { |
29548
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
423 int status = m_qapplication->exec (); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
424 |
29548
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
425 #if defined (Q_OS_MAC) |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
426 // fprintf to stderr is needed by macOS, for poorly-understood reasons. |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
427 fprintf (stderr, "\n"); |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
428 #endif |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
429 |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
430 m_main_thread->quit (); |
f6ad83cbe3c4
simplify interpreter shutdown in the GUI
John W. Eaton <jwe@octave.org>
parents:
29544
diff
changeset
|
431 m_main_thread->wait (); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
432 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
433 return status; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
434 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
435 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
436 // Provided for convenience. Will be removed once we eliminate the |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
437 // old terminal widget. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
438 bool base_qobject::experimental_terminal_widget (void) const |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
439 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
440 return m_app_context.experimental_terminal_widget (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
441 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
442 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
443 bool base_qobject::gui_running (void) const |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
444 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
445 return m_app_context.gui_running (); |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
448 QPointer<terminal_dock_widget> |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
449 base_qobject::terminal_widget (main_window *mw) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
450 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
451 if (m_terminal_widget && mw) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
452 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
453 m_terminal_widget->set_main_window (mw); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
454 m_terminal_widget->set_adopted (true); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
455 } |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
456 else if (! m_terminal_widget) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
457 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
458 m_terminal_widget |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
459 = QPointer<terminal_dock_widget> (new terminal_dock_widget (mw, *this)); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
460 if (experimental_terminal_widget ()) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
461 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
462 command_widget *cmd_widget |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
463 = m_terminal_widget->get_command_widget (); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
464 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
465 connect (cmd_widget, &command_widget::interpreter_pause, |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
466 this, &base_qobject::interpreter_pause); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
467 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
468 connect (cmd_widget, &command_widget::interpreter_resume, |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
469 this, &base_qobject::interpreter_resume); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
470 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
471 connect (cmd_widget, &command_widget::interpreter_stop, |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
472 this, &base_qobject::interpreter_stop); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
473 |
29796
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
474 connect (qt_link (), &qt_interpreter_events::interpreter_output_signal, |
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
475 m_terminal_widget, &terminal_dock_widget::interpreter_output); |
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
476 |
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
477 connect (qt_link (), &qt_interpreter_events::update_prompt_signal, |
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
478 m_terminal_widget, &terminal_dock_widget::update_prompt); |
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
479 |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
480 connect_interpreter_events (cmd_widget); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
481 } |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
482 else |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
483 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
484 QTerminal *cmd_widget = m_terminal_widget->get_qterminal (); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
485 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
486 // Connect the interrupt signal (emitted by Ctrl-C) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
487 connect (cmd_widget, &QTerminal::interrupt_signal, |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
488 this, &base_qobject::interpreter_interrupt); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
489 } |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
490 } |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
491 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
492 return m_terminal_widget; |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
493 } |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
494 |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
495 QPointer<documentation_dock_widget> |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
496 base_qobject::documentation_widget (main_window *mw) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
497 { |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
498 if (m_documentation_widget && mw) |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
499 { |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
500 m_documentation_widget->set_main_window (mw); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
501 m_documentation_widget->set_adopted (true); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
502 } |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
503 else if (! m_documentation_widget) |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
504 { |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
505 m_documentation_widget |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
506 = QPointer<documentation_dock_widget> (new documentation_dock_widget (mw, *this)); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
507 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
508 connect (qt_link (), |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
509 &qt_interpreter_events::register_documentation_signal, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
510 m_documentation_widget, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
511 &documentation_dock_widget::registerDoc); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
512 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
513 connect (qt_link (), |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
514 &qt_interpreter_events::unregister_documentation_signal, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
515 m_documentation_widget, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
516 &documentation_dock_widget::unregisterDoc); |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
517 } |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
518 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
519 return m_documentation_widget; |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
520 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
521 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
522 QPointer<files_dock_widget> |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
523 base_qobject::file_browser_widget (main_window *mw) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
524 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
525 if (m_file_browser_widget) |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
526 { |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
527 m_file_browser_widget->set_main_window (mw); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
528 m_file_browser_widget->set_adopted (true); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
529 } |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
530 else if (! m_file_browser_widget) |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
531 m_file_browser_widget |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
532 = QPointer<files_dock_widget> (new files_dock_widget (mw, *this)); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
533 |
29796
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
534 connect (qt_link (), &qt_interpreter_events::directory_changed_signal, |
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
535 m_file_browser_widget, &files_dock_widget::update_octave_directory); |
a0fce019cd1f
additional reorganization of signal/slot connections in main_window class
John W. Eaton <jwe@octave.org>
parents:
29787
diff
changeset
|
536 |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
537 return m_file_browser_widget; |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
538 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
539 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
540 QPointer<history_dock_widget> |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
541 base_qobject::history_widget (main_window *mw) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
542 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
543 if (m_history_widget) |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
544 { |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
545 m_history_widget->set_main_window (mw); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
546 m_history_widget->set_adopted (true); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
547 } |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
548 else if (! m_history_widget) |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
549 { |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
550 m_history_widget |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
551 = QPointer<history_dock_widget> (new history_dock_widget (mw, *this)); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
552 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
553 connect (qt_link (), &qt_interpreter_events::set_history_signal, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
554 m_history_widget, &history_dock_widget::set_history); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
555 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
556 connect (qt_link (), &qt_interpreter_events::append_history_signal, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
557 m_history_widget, &history_dock_widget::append_history); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
558 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
559 connect (qt_link (), &qt_interpreter_events::clear_history_signal, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
560 m_history_widget, &history_dock_widget::clear_history); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
561 |
29775
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
562 emit interpreter_event |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
563 ([=] (interpreter& interp) { |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
564 // INTERPRETER THREAD |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
565 |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
566 event_manager& xevmgr = interp.get_event_manager (); |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
567 |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
568 xevmgr.set_history (); |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
569 }); |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
570 } |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
571 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
572 return m_history_widget; |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
573 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
574 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
575 QPointer<workspace_view> |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
576 base_qobject::workspace_widget (main_window *mw) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
577 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
578 if (m_workspace_widget) |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
579 { |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
580 m_workspace_widget->set_main_window (mw); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
581 m_workspace_widget->set_adopted (true); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
582 } |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
583 else if (! m_workspace_widget) |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
584 { |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
585 m_workspace_widget |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
586 = QPointer<workspace_view> (new workspace_view (mw, *this)); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
587 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
588 m_workspace_widget->setModel (m_workspace_model); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
589 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
590 connect (m_workspace_model, &workspace_model::model_changed, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
591 m_workspace_widget, &workspace_view::handle_model_changed); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
592 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
593 connect (qt_link (), &qt_interpreter_events::set_workspace_signal, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
594 m_workspace_model, &workspace_model::set_workspace); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
595 |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
596 connect (qt_link (), &qt_interpreter_events::clear_workspace_signal, |
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
597 m_workspace_model, &workspace_model::clear_workspace); |
29768
38bbe1a2828f
allow variable editor to open from workspace view without main window
John W. Eaton <jwe@octave.org>
parents:
29762
diff
changeset
|
598 |
29774
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
599 connect (m_workspace_widget, |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
600 &workspace_view::copy_variable_value_to_clipboard, |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
601 [=] (const QString& var_name) { |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
602 emit interpreter_event |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
603 ([=] (interpreter& interp) |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
604 { |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
605 // INTERPRETER THREAD |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
606 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
607 octave_value val = interp.varval (var_name.toStdString ()); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
608 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
609 if (val.is_undefined ()) |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
610 val = 0; |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
611 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
612 std::ostringstream buf; |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
613 val.print_raw (buf, true); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
614 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
615 // FIXME: is the following operation thread safe or should |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
616 // it be done with a signal/slot connection? |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
617 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
618 QClipboard *clipboard = QApplication::clipboard (); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
619 clipboard->setText (QString::fromStdString (buf.str ())); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
620 }); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
621 }); |
29773
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
622 |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
623 connect (m_workspace_widget, &workspace_view::rename_variable_signal, |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
624 [=] (const QString& old_name, const QString& new_name) { |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
625 emit interpreter_event |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
626 ([=] (interpreter& interp) { |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
627 // INTERPRETER THREAD |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
628 |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
629 symbol_scope scope = interp.get_current_scope (); |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
630 |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
631 if (scope) |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
632 { |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
633 scope.rename (old_name.toStdString (), |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
634 new_name.toStdString ()); |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
635 |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
636 tree_evaluator& tw = interp.get_evaluator (); |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
637 |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
638 event_manager& xevmgr = interp.get_event_manager (); |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
639 |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
640 xevmgr.set_workspace (true, tw.get_symbol_info ()); |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
641 } |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
642 |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
643 // FIXME: if this action fails, do we need a way to |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
644 // display that info in the GUI? |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
645 }); |
5f404ae822ee
allow variable renaming in workspace_view to work without main_window
John W. Eaton <jwe@octave.org>
parents:
29768
diff
changeset
|
646 }); |
29774
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
647 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
648 connect (m_workspace_widget, &workspace_view::edit_variable_signal, |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
649 [=] (const QString& var_name) { |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
650 emit interpreter_event |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
651 ([=] (interpreter& interp) { |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
652 // INTERPRETER THREAD |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
653 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
654 std::string name = var_name.toStdString (); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
655 octave_value val = interp.varval (name); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
656 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
657 event_manager& xevmgr = interp.get_event_manager (); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
658 |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
659 xevmgr.edit_variable (name, val); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
660 }); |
aa46787ed8b7
eliminate direct dependence on octave intepreter from workspace_view
John W. Eaton <jwe@octave.org>
parents:
29773
diff
changeset
|
661 }); |
29775
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
662 |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
663 emit interpreter_event |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
664 ([=] (interpreter& interp) { |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
665 // INTERPRETER THREAD |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
666 |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
667 event_manager& xevmgr = interp.get_event_manager (); |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
668 |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
669 xevmgr.set_workspace (); |
a64352cadda8
use interpreter events to set initial data for workspace and history widgets
John W. Eaton <jwe@octave.org>
parents:
29774
diff
changeset
|
670 }); |
29702
3a684b0e7406
only connect dock widget signals in base_qobject when creating dock widgets
John W. Eaton <jwe@octave.org>
parents:
29700
diff
changeset
|
671 } |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
672 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
673 return m_workspace_widget; |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
674 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
675 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
676 QPointer<file_editor_interface> |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
677 base_qobject::editor_widget (main_window */*mw*/) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
678 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
679 #if 0 |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
680 if (m_editor_widget && mw) |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
681 { |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
682 m_editor_widget->set_main_window (mw); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
683 m_editor_widget->set_adopted (true); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
684 } |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
685 else if (! m_editor_widget) |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
686 m_editor_widget = new file_editor (mw, *this); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
687 #endif |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
688 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
689 return m_editor_widget; |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
690 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
691 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
692 QPointer<variable_editor> |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
693 base_qobject::variable_editor_widget (main_window *mw) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
694 { |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
695 if (m_variable_editor_widget && mw) |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
696 { |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
697 m_variable_editor_widget->set_main_window (mw); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
698 m_variable_editor_widget->set_adopted (true); |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
699 } |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
700 else if (! m_variable_editor_widget) |
29762
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
701 { |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
702 m_variable_editor_widget |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
703 = QPointer<variable_editor> (new variable_editor (mw, *this)); |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
704 |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
705 connect (m_variable_editor_widget, &variable_editor::updated, |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
706 this, &base_qobject::handle_variable_editor_update); |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
707 |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
708 connect (m_variable_editor_widget, &variable_editor::command_signal, |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
709 this, &base_qobject::execute_command); |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
710 |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
711 connect (qt_link (), |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
712 &qt_interpreter_events::refresh_variable_editor_signal, |
29822
0923ae48a4f7
avoid possible crash on return to command line after closing main window
John W. Eaton <jwe@octave.org>
parents:
29796
diff
changeset
|
713 m_variable_editor_widget, &variable_editor::refresh); |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29780
diff
changeset
|
714 |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29780
diff
changeset
|
715 connect_interpreter_events<variable_editor> (m_variable_editor_widget); |
29762
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
716 } |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
717 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
718 return m_variable_editor_widget; |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
719 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
720 |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
721 QPointer<community_news> base_qobject::community_news_widget (int serial) |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
722 { |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
723 if (! m_community_news) |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
724 m_community_news |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
725 = QPointer<community_news> (new community_news (*this, serial)); |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
726 |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
727 return m_community_news; |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
728 } |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
729 |
27588
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27582
diff
changeset
|
730 bool base_qobject::confirm_shutdown (void) |
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27582
diff
changeset
|
731 { |
29153
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
732 // Currently, we forward to main_window::confirm_shutdown instead of |
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
733 // just displaying a dialog box here because the main_window also |
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
734 // knows about and is responsible for notifying the editor. |
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
735 |
02ee34a30351
eliminate separate cli_qobject and gui_qobject classes
John W. Eaton <jwe@octave.org>
parents:
28851
diff
changeset
|
736 return m_main_window ? m_main_window->confirm_shutdown () : true; |
27588
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27582
diff
changeset
|
737 } |
f0e3f3e28a8e
move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents:
27582
diff
changeset
|
738 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
739 void base_qobject::start_gui (bool gui_app) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
740 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
741 if (m_app_context.experimental_terminal_widget ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
742 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
743 if (m_main_window) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
744 return; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
745 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
746 m_gui_app = gui_app; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
747 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
748 m_main_window = new main_window (*this); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
749 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
750 connect (qt_link (), &qt_interpreter_events::focus_window_signal, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
751 m_main_window, &main_window::focus_window); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
752 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
753 connect (qt_link (), &qt_interpreter_events::close_gui_signal, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
754 this, &base_qobject::close_gui); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
755 |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
756 connect (m_main_window, &main_window::close_gui_signal, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
757 this, &base_qobject::close_gui); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
758 |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
759 connect (m_main_window, &main_window::show_community_news_signal, |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
760 this, &base_qobject::show_community_news); |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
761 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
762 if (m_interpreter_ready) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
763 m_main_window->handle_octave_ready (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
764 else |
29575
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
765 connect (m_interpreter_qobj, &interpreter_qobject::ready, |
c7206af46897
Avoid use of SIGNAL/SLOT where possible (bug #60420)
Rik <rik@octave.org>
parents:
29549
diff
changeset
|
766 m_main_window, &main_window::handle_octave_ready); |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
767 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
768 if (m_gui_app) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
769 m_qapplication->setQuitOnLastWindowClosed (true); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
770 else |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
771 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
772 // FIXME: Save current values of PS1 and PS2 so they can be |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
773 // restored when we return to the command line? |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
774 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
775 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
776 m_app_context.gui_running (true); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
777 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
778 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
779 |
29787
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
780 void base_qobject::show_terminal_window (void) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
781 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
782 terminal_dock_widget *widget |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
783 = (m_terminal_widget |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
784 ? m_terminal_widget : terminal_widget ()); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
785 |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
786 if (! widget->isVisible ()) |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
787 { |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
788 widget->show (); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
789 widget->raise (); |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
790 } |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
791 } |
b4d2fa28d1d4
allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29786
diff
changeset
|
792 |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
793 void base_qobject::show_documentation_window (const QString& file) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
794 { |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
795 documentation_dock_widget *widget |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
796 = (m_documentation_widget |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
797 ? m_documentation_widget : documentation_widget ()); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
798 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
799 widget->showDoc (file); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
800 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
801 if (! widget->isVisible ()) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
802 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
803 widget->show (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
804 widget->raise (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
805 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
806 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
807 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
808 void base_qobject::show_file_browser_window (void) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
809 { |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
810 files_dock_widget *widget |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
811 = m_file_browser_widget ? m_file_browser_widget : file_browser_widget (); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
812 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
813 if (! widget->isVisible ()) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
814 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
815 widget->show (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
816 widget->raise (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
817 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
818 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
819 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
820 void base_qobject::show_command_history_window (void) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
821 { |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
822 history_dock_widget *widget |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
823 = m_history_widget ? m_history_widget : history_widget (); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
824 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
825 if (! widget->isVisible ()) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
826 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
827 widget->show (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
828 widget->raise (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
829 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
830 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
831 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
832 void base_qobject::show_workspace_window (void) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
833 { |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
834 workspace_view *widget |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
835 = m_workspace_widget ? m_workspace_widget : workspace_widget (); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
836 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
837 if (! widget->isVisible ()) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
838 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
839 widget->show (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
840 widget->raise (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
841 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
842 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
843 |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
844 void base_qobject::show_variable_editor_window (const QString& name, |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
845 const octave_value& value) |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
846 { |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
847 variable_editor *widget |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
848 = (m_variable_editor_widget |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
849 ? m_variable_editor_widget : variable_editor_widget ()); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
850 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
851 if (! widget->isVisible ()) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
852 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
853 widget->show (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
854 widget->raise (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
855 } |
29754
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
856 |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
857 // FIXME: Should this be done with a signal/slot connection? |
4c569e386e9b
improve behavior of dockable widgets (bug #60750)
John W. Eaton <jwe@octave.org>
parents:
29702
diff
changeset
|
858 widget->edit_variable (name, value); |
29613
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
859 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
860 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
861 void base_qobject::handle_variable_editor_update (void) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
862 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
863 // Called when the variable editor emits the updated signal. The size |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
864 // of a variable may have changed, so we refresh the workspace in the |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
865 // interpreter. That will eventually cause the workspace view in the |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
866 // GUI to be updated. |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
867 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
868 interpreter_event |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
869 ([] (interpreter& interp) |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
870 { |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
871 // INTERPRETER THREAD |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
872 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
873 tree_evaluator& tw = interp.get_evaluator (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
874 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
875 event_manager& xevmgr = interp.get_event_manager (); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
876 |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
877 xevmgr.set_workspace (true, tw.get_symbol_info (), false); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
878 }); |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
879 } |
9367cba2a6d5
allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents:
29575
diff
changeset
|
880 |
29835
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
881 void base_qobject::show_community_news (int serial) |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
882 { |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
883 // Ensure widget exists. |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
884 community_news_widget (serial); |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
885 |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
886 m_community_news->display (); |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
887 } |
a946d742fb97
allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents:
29822
diff
changeset
|
888 |
29762
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
889 void base_qobject::execute_command (const QString& command) |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
890 { |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
891 emit interpreter_event |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
892 ([=] (interpreter& interp) |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
893 { |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
894 // INTERPRETER THREAD |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
895 |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
896 // FIXME: Do we need to do anything special about errors here? |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
897 // Currently the eval function will just call error() in the |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
898 // interpreter event loop and throw an execution error. It will |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
899 // be caught, so shouldn't crash the interpreter, but the |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
900 // message may not go anywhere useful depending on how the GUI |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
901 // is being used or if Octave running server mode. |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
902 |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
903 interp.eval (command.toStdString (), 0); |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
904 }); |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
905 } |
84d7e1ace446
improve variable editor functionality when used without GUI main window
John W. Eaton <jwe@octave.org>
parents:
29758
diff
changeset
|
906 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
907 void base_qobject::close_gui (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
908 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
909 if (m_app_context.experimental_terminal_widget ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
910 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
911 if (! m_main_window) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
912 return; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
913 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
914 // FIXME: Restore previous values of PS1 and PS2 if we are |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
915 // returning to the command line? |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
916 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
917 interpreter_event |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
918 ([=] (interpreter& interp) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
919 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
920 // INTERPRETER THREAD |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
921 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
922 application *app = interp.get_app_context (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
923 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
924 cmdline_options opts = app->options (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
925 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
926 if (opts.gui ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
927 interp.quit (0, false, false); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
928 }); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
929 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
930 m_app_context.gui_running (false); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
931 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
932 if (m_main_window) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
933 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
934 m_main_window->deleteLater (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
935 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
936 m_main_window = nullptr; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
937 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
938 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
939 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
940 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
941 void base_qobject::interpreter_ready (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
942 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
943 m_interpreter_ready = true; |
28347
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28063
diff
changeset
|
944 } |
00a9a49c7670
improve interpreter shutdown process (bug #56952)
John W. Eaton <jwe@octave.org>
parents:
28063
diff
changeset
|
945 |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
946 void base_qobject::interpreter_event (const fcn_callback& fcn) |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
947 { |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
948 // The following is a direct function call across threads. It works |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29780
diff
changeset
|
949 // because it is accessing a thread-safe queue of events that |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
950 // are later executed by the Octave interpreter in the other thread. |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
951 |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
952 // See also the comments in interpreter-qobject.h about |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
953 // interpreter_qobject slots. |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
954 |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
955 m_interpreter_qobj->interpreter_event (fcn); |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
956 } |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
957 |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
958 void base_qobject::interpreter_event (const meth_callback& meth) |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
959 { |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
960 // The following is a direct function call across threads. It works |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29780
diff
changeset
|
961 // because it is accessing a thread-safe queue of events that |
27302
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
962 // are later executed by the Octave interpreter in the other thread. |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
963 |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
964 // See also the comments in interpreter-qobject.h about |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
965 // interpreter_qobject slots. |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
966 |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
967 m_interpreter_qobj->interpreter_event (meth); |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
968 } |
5f170ea12fa1
use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents:
27263
diff
changeset
|
969 |
29292
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29219
diff
changeset
|
970 void base_qobject::interpreter_interrupt (void) |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29219
diff
changeset
|
971 { |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
972 m_interpreter_qobj->interrupt (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
973 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
974 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
975 // FIXME: Should we try to make the pause, stop, and resume actions |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
976 // work for both the old and new terminal widget? |
29292
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29219
diff
changeset
|
977 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
978 void base_qobject::interpreter_pause (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
979 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
980 if (m_app_context.experimental_terminal_widget ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
981 m_interpreter_qobj->pause (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
982 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
983 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
984 void base_qobject::interpreter_stop (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
985 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
986 if (m_app_context.experimental_terminal_widget ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
987 m_interpreter_qobj->stop (); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
988 } |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
989 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
990 void base_qobject::interpreter_resume (void) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
991 { |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
992 if (m_app_context.experimental_terminal_widget ()) |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
993 m_interpreter_qobj->resume (); |
29292
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29219
diff
changeset
|
994 } |
eb1e10abe9d5
use method in interpreter class to interrupt interpreter execution in GUI
John W. Eaton <jwe@octave.org>
parents:
29219
diff
changeset
|
995 |
27197
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
996 void base_qobject::copy_image_to_clipboard (const QString& file, |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
997 bool remove_file) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
998 { |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
999 QClipboard *clipboard = QApplication::clipboard (); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1000 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1001 QImage img (file); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1002 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1003 if (img.isNull ()) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1004 { |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1005 // Report error? |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1006 return; |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1007 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1008 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1009 clipboard->setImage (img); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1010 |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1011 if (remove_file) |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1012 QFile::remove (file); |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1013 } |
b8c0d5ad024f
refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1014 } |