annotate libgui/src/dw-main-window.cc @ 31621:0645ea65ca6b

handle icons and themes in gui_settings class, not resource_manager * resource-manager.h, resource-manager.cc (resource_manager::config_icon_theme, resource_manager::icon): Move funtcions to gui-settings.h and gui-settings.cc. * Canvas.cc, QTerminal.cc, documentation-bookmarks.cc, documentation.cc, dw-main-window.cc, files-dock-widget.cc, find-files-dialog.cc, gui-settings.cc, gui-settings.h, history-dock-widget.cc, file-editor.cc, main-window.cc, octave-dock-widget.cc, octave-qobject.cc, qt-interpreter-events.cc, resource-manager.cc, resource-manager.h, variable-editor.cc: Change all uses.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Dec 2022 18:43:12 -0500
parents ad014fc78bd6
children 431f80aba37a
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: 29358
diff changeset
3 // Copyright (C) 2013-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 ////////////////////////////////////////////////////////////////////////
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
25
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
26 /* This is the main window derived from QMainWindow for being used
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
27 as the main window in dock widgets like the variable editor or
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
28 the file editor
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
29 */
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
30
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
31 #if defined (HAVE_CONFIG_H)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
32 # include "config.h"
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
33 #endif
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
34
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
35 #include <QDockWidget>
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
36 #include <QMenu>
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
37
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27277
diff changeset
38 #include "dw-main-window.h"
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
39 #include "gui-preferences-sc.h"
31621
0645ea65ca6b handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
40 #include "gui-settings.h"
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
41 #include "octave-qobject.h"
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
42 #include "shortcut-manager.h"
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
43
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
44 namespace octave
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
45 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
46
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
47 dw_main_window::dw_main_window (base_qobject& oct_qobj, QWidget *p)
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
48 : QMainWindow (p), m_octave_qobj (oct_qobj)
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
49 {
31621
0645ea65ca6b handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
50 gui_settings settings;
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
51
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
52 // Adding the actions for closing the dock widgets
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
53 m_close_action
31621
0645ea65ca6b handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
54 = add_action (nullptr, settings.icon ("window-close", false),
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
55 tr ("&Close"), SLOT (request_close ()), this);
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
56
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
57 m_close_all_action
31621
0645ea65ca6b handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
58 = add_action (nullptr, settings.icon ("window-close", false),
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
59 tr ("Close &All"), SLOT (request_close_all ()), this);
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
60
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
61 m_close_others_action
31621
0645ea65ca6b handle icons and themes in gui_settings class, not resource_manager
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
62 = add_action (nullptr, settings.icon ("window-close", false),
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
63 tr ("Close &Other"), SLOT (request_close_other ()), this);
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
64
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
65 m_switch_left_action
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
66 = add_action (nullptr, QIcon (), tr ("Switch to &Left Widget"),
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
67 SLOT (request_switch_left ()), this);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
68
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
69 m_switch_right_action
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
70 = add_action (nullptr, QIcon (), tr ("Switch to &Right Widget"),
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
71 SLOT (request_switch_right ()), this);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
72
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
73 // The list of actions for floating widgets
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
74 m_actions_list << m_close_action;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
75 m_actions_list << m_close_others_action;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
76 m_actions_list << m_close_all_action;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
77 m_actions_list << m_switch_left_action;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
78 m_actions_list << m_switch_right_action;
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
79
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
80 notice_settings ();
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
81 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
82
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
83
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
84 // Re-implementing the popup menu of the main window
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
85 QMenu *dw_main_window::createPopupMenu ()
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
86 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
87 QList<QAction *> new_actions = QList<QAction *> ();
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
88 new_actions.append (m_close_action);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
89 new_actions.append (m_close_others_action);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
90 new_actions.append (m_close_all_action);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
91
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
92 QMenu *menu = QMainWindow::createPopupMenu ();
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
93 QList<QAction *> actions = menu->actions();
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
94
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
95 if (actions.length () > 0)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
96 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
97 QAction *sep = menu->insertSeparator (actions.at (0));
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
98 menu->insertActions (sep, new_actions);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
99 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
100 else
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
101 menu->addActions (new_actions);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
102
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
103 return menu;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
104 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
105
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
106
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
107 // Adding an action to the main window
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
108 QAction * dw_main_window::add_action (QMenu *menu, const QIcon& icon,
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
109 const QString& text, const char *member,
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
110 QWidget *receiver)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
111 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
112 QAction *a;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
113 QWidget *r = this;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
114
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
115 if (receiver != nullptr)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
116 r = receiver;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
117
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
118 if (menu)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
119 a = menu->addAction (icon, text, r, member);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
120 else
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
121 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
122 a = new QAction (icon, text, this);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
123 a->setEnabled (true);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
124 connect (a, SIGNAL (triggered ()), r, member);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
125 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
126
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
127 addAction (a); // important for shortcut context
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
128 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
129
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
130 return a;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
131 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
132
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
133 // Update the settings
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
134 void dw_main_window::notice_settings (void)
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
135 {
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
136 shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager ();
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
137
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27630
diff changeset
138 scmgr.set_shortcut (m_close_action, sc_edit_file_close);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27630
diff changeset
139 scmgr.set_shortcut (m_close_all_action, sc_edit_file_close_all);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27630
diff changeset
140 scmgr.set_shortcut (m_close_others_action, sc_edit_file_close_other);
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
141
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27630
diff changeset
142 scmgr.set_shortcut (m_switch_left_action, sc_edit_tabs_switch_left_tab);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27630
diff changeset
143 scmgr.set_shortcut (m_switch_right_action, sc_edit_tabs_switch_right_tab);
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
144 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
145
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
146
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
147 // Slots for handling actions
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
148
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
149 // Close current widget
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
150 void dw_main_window::request_close ()
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
151 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
152 for (int i = 0; i < m_dw_list.length (); i++)
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
153 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
154 if (m_dw_list.at (i)->hasFocus ())
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
155 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
156 m_dw_list.at (i)->close ();
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
157 if (i > 0)
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
158 m_dw_list.at (i-1)->setFocus ();
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
159 break;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
160 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
161 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
162 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
163
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
164 // Close other widgets
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
165 void dw_main_window::request_close_other ()
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
166 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
167 for (int i = m_dw_list.length () - 1; i >= 0; i--)
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
168 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
169 if (! m_dw_list.at (i)->hasFocus ())
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
170 m_dw_list.at (i)->close ();
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
171 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
172 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
173
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
174 // Close all widgets
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
175 void dw_main_window::request_close_all ()
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
176 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
177 for (int i = m_dw_list.length () - 1; i >= 0; i--)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
178 m_dw_list.at (i)->close ();
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
179 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
180
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
181 // Switch to left widget
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
182 void dw_main_window::request_switch_left ()
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
183 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
184 request_switch (-1);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
185 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
186
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
187 // Switch to right widget
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
188 void dw_main_window::request_switch_right ()
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
189 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
190 request_switch (1);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
191 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
192
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
193 // Switch to left/right widget
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
194 void dw_main_window::request_switch (int direction)
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
195 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
196 int active = -1, next;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
197
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
198 for (int i = m_dw_list.length () - 1; i >= 0; i--)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
199 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
200 if (m_dw_list.at (i)->hasFocus ())
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
201 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
202 active = i;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
203 break;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
204 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
205 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
206
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
207 if (active == -1)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
208 return;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
209
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
210 if (direction == -1 && active == 0)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
211 next = m_dw_list.length () - 1;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
212 else if (direction == 1 && active == m_dw_list.length () - 1)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
213 next = 0;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
214 else
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
215 next = active + direction;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
216
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
217 m_dw_list.at (next)->raise ();
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
218 m_dw_list.at (next)->activateWindow ();
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
219 m_dw_list.at (next)->setFocus ();
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
220 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
221
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
222
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
223 // Reimplemented Event
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
224 bool dw_main_window::event (QEvent *ev)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
225 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
226 if (ev->type () == QEvent::ChildAdded
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
227 || ev->type () == QEvent::ChildRemoved)
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
228 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
229 // Adding or Removing a child indicates that a dock widget was
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
230 // created or removed.
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
231 // In all cases, the list of dock widgets has to be updated.
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
232 m_dw_list = findChildren<QDockWidget *>();
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
233 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
234
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
235 if (ev->type () == QEvent::StyleChange)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
236 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
237 // This might indicate un- or re-docking a widget: Make sure
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27818
diff changeset
238 // floating widgets get a copy of our actions
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
239 for (int i = m_dw_list.length () - 1; i >= 0; i--)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
240 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
241 // First remove possibly existing actions
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
242 for (int j = m_actions_list.length () - 1; j >0; j--)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
243 m_dw_list.at (i)->removeAction (m_actions_list.at (j));
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
244
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
245 // Then add our actions for floating widgets
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
246 if (m_dw_list.at (i)->isFloating ())
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
247 m_dw_list.at (i)->addActions (m_actions_list);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
248 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
249 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
250
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
251 return QMainWindow::event (ev);
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
252 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
253
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
254 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
255