Mercurial > octave
annotate libgui/src/terminal-dock-widget.h @ 31696:8fed04d0607c
eliminate shortcut_manager class and revamp shortcut handling
* settings-dialog.ui: Use a custom type for the
* shortcuts-tree-widget.h, shortcuts-tree-widget.cc: New files.
(shortcuts_tree_widget): New class to use for editing and displaying
shortcuts in the settings dialog. Adapt constructor from
shortcut_manager::fill_treewidget function.
(enter_shortcut): Move here from shortcut-manager.h and
shortcut-manager.cc.
(tree_widget_shortcut_item): New class to use for items in the
shortcuts_tree_widget class in place of QTreeWidgetItem.
(shortcut_edit_dialog): New class to use for shortcut editing dialog
in place of a simple QDialog. Allows for capturing edited values in
the dialog object.
* gui-preferences-sc.h, gui-preferences-sc.cc (sc_group):
Drop trailing "/" from definition and move here from
gui-preferences.h. Update code that prepends sc_group to a settings key.
(get_shortcut_section): New function.
* gui-preferences.h, gui-preferences.cc
(sc_pref::def_value, sc_pref::def_text): New functions.
(all_shortcut_preferences::value, all_shortcut_preferences::keys): New
static funtions.
(all_shortcut_preferences::do_value,
all_shortcut_preferences::do_keys): New helper functions.
* gui-settings.cc (gui_settings::sc_def_value):
Simply call sc_pref::def_value.
* settings-dialog.h, settings-dialog.cc (class settings_dialog):
Eliminate use of base_qobject and shortcut_manager.
(settings_dialog::import_shortcut_set): Get file name here. Call
shortcuts_tree_widget::import_shortcuts instead of
shortcut_manager::import_export.
(settings_dialog::export_shortcut_set): Get file name here. Call
shortcuts_tree_widget::export_shortcuts instead of
shortcut_manager::import_export.
(settings_dialog::default_shortcut_set): Check whether to overwrite
shortcuts here. Call shortcuts_tree_widget::set_default_shortcuts
instead of shortcut_manager::import_export.
(settings_dialog::write_changed_settings): Eliminate CLOSING
argument. Call shortcuts_tree_widget::write_settings instead of
shortcut_manager::write_shortcuts.
(settings_dialog::get_shortcuts_file_name): New function to prompt
user for file name.
(settings_dialog::overwrite_all_shortcuts): New function to ask user
whether replacing shortcuts is OK.
(import_export_action): Move enum decl here from shortcut-manager.h.
* main-window.cc (main_window::process_settings_dialog_request):
Eliminate m_octave_qobj in call to settings_dialog ctor.
(main_window::main_window): Don't call shortcut_manager::init_data.
* terminal-dock-widget.h, terminal-dock-widget.cc
(terminal_dock_widget::init_control_d_shortcut_behavior): New function.
(terminal_dock_widget::terminal_dock_widget): Use it instead of
performing same action in shortcut_manager::init.
* octave-qobject.h, octave-qobject.cc
(base_qobject::m_shortcut_manager): Delete data member.
(base_qobject::get_shortcut_manager): Delete.
(base_qobject::base_qobject): Don't call shortcut_manager::init_data.
* shortcut-manager.h, shortcut-manager.cc: Delete. Eliminates the now
unnecessary shortcut_manager class.
* libgui/src/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 26 Dec 2022 17:29:59 -0500 |
parents | deb553ac2c54 |
children | dd904ce6f53f |
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:
29783
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 //////////////////////////////////////////////////////////////////////// |
14692
d6d250812c01
Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
25 |
21203
710e700cdd7f
maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
26 #if ! defined (octave_terminal_dock_widget_h) |
710e700cdd7f
maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
27 #define octave_terminal_dock_widget_h 1 |
14692
d6d250812c01
Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
28 |
16446
4b3a4bf8569b
improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents:
16057
diff
changeset
|
29 #include <QString> |
4b3a4bf8569b
improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents:
16057
diff
changeset
|
30 |
16057
c3057d80cf91
Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
15585
diff
changeset
|
31 #include "octave-dock-widget.h" |
14692
d6d250812c01
Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
32 |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
33 class QTerminal; |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
34 |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31222
diff
changeset
|
35 OCTAVE_BEGIN_NAMESPACE(octave) |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31222
diff
changeset
|
36 |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
37 class command_widget; |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
38 class base_qobject; |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
39 |
24733
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
40 class terminal_dock_widget : public octave_dock_widget |
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
41 { |
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
42 Q_OBJECT |
16446
4b3a4bf8569b
improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents:
16057
diff
changeset
|
43 |
24733
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
44 public: |
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
45 |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
46 terminal_dock_widget (QWidget *parent, base_qobject& oct_qobj); |
16446
4b3a4bf8569b
improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents:
16057
diff
changeset
|
47 |
29550
8dd0fca2a3d9
where possible, use default destructors in GUI classes
John W. Eaton <jwe@octave.org>
parents:
29503
diff
changeset
|
48 ~terminal_dock_widget (void) = default; |
22177
6e9f5408c0db
Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
21203
diff
changeset
|
49 |
24733
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
50 bool has_focus (void) const; |
16576
2754c5fd6ae0
keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
51 |
31067
5261a81765b0
merge input and output of exp. terminal widget into one widget
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
52 void init_command_prompt (); |
5261a81765b0
merge input and output of exp. terminal widget into one widget
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30564
diff
changeset
|
53 |
31696
8fed04d0607c
eliminate shortcut_manager class and revamp shortcut handling
John W. Eaton <jwe@octave.org>
parents:
31649
diff
changeset
|
54 void init_control_d_shortcut_behavior (); |
8fed04d0607c
eliminate shortcut_manager class and revamp shortcut handling
John W. Eaton <jwe@octave.org>
parents:
31649
diff
changeset
|
55 |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
56 // FIXME: The next two functions could be eliminated (or combined) |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
57 // if we had a common interface for the old and new terminal |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
58 // widgets. |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
59 |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
60 // Only valid if using the old terminal widget. |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
61 QTerminal * get_qterminal (void); |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
62 |
31222
1a0756f7c90a
disable experimental terminal widget when building without qscintilla
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31087
diff
changeset
|
63 #if defined (HAVE_QSCINTILLA) |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
64 // Only valid if using the new terminal widget. |
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
65 command_widget * get_command_widget (void); |
31222
1a0756f7c90a
disable experimental terminal widget when building without qscintilla
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31087
diff
changeset
|
66 #endif |
29783
5154c91e0d98
eliminate some connections to parent objects in octave_dock_widget classes
John W. Eaton <jwe@octave.org>
parents:
29611
diff
changeset
|
67 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
68 signals: |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
69 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31222
diff
changeset
|
70 void settings_changed (void); |
29611
d64ad3b93372
eliminate direct parent to child connection in terminal dock widget
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
71 |
31087
9c0099048264
exp cmd widget: fix missing promt after error
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31068
diff
changeset
|
72 // Note: the following four signals are |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
73 // currently only used by the new experimental terminal widget. |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
74 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
75 void update_prompt_signal (const QString&); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
76 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
77 void interpreter_output_signal (const QString&); |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
78 |
31087
9c0099048264
exp cmd widget: fix missing promt after error
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31068
diff
changeset
|
79 void new_command_line_signal (const QString& = QString ()); |
9c0099048264
exp cmd widget: fix missing promt after error
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31068
diff
changeset
|
80 |
31068
0b402f523f09
allow executing a command in the new terminal widget
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31067
diff
changeset
|
81 void execute_command_signal (const QString&); |
0b402f523f09
allow executing a command in the new terminal widget
Torsten Lilge <ttl-octave@mailbox.org>
parents:
31067
diff
changeset
|
82 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
83 public slots: |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
84 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31222
diff
changeset
|
85 void notice_settings (void); |
29611
d64ad3b93372
eliminate direct parent to child connection in terminal dock widget
John W. Eaton <jwe@octave.org>
parents:
29550
diff
changeset
|
86 |
24733
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
87 private: |
17920
5c3f22dd0bbb
raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
88 |
29503
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
89 bool m_experimental_terminal_widget; |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
90 |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
91 // FIXME!!! Maybe my_term should just be derived from QTerminal? |
3bfec185c9e2
experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
92 QWidget *m_terminal; |
24733
e15d53d2de1e
move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
93 }; |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31222
diff
changeset
|
94 |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31222
diff
changeset
|
95 OCTAVE_END_NAMESPACE(octave) |
14692
d6d250812c01
Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff
changeset
|
96 |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
97 #endif |