annotate libgui/src/dw-main-window.cc @ 25411:ad3d018e595f

provide shortcuts for switching between widgets in var. editor (bug #53002) * dw-main-window.cc (dw_main_window): add new actions for switching to next/previous widget, collect all actions that are required in floating widgets in a list; (notice_settings): set the shortcuts for the new actions; (request_close_file, request_close_other_files, request_close_all_files): renamed, dropping term file, and using the new class variable storing the list of current dock widgets; (request_switch_left, request_switch_right): new slots for the new actions; (request_switch): function with common part for switching widgets; (event): re-implementation of the event method, updating the list of all dock widgets when widget was added or removed, and adding actions to floating widgets when floating status has changed. * dw_main-window.h: re-implemented event, new actions wit new slots for switching between widgets, new class variables for widget list and list of actions for floating widgets
author Torsten <mttl@mailbox.org>
date Sat, 26 May 2018 20:50:46 +0200
parents a78e5b8d5ee7
children 00f796120a6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
1 /*
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
2
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
3 Copyright (C) 2013-2018 Torsten <mttl@mailbox.org>
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
4
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
5 This file is part of Octave.
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
6
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
10 (at your option) any later version.
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
11
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
15 GNU General Public License for more details.
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
16
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
19 <https://www.gnu.org/licenses/>.
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
20
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
21 */
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
22
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
23 /* 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
24 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
25 the file editor
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
26 */
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
27
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
28 #if defined (HAVE_CONFIG_H)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
29 # include "config.h"
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
30 #endif
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
31
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
32 #include <QMenu>
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
33 #include <QDockWidget>
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
34
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
35 #include "resource-manager.h"
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
36 #include "shortcut-manager.h"
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
37 #include "dw-main-window.h"
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
38
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
39 namespace octave
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
40 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
41
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
42 dw_main_window::dw_main_window (QWidget *p)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
43 : QMainWindow (p)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
44 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
45 // 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
46 m_close_action
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
47 = add_action (nullptr,
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
48 resource_manager::icon ("window-close",false),
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
49 tr ("&Close"),
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
50 SLOT (request_close ()), this);
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
51
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
52 m_close_all_action
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
53 = add_action (nullptr,
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
54 resource_manager::icon ("window-close",false),
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
55 tr ("Close &All"),
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
56 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
57
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
58 m_close_others_action
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
59 = add_action (nullptr,
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
60 resource_manager::icon ("window-close",false),
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
61 tr ("Close &Other"),
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
62 SLOT (request_close_other ()), this);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
63
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
64 m_switch_left_action
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
65 = 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
66 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
67
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
68 m_switch_right_action
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
69 = 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
70 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
71
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
72 // 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
73 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
74 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
75 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
76 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
77 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
78
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
79 notice_settings (resource_manager::get_settings ());
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
80 }
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 // 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
84 QMenu *dw_main_window::createPopupMenu ()
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
85 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
86 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
87 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
88 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
89 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
90
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
91 QMenu *menu = QMainWindow::createPopupMenu ();
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
92 QList<QAction *> actions = menu->actions();
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
93
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
94 if (actions.length () > 0)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
95 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
96 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
97 menu->insertActions (sep, new_actions);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
98 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
99 else
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
100 menu->addActions (new_actions);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
101
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
102 return menu;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
103 }
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 // 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
107 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
108 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
109 QWidget *receiver)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
110 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
111 QAction *a;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
112 QWidget *r = this;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
113
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
114 if (receiver != nullptr)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
115 r = receiver;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
116
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
117 if (menu)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
118 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
119 else
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
120 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
121 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
122 a->setEnabled (true);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
123 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
124 }
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 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
127 a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
128
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
129 return a;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
130 }
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 // Update the settings
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
133 void dw_main_window::notice_settings (const QSettings*)
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
134 {
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
135 shortcut_manager::set_shortcut (m_close_action, "editor_file:close");
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
136 shortcut_manager::set_shortcut (m_close_all_action, "editor_file:close_all");
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
137 shortcut_manager::set_shortcut (m_close_others_action, "editor_file:close_other");
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
138
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
139 shortcut_manager::set_shortcut (m_switch_left_action, "editor_tabs:switch_left_tab");
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
140 shortcut_manager::set_shortcut (m_switch_right_action, "editor_tabs:switch_right_tab");
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
141 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
142
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
143
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
144 // Slots for handling actions
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 // Close current widget
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
147 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
148 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
149 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
150 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
151 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
152 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
153 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
154 if (i > 0)
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
155 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
156 break;
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
157 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
158 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
159 }
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 // Close other widgets
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
162 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
163 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
164 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
165 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
166 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
167 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
168 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
169 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
170
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
171 // Close all widgets
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
172 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
173 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
174 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
175 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
176 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
177
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
178 // Switch to left widget
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
179 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
180 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
181 request_switch (-1);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
182 }
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 // Switch to right widget
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
185 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
186 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
187 request_switch (1);
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
188 }
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 // 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
191 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
192 {
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
193 int active = -1, next;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
194
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
195 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
196 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
197 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
198 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
199 active = i;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
200 break;
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 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
203
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
204 if (active == -1)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
205 return;
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 (direction == -1 && active == 0)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
208 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
209 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
210 next = 0;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
211 else
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
212 next = active + direction;
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
213
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
214 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
215 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
216 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
217 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
218
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
219
25411
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
220 // Reimplemented Event
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
221 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
222 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
223 if (ev->type () == QEvent::ChildAdded ||
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
224 ev->type () == QEvent::ChildRemoved)
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
225 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
226 // 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
227 // created or removed.
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
228 // 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
229 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
230 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
231
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
232 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
233 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
234 // This might indicate un- or re-docking a widget: Make sure
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
235 // floating widget get a copy of our actions
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
236 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
237 {
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
238 // 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
239 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
240 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
241
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
242 // 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
243 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
244 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
245 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
246 }
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
247
ad3d018e595f provide shortcuts for switching between widgets in var. editor (bug #53002)
Torsten <mttl@mailbox.org>
parents: 25398
diff changeset
248 return QMainWindow::event (ev);
25398
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
249 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
250
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
251 }
a78e5b8d5ee7 provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff changeset
252