annotate libgui/src/qt-interpreter-events.cc @ 31648:29d734430e5f stable

maint: Re-indent code after switch to using namespace macros. * BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, qopengl-functions.h, qt-graphics-toolkit.cc, qt-graphics-toolkit.h, module.mk, QTerminal.h, color-picker.cc, color-picker.h, command-widget.cc, command-widget.h, community-news.cc, community-news.h, dialog.cc, dialog.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, graphics-init.cc, graphics-init.h, gui-settings.cc, gui-settings.h, gui-utils.cc, gui-utils.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, interpreter-qobject.h, led-indicator.cc, led-indicator.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, qt-application.cc, qt-application.h, qt-interpreter-events.cc, qt-interpreter-events.h, qt-utils.h, release-notes.cc, release-notes.h, resource-manager.cc, resource-manager.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.cc, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h: Re-indent code after switch to using namespace macros.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2022 14:53:00 -0500
parents c6d54dd31a7e
children deb553ac2c54 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30398
diff changeset
3 // Copyright (C) 2011-2022 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 ////////////////////////////////////////////////////////////////////////
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21717
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
27 # include "config.h"
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
30 #include <iostream>
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
31 #include <sstream>
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
32
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
33 #include <QDialog>
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
34 #include <QDir>
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
35 #include <QIcon>
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
36 #include <QMetaType>
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
37 #include <QPushButton>
24641
7d177be54c37 pass variable value to variable editor in addition to variable name
John W. Eaton <jwe@octave.org>
parents: 24632
diff changeset
38 #include <QStringList>
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
39
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
40 #include "dialog.h"
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
41 #include "gui-preferences-ed.h"
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
42 #include "octave-qobject.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
43 #include "qt-interpreter-events.h"
28566
20ee8aa92897 avoid QList deprecated function warnings
John W. Eaton <jwe@octave.org>
parents: 28118
diff changeset
44 #include "qt-utils.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
45
28118
f2789cae04f3 Don't use "codecForLocale" to get encoding for locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27929
diff changeset
46 #include "localcharset-wrapper.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
47 #include "oct-env.h"
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
48 #include "str-vec.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
49
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
50 #include "builtin-defun-decls.h"
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
51 #include "error.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
52 #include "interpreter-private.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
53 #include "load-path.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
54 #include "oct-map.h"
25557
bb779fc2d0db do not attempt to open a file when debugging a command line fct (bug #54231)
Torsten <mttl@mailbox.org>
parents: 25407
diff changeset
55 #include "octave.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
56 #include "ov.h"
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25948
diff changeset
57 #include "syminfo.h"
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16581
diff changeset
58 #include "utils.h"
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
59
24645
f61502510d08 restore ability to select variables for editing from workspace widget
John W. Eaton <jwe@octave.org>
parents: 24641
diff changeset
60 Q_DECLARE_METATYPE (octave_value)
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 25948
diff changeset
61 Q_DECLARE_METATYPE (octave::symbol_info_list)
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27284
diff changeset
62 Q_DECLARE_METATYPE (octave::fcn_callback)
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27284
diff changeset
63 Q_DECLARE_METATYPE (octave::meth_callback)
17884
766ad9be2966 Prompt for non-existent new file when using edit.m from GUI (bug #40450)
Torsten <ttl@justmail.de>
parents: 17824
diff changeset
64
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 31087
diff changeset
65 OCTAVE_BEGIN_NAMESPACE(octave)
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 31087
diff changeset
66
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
67 static QStringList
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
68 make_qstring_list (const std::list<std::string>& lst)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
69 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
70 QStringList retval;
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
71
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
72 for (const auto& s : lst)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
73 retval.append (QString::fromStdString (s));
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
74
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
75 return retval;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
76 }
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
77
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
78 static QStringList
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
79 make_filter_list (const event_manager::filter_list& lst)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
80 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
81 QStringList retval;
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
82
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
83 // We have pairs of data, first being the list of extensions
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
84 // exta;exb;extc etc second the name to use as filter name
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
85 // (optional). Qt wants a list of filters in the format of
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
86 // 'FilterName (space separated exts)'.
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
87
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
88 for (const auto& ext_name : lst)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
89 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
90 QString ext = QString::fromStdString (ext_name.first);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
91 QString name = QString::fromStdString (ext_name.second);
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
92
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
93 // Strip out extensions from name and replace ';' with spaces in list.
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
94
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
95 name.replace (QRegExp (R"(\(.*\))"), "");
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
96 ext.replace (";", " ");
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
97
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
98 if (name.isEmpty ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
99 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
100 // No name field. Build one from the extensions.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
101 name = ext.toUpper () + " Files";
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
102 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
103
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
104 retval.append (name + " (" + ext + ')');
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
105 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
106
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
107 return retval;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
108 }
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
109
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
110 qt_interpreter_events::qt_interpreter_events (base_qobject& oct_qobj)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
111 : interpreter_events (), m_octave_qobj (oct_qobj),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
112 m_uiwidget_creator (oct_qobj), m_result (), m_mutex (),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
113 m_waitcondition ()
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
114 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
115 qRegisterMetaType<QIntList> ("QIntList");
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
116 qRegisterMetaType<QFloatList> ("QFloatList");
27551
564bba235594 move some dialog slot functions from octave-qobject.cc to dialog.cc
John W. Eaton <jwe@octave.org>
parents: 27550
diff changeset
117
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
118 qRegisterMetaType<octave_value> ("octave_value");
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
119 qRegisterMetaType<symbol_info_list> ("symbol_info_list");
20091
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
120
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
121 qRegisterMetaType<fcn_callback> ("fcn_callback");
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
122 qRegisterMetaType<meth_callback> ("meth_callback");
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
123
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
124 connect (this, &qt_interpreter_events::confirm_shutdown_signal,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
125 this, &qt_interpreter_events::confirm_shutdown_octave);
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
126
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
127 connect (this, &qt_interpreter_events::get_named_icon_signal,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
128 this, &qt_interpreter_events::get_named_icon_slot);
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
129
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
130 connect (this, &qt_interpreter_events::gui_preference_signal,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
131 this, &qt_interpreter_events::gui_preference_slot);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
132 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
133
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
134 void qt_interpreter_events::start_gui (bool gui_app)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
135 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
136 if (m_octave_qobj.experimental_terminal_widget ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
137 emit start_gui_signal (gui_app);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
138 }
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
139
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
140 void qt_interpreter_events::close_gui (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
141 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
142 if (m_octave_qobj.experimental_terminal_widget ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
143 emit close_gui_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
144 }
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
145
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
146 std::list<std::string>
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
147 qt_interpreter_events::file_dialog (const filter_list& filter,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
148 const std::string& title,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
149 const std::string& filename,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
150 const std::string& dirname,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
151 const std::string& multimode)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
152 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
153 QStringList lst
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
154 = m_uiwidget_creator.file_dialog (make_filter_list (filter),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
155 QString::fromStdString (title),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
156 QString::fromStdString (filename),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
157 QString::fromStdString (dirname),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
158 QString::fromStdString (multimode));
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
159
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
160 std::list<std::string> retval;
20091
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19970
diff changeset
161
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
162 for (const auto& s : lst)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
163 retval.push_back (s.toStdString ());
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
164
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
165 return retval;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
166 }
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16570
diff changeset
167
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
168 std::list<std::string>
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
169 qt_interpreter_events::input_dialog (const std::list<std::string>& prompt,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
170 const std::string& title,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
171 const std::list<float>& nr,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
172 const std::list<float>& nc,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
173 const std::list<std::string>& defaults)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
174 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
175 QStringList lst
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
176 = m_uiwidget_creator.input_dialog (make_qstring_list (prompt),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
177 QString::fromStdString (title),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
178 std_list_to_qt_list<float> (nr),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
179 std_list_to_qt_list<float> (nc),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
180 make_qstring_list (defaults));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
181 std::list<std::string> retval;
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
182
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
183 for (const auto& s : lst)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
184 retval.push_back (s.toStdString ());
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
185
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
186 return retval;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
187 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
188
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
189 std::pair<std::list<int>, int>
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
190 qt_interpreter_events::list_dialog (const std::list<std::string>& list,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
191 const std::string& mode,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
192 int width, int height,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
193 const std::list<int>& initial,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
194 const std::string& name,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
195 const std::list<std::string>& prompt,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
196 const std::string& ok_string,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
197 const std::string& cancel_string)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
198 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
199 QPair<QIntList, int> result
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
200 = m_uiwidget_creator.list_dialog (make_qstring_list (list),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
201 QString::fromStdString (mode),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
202 width, height,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
203 std_list_to_qt_list<int> (initial),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
204 QString::fromStdString (name),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
205 make_qstring_list (prompt),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
206 QString::fromStdString (ok_string),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
207 QString::fromStdString (cancel_string));
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
208
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
209 QIntList& lst = result.first;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
210 return std::pair<std::list<int>, int> (std::list<int> (lst.begin (),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
211 lst.end ()),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
212 result.second);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
213 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
214
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
215 std::string
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
216 qt_interpreter_events::question_dialog (const std::string& msg,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
217 const std::string& title,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
218 const std::string& btn1,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
219 const std::string& btn2,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
220 const std::string& btn3,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
221 const std::string& btndef)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
222 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
223 QString icon = "quest";
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
224 QStringList buttons;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
225 QStringList role;
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
226
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
227 // Must use ResetRole which is left-aligned for all OS and WM.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
228 role << "ResetRole" << "ResetRole" << "ResetRole";
27552
de5129cb0796 refactor dialog functions
John W. Eaton <jwe@octave.org>
parents: 27551
diff changeset
229
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
230 buttons << QString::fromStdString (btn1);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
231 if (btn2 == "")
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
232 role.removeAt (0);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
233 else
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
234 buttons << QString::fromStdString (btn2);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
235 buttons << QString::fromStdString (btn3);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
236
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
237 QString answer
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
238 = m_uiwidget_creator.message_dialog (QString::fromStdString (msg),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
239 QString::fromStdString (title),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
240 icon, buttons,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
241 QString::fromStdString (btndef),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
242 role);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
243
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
244 return answer.toStdString ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
245 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
246
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
247 void qt_interpreter_events::update_path_dialog (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
248 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
249 emit update_path_dialog_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
250 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
251
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
252 void qt_interpreter_events::show_preferences (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
253 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
254 emit show_preferences_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
255 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
256
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
257 void qt_interpreter_events::apply_preferences (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
258 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
259 emit apply_new_settings ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
260 }
27602
ba317c535adb define new __event_manager_apply_preferences__ function
John W. Eaton <jwe@octave.org>
parents: 27601
diff changeset
261
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
262 void qt_interpreter_events::show_terminal_window (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
263 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
264 emit show_terminal_window_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
265 }
29787
b4d2fa28d1d4 allow terminal window to be opened from command line
John W. Eaton <jwe@octave.org>
parents: 29613
diff changeset
266
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
267 bool qt_interpreter_events::show_documentation (const std::string& file)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
268 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
269 emit show_documentation_signal (QString::fromStdString (file));
29613
9367cba2a6d5 allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents: 29542
diff changeset
270
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
271 return true;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
272 }
29613
9367cba2a6d5 allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents: 29542
diff changeset
273
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
274 void qt_interpreter_events::show_file_browser (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
275 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
276 emit show_file_browser_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
277 }
29613
9367cba2a6d5 allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents: 29542
diff changeset
278
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
279 void qt_interpreter_events::show_command_history (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
280 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
281 emit show_command_history_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
282 }
29613
9367cba2a6d5 allow most dock widgets to be used from command line
John W. Eaton <jwe@octave.org>
parents: 29542
diff changeset
283
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
284 void qt_interpreter_events::show_workspace (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
285 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
286 emit show_workspace_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
287 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
288
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
289 void qt_interpreter_events::show_community_news (int serial)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
290 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
291 emit show_community_news_signal (serial);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
292 }
29835
a946d742fb97 allow community news window to be opened from command line
John W. Eaton <jwe@octave.org>
parents: 29796
diff changeset
293
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
294 void qt_interpreter_events::show_release_notes (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
295 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
296 emit show_release_notes_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
297 }
29836
56465c0739fa allow release notes window to be opened from command line
John W. Eaton <jwe@octave.org>
parents: 29835
diff changeset
298
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
299 bool qt_interpreter_events::edit_file (const std::string& file)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
300 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
301 emit edit_file_signal (QString::fromStdString (file));
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
302
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
303 return true;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
304 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
305
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
306 void qt_interpreter_events::edit_variable (const std::string& expr,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
307 const octave_value& val)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
308 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
309 emit edit_variable_signal (QString::fromStdString (expr), val);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
310 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
311
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
312 bool qt_interpreter_events::confirm_shutdown (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
313 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
314 QMutexLocker autolock (&m_mutex);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
315
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
316 emit confirm_shutdown_signal ();
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
317
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
318 // Wait for result.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
319 wait ();
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
320
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
321 return m_result.toBool ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
322 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
323
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
324 bool qt_interpreter_events::prompt_new_edit_file (const std::string& file)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
325 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
326 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
327 gui_settings *settings = rmgr.get_settings ();
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
328
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
329 if (! settings || settings->value (ed_create_new_file).toBool ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
330 return true;
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
331
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
332 std::string abs_fname = sys::env::make_absolute (file);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
333
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
334 QStringList btn;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
335 QStringList role;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
336 role << "YesRole" << "RejectRole";
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
337 btn << tr ("Create") << tr ("Cancel");
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
338
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
339 QString answer = m_uiwidget_creator.message_dialog
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
340 (tr ("File\n%1\ndoes not exist. Do you want to create it?").
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
341 arg (QString::fromStdString (abs_fname)),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
342 tr ("Octave Editor"), "quest", btn, tr ("Create"), role);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
343
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
344 return (answer == tr ("Create"));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
345 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
346
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
347 // Prompt to allow file to be run by setting cwd (or if
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
348 // addpath_option==true, alternatively setting the path).
27264
378d3c91f85b style fixes for event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27263
diff changeset
349
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
350 int
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
351 qt_interpreter_events::debug_cd_or_addpath_error (const std::string& file,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
352 const std::string& dir,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
353 bool addpath_option)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
354 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
355 int retval = -1;
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
356
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
357 QString qdir = QString::fromStdString (dir);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
358 QString qfile = QString::fromStdString (file);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
359 QString msg
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
360 = (addpath_option
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
361 ? tr ("The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
362 : tr ("The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir));
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
363
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
364 QString title = tr ("Change Directory or Add Directory to Load Path");
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
365
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
366 QString cd_txt = tr ("&Change Directory");
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
367 QString addpath_txt = tr ("&Add Directory to Load Path");
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
368 QString cancel_txt = tr ("Cancel");
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
369
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
370 QStringList btn;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
371 QStringList role;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
372 btn << cd_txt;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
373 role << "YesRole";
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
374 if (addpath_option)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
375 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
376 btn << addpath_txt;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
377 role << "AcceptRole";
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
378 }
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
379 btn << cancel_txt;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
380 role << "RejectRole";
21311
718332a58d35 Fix left mouse button in editor margin bug from cset 65827e9cccb8
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21310
diff changeset
381
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
382 QString result
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
383 = m_uiwidget_creator.message_dialog (msg, title, "quest", btn,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
384 cancel_txt, role);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
385
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
386 if (result == cd_txt)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
387 retval = 1;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
388 else if (result == addpath_txt)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
389 retval = 2;
16565
e4b94abfeb96 use generic dialog for cd or addpath question
John W. Eaton <jwe@octave.org>
parents: 16551
diff changeset
390
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
391 return retval;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
392 }
16547
3cd80afc3509 improve debugging with the GUI
John W. Eaton <jwe@octave.org>
parents: 16528
diff changeset
393
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
394 uint8NDArray qt_interpreter_events::get_named_icon (const std::string& name)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
395 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
396 QMutexLocker autolock (&m_mutex);
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
397
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
398 emit get_named_icon_signal (QString::fromStdString (name));
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
399
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
400 // Wait for result.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
401 wait ();
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
402
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
403 uint8NDArray empty_img;
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
404
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
405 QIcon icon = m_result.value<QIcon> ();
27600
bb9aecedc167 use single QVariant object for return values in qt_interpreter_events class
John W. Eaton <jwe@octave.org>
parents: 27599
diff changeset
406
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
407 if (icon.isNull ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
408 return empty_img;
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
409
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
410 QImage img = icon.pixmap (QSize (32, 32)).toImage ();
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
411
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
412 if (img.format () != QImage::Format_ARGB32_Premultiplied)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
413 return empty_img;
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
414
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
415 dim_vector dims (img.height (), img.width (), 4);
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
416
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
417 uint8NDArray retval (dims, 0);
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
418
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
419 uint8_t *bits = img.bits ();
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
420
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
421 for (int i = 0; i < img.height (); i++)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
422 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
423 for (int j = 0; j < img.width (); j++)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
424 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
425 retval(i, j, 2) = bits[0];
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
426 retval(i, j, 1) = bits[1];
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
427 retval(i, j, 0) = bits[2];
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
428 retval(i, j, 3) = bits[3];
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
429
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
430 bits += 4;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
431 }
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
432 }
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
433
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
434 return retval;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
435 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
436
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
437 void qt_interpreter_events::get_named_icon_slot (const QString& name)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
438 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
439 QMutexLocker autolock (&m_mutex);
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
440
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
441 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
442 m_result = QVariant::fromValue (rmgr.icon (name));
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
443
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
444 wake_all ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
445 }
27599
ada24a1979c0 improve thread safety of qt_interpreter_events::get_named_icon
John W. Eaton <jwe@octave.org>
parents: 27589
diff changeset
446
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
447 std::string
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
448 qt_interpreter_events::gui_preference (const std::string& key,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
449 const std::string& value)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
450 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
451 QString pref_value;
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
452
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
453 QMutexLocker autolock (&m_mutex);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
454
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
455 // Emit the signal for changing or getting a preference
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
456 emit gui_preference_signal (QString::fromStdString (key),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
457 QString::fromStdString (value));
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
458
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
459 // Wait for response (pref_value).
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
460 wait ();
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
461
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
462 QString pref = m_result.toString ();
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
463
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
464 return pref.toStdString ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
465 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
466
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
467 bool qt_interpreter_events::copy_image_to_clipboard (const std::string& file)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
468 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
469 emit copy_image_to_clipboard_signal (QString::fromStdString (file), true);
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
470
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
471 return true;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
472 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
473
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
474 void qt_interpreter_events::focus_window (const std::string win_name)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
475 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
476 emit focus_window_signal (QString::fromStdString (win_name));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
477 }
27669
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27643
diff changeset
478
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
479 void qt_interpreter_events::execute_command_in_terminal
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
480 (const std::string& command)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
481 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
482 emit execute_command_in_terminal_signal (QString::fromStdString (command));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
483 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
484
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
485 void qt_interpreter_events::register_documentation (const std::string& file)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
486 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
487 emit register_documentation_signal (QString::fromStdString (file));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
488 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
489
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
490 void qt_interpreter_events::unregister_documentation (const std::string& file)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
491 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
492 emit unregister_documentation_signal (QString::fromStdString (file));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
493 }
27442
6e4519df0be2 group functions by category in interpreter_events and event_manager classes
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
494
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
495 void qt_interpreter_events::interpreter_output (const std::string& msg)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
496 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
497 if (m_octave_qobj.experimental_terminal_widget ()
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
498 && m_octave_qobj.have_terminal_window ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
499 emit interpreter_output_signal (QString::fromStdString (msg));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
500 else
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
501 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
502 // FIXME: is this the correct thing to do?
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
503 std::cout << msg;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
504 }
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
505 }
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
506
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
507 void qt_interpreter_events::display_exception (const execution_exception& ee,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
508 bool beep)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
509 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
510 if (m_octave_qobj.experimental_terminal_widget ()
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
511 && m_octave_qobj.have_terminal_window ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
512 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
513 // Output the exception message
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
514 std::ostringstream buf;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
515 ee.display (buf);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
516 emit interpreter_output_signal (QString::fromStdString (buf.str ()));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
517 // Create w new command line
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
518 emit new_command_line_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
519 }
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
520 else
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
521 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
522 if (beep)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
523 std::cerr << "\a";
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
524
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
525 ee.display (std::cerr);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
526 }
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
527 }
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
528
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
529 void qt_interpreter_events::gui_status_update (const std::string& feature,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
530 const std::string& status)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
531 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
532 emit gui_status_update_signal (QString::fromStdString (feature),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
533 QString::fromStdString (status));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
534 }
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
535
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
536 void qt_interpreter_events::update_gui_lexer (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
537 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
538 emit update_gui_lexer_signal (true);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
539 }
28788
aba2c4eadb83 add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28566
diff changeset
540
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
541 void qt_interpreter_events::directory_changed (const std::string& dir)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
542 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
543 emit directory_changed_signal (QString::fromStdString (dir));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
544 }
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
545
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
546 void qt_interpreter_events::file_remove (const std::string& old_name,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
547 const std::string& new_name)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
548 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
549 QMutexLocker autolock (&m_mutex);
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
550
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
551 // Emit the signal for the editor for closing the file if it is open
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
552 emit file_remove_signal (QString::fromStdString (old_name),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
553 QString::fromStdString (new_name));
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
554
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
555 // Wait for file removal to complete before continuing.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
556 wait ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
557 }
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
558
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
559 void qt_interpreter_events::file_renamed (bool load_new)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
560 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
561 emit file_renamed_signal (load_new);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
562 }
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
563
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
564 void qt_interpreter_events::set_workspace (bool top_level, bool debug,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
565 const symbol_info_list& syminfo,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
566 bool update_variable_editor)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
567 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
568 if (! top_level && ! debug)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
569 return;
19904
793230bb81d4 don't update workspace viewer unless at top level (bug #44156)
John W. Eaton <jwe@octave.org>
parents: 19714
diff changeset
570
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
571 emit set_workspace_signal (top_level, debug, syminfo);
23927
e3a36f84d01d provide variable-editor widget for the GUI
Michael Barnes <mjbcode@runbox.com>
parents: 23807
diff changeset
572
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
573 if (update_variable_editor)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
574 emit refresh_variable_editor_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
575 }
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
576
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
577 void qt_interpreter_events::clear_workspace (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
578 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
579 emit clear_workspace_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
580 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
581
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
582 void qt_interpreter_events::update_prompt (const std::string& prompt)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
583 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
584 emit update_prompt_signal (QString::fromStdString (prompt));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
585 }
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
586
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
587 void qt_interpreter_events::set_history (const string_vector& hist)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
588 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
589 QStringList qt_hist;
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
590
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
591 for (octave_idx_type i = 0; i < hist.numel (); i++)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
592 qt_hist.append (QString::fromStdString (hist[i]));
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
593
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
594 emit set_history_signal (qt_hist);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
595 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
596
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
597 void qt_interpreter_events::append_history (const std::string& hist_entry)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
598 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
599 emit append_history_signal (QString::fromStdString (hist_entry));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
600 }
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
601
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
602 void qt_interpreter_events::clear_history (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
603 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
604 emit clear_history_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
605 }
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
606
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
607 void qt_interpreter_events::pre_input_event (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
608 { }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
609
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
610 void qt_interpreter_events::post_input_event (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
611 { }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
612
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
613 void qt_interpreter_events::enter_debugger_event (const std::string& /*fcn_name*/,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
614 const std::string& fcn_file_name,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
615 int line)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
616 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
617 if (fcn_file_name.empty ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
618 return;
25557
bb779fc2d0db do not attempt to open a file when debugging a command line fct (bug #54231)
Torsten <mttl@mailbox.org>
parents: 25407
diff changeset
619
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
620 insert_debugger_pointer (fcn_file_name, line);
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
621
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
622 emit enter_debugger_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
623 }
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
624
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
625 void
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
626 qt_interpreter_events::execute_in_debugger_event (const std::string& file,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
627 int line)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
628 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
629 delete_debugger_pointer (file, line);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
630 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
631
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
632 void qt_interpreter_events::exit_debugger_event (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
633 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
634 emit exit_debugger_signal ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
635 }
16415
70032fc70bee move octave-link and octave-event-listener classes to libinterp
John W. Eaton <jwe@octave.org>
parents:
diff changeset
636
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
637 // Display (if @insert true) or remove the appropriate symbol for a breakpoint
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
638 // in @file at @line with condition @cond.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
639 void qt_interpreter_events::update_breakpoint (bool insert,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
640 const std::string& file,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
641 int line,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
642 const std::string& cond)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
643 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
644 emit update_breakpoint_marker_signal (insert, QString::fromStdString (file),
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
645 line, QString::fromStdString (cond));
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
646 }
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
647
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
648 void
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
649 qt_interpreter_events::insert_debugger_pointer (const std::string& file,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
650 int line)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
651 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
652 emit insert_debugger_pointer_signal (QString::fromStdString (file), line);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
653 }
17010
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16658
diff changeset
654
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
655 void
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
656 qt_interpreter_events::delete_debugger_pointer (const std::string& file,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
657 int line)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
658 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
659 emit delete_debugger_pointer_signal (QString::fromStdString (file), line);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
660 }
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
661
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
662 void
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
663 qt_interpreter_events::confirm_shutdown_octave (void)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
664 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
665 QMutexLocker autolock (&m_mutex);
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
666
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
667 m_result = m_octave_qobj.confirm_shutdown ();
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27553
diff changeset
668
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
669 wake_all ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
670 }
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
671
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
672 // If VALUE is empty, return current value of preference named by KEY.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
673 //
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
674 // If VALUE is not empty, set preference named by KEY to VALUE return
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
675 // previous value.
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
676 //
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
677 // FIXME: should we have separate get and set functions? With only
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
678 // one, we don't allow a preference value to be set to the empty
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
679 // string.
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
680
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
681 void
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
682 qt_interpreter_events::gui_preference_slot (const QString& key,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
683 const QString& value)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
684 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
685 QMutexLocker autolock (&m_mutex);
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
686
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
687 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
688 gui_settings *settings = rmgr.get_settings ();
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
689
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
690 QString read_value = settings->value (key).toString ();
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
691
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
692 // Some preferences need extra handling
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
693 QString adjusted_value = gui_preference_adjust (key, value);
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
694
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
695 if (! adjusted_value.isEmpty () && (read_value != adjusted_value))
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
696 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
697 // Change settings only for new, non-empty values
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
698 settings->setValue (key, QVariant (adjusted_value));
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
699
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
700 emit settings_changed (settings, true); // true: changed by worker
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
701 }
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
702
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
703 m_result = read_value;
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
704
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
705 wake_all ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
706 }
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
707
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
708 QString
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
709 qt_interpreter_events::gui_preference_adjust (const QString& key,
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
710 const QString& value)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
711 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
712 // Immediately return if no new value is given.
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
713
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
714 if (value.isEmpty ())
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
715 return value;
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
716
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
717 QString adjusted_value = value;
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
718
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
719 // Not all encodings are available. Encodings are uppercase and do
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
720 // not use CPxxx but IBMxxx or WINDOWS-xxx.
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
721
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
722 if (key == ed_default_enc.key)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
723 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
724 adjusted_value = adjusted_value.toUpper ();
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
725
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
726 QStringList codecs;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
727 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
728 rmgr.get_codecs (&codecs);
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
729
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
730 QRegExp re ("^CP(\\d+)$");
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
731
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
732 if (adjusted_value == "SYSTEM")
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
733 adjusted_value =
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
734 QString ("SYSTEM (") +
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
735 QString (octave_locale_charset_wrapper ()).toUpper () +
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
736 QString (")");
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
737 else if (re.indexIn (adjusted_value) > -1)
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
738 {
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
739 if (codecs.contains ("IBM" + re.cap (1)))
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
740 adjusted_value = "IBM" + re.cap (1);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
741 else if (codecs.contains ("WINDOWS-" + re.cap (1)))
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
742 adjusted_value = "WINDOWS-" + re.cap (1);
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
743 else
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
744 adjusted_value.clear ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
745 }
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
746 else if (! codecs.contains (adjusted_value))
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
747 adjusted_value.clear ();
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
748 }
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27600
diff changeset
749
31648
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
750 return adjusted_value;
29d734430e5f maint: Re-indent code after switch to using namespace macros.
John W. Eaton <jwe@octave.org>
parents: 31646
diff changeset
751 }
31646
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 31087
diff changeset
752
c6d54dd31a7e maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents: 31087
diff changeset
753 OCTAVE_END_NAMESPACE(octave)